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

@@ -15,7 +15,7 @@ import {
import { Hono } from "hono";
import type { Handler } from "hono/types";
import type { ModuleBuildContext } from "modules";
import { AppData } from "../AppData";
import * as SystemPermissions from "modules/permissions";
import { type AppDataConfig, FIELDS } from "../data-schema";
export class DataController implements ClassController {
@@ -89,12 +89,10 @@ export class DataController implements ClassController {
return func;
}
// add timing
/*hono.use("*", async (c, next) => {
startTime(c, "data");
hono.use("*", async (c, next) => {
this.ctx.guard.throwUnlessGranted(SystemPermissions.api);
await next();
endTime(c, "data");
});*/
});
// info
hono.get(

View File

@@ -42,6 +42,7 @@ export type DbFunctions = {
};
export abstract class Connection {
cls = "bknd:connection";
kysely: Kysely<any>;
constructor(
@@ -52,6 +53,15 @@ export abstract class Connection {
this.kysely = kysely;
}
/**
* This is a helper function to manage Connection classes
* coming from different places
* @param conn
*/
static isConnection(conn: any): conn is Connection {
return conn?.cls === "bknd:connection";
}
getIntrospector(): ConnectionIntrospector {
return this.kysely.introspection as ConnectionIntrospector;
}

View File

@@ -36,7 +36,7 @@ export class EntityManager<DB> {
relations.forEach((relation) => this.addRelation(relation));
indices.forEach((index) => this.addIndex(index));
if (!(connection instanceof Connection)) {
if (!Connection.isConnection(connection)) {
throw new UnableToConnectException("");
}