mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
Merge pull request #186 from bknd-io/feat/unify-connections
feat/unify-connections
This commit is contained in:
@@ -11,16 +11,9 @@ import {
|
||||
stripMark,
|
||||
transformObject,
|
||||
} from "core/utils";
|
||||
import {
|
||||
type Connection,
|
||||
EntityManager,
|
||||
type Schema,
|
||||
datetime,
|
||||
entity,
|
||||
enumm,
|
||||
jsonSchema,
|
||||
number,
|
||||
} from "data";
|
||||
import type { Connection, Schema } from "data";
|
||||
import { EntityManager } from "data/entities/EntityManager";
|
||||
import * as proto from "data/prototype";
|
||||
import { TransformPersistFailedException } from "data/errors";
|
||||
import { Hono } from "hono";
|
||||
import type { Kysely } from "kysely";
|
||||
@@ -116,12 +109,12 @@ const configJsonSchema = Type.Union([
|
||||
}),
|
||||
),
|
||||
]);
|
||||
export const __bknd = entity(TABLE_NAME, {
|
||||
version: number().required(),
|
||||
type: enumm({ enum: ["config", "diff", "backup"] }).required(),
|
||||
json: jsonSchema({ schema: configJsonSchema }).required(),
|
||||
created_at: datetime(),
|
||||
updated_at: datetime(),
|
||||
export const __bknd = proto.entity(TABLE_NAME, {
|
||||
version: proto.number().required(),
|
||||
type: proto.enumm({ enum: ["config", "diff", "backup"] }).required(),
|
||||
json: proto.jsonSchema({ schema: configJsonSchema }).required(),
|
||||
created_at: proto.datetime(),
|
||||
updated_at: proto.datetime(),
|
||||
});
|
||||
type ConfigTable2 = Schema<typeof __bknd>;
|
||||
interface T_INTERNAL_EM {
|
||||
@@ -234,7 +227,8 @@ export class ModuleManager {
|
||||
}
|
||||
|
||||
private get db() {
|
||||
return this.connection.kysely as Kysely<{ table: ConfigTable }>;
|
||||
// @todo: check why this is neccessary
|
||||
return this.connection.kysely as unknown as Kysely<{ table: ConfigTable }>;
|
||||
}
|
||||
|
||||
// @todo: add indices for: version, type
|
||||
|
||||
@@ -311,6 +311,11 @@ export class SystemController extends Controller {
|
||||
c.json({
|
||||
version: c.get("app")?.version(),
|
||||
runtime: getRuntimeKey(),
|
||||
connection: {
|
||||
name: this.app.em.connection.name,
|
||||
// @ts-expect-error
|
||||
supports: this.app.em.connection.supported,
|
||||
},
|
||||
timezone: {
|
||||
name: getTimezone(),
|
||||
offset: getTimezoneOffset(),
|
||||
|
||||
Reference in New Issue
Block a user