mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
reworked html serving, added new permissions for api/auth, updated adapters
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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("");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user