reworked html serving, added new permissions for api/auth, updated adapters

This commit is contained in:
dswbx
2024-11-23 11:21:09 +01:00
parent 6077f0e64f
commit 2433833ad0
30 changed files with 418 additions and 298 deletions

View File

@@ -7,6 +7,7 @@ import {
type Modules
} from "modules/ModuleManager";
import * as SystemPermissions from "modules/permissions";
import { AdminController, type AdminControllerOptions } from "modules/server/AdminController";
import { SystemController } from "modules/server/SystemController";
export type AppPlugin<DB> = (app: App<DB>) => void;
@@ -58,7 +59,7 @@ export class App<DB = any> {
static create(config: CreateAppConfig) {
let connection: Connection | undefined = undefined;
if (config.connection instanceof Connection) {
if (Connection.isConnection(config.connection)) {
connection = config.connection;
} else if (typeof config.connection === "object") {
switch (config.connection.type) {
@@ -66,6 +67,8 @@ export class App<DB = any> {
connection = new LibsqlConnection(config.connection.config);
break;
}
} else {
throw new Error(`Unknown connection of type ${typeof config.connection} given.`);
}
if (!connection) {
throw new Error("Invalid connection");
@@ -79,7 +82,6 @@ export class App<DB = any> {
}
async build(options?: { sync?: boolean; drop?: boolean; save?: boolean }) {
//console.log("building");
await this.modules.build();
if (options?.sync) {
@@ -136,6 +138,12 @@ export class App<DB = any> {
return this.modules.version();
}
registerAdminController(config?: AdminControllerOptions) {
// register admin
this.modules.server.route("/", new AdminController(this, config).getController());
return this;
}
toJSON(secrets?: boolean) {
return this.modules.toJSON(secrets);
}