mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Refactor module schema handling and add sync mechanism
Redesigned entity and index management with methods to streamline schema updates and added a sync flag to signal required DB syncs post-build. Enhanced test coverage and functionality for schema modifications, including support for additional fields.
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { serve } from "./src/adapter/vite";
|
||||
import { serveStatic } from "@hono/node-server/serve-static";
|
||||
import { createClient } from "@libsql/client/node";
|
||||
import { App, registries } from "./src";
|
||||
import { LibsqlConnection } from "./src/data";
|
||||
import { StorageLocalAdapter } from "./src/media/storage/adapters/StorageLocalAdapter";
|
||||
|
||||
registries.media.register("local", StorageLocalAdapter);
|
||||
|
||||
const credentials = {
|
||||
url: import.meta.env.VITE_DB_URL!,
|
||||
@@ -8,10 +14,22 @@ if (!credentials.url) {
|
||||
throw new Error("Missing VITE_DB_URL env variable. Add it to .env file");
|
||||
}
|
||||
|
||||
export default serve({
|
||||
connection: {
|
||||
type: "libsql",
|
||||
config: credentials
|
||||
},
|
||||
forceDev: true
|
||||
});
|
||||
const connection = new LibsqlConnection(createClient(credentials));
|
||||
|
||||
export default {
|
||||
async fetch(request: Request) {
|
||||
const app = App.create({ connection });
|
||||
|
||||
app.emgr.onEvent(
|
||||
App.Events.AppBuiltEvent,
|
||||
async () => {
|
||||
app.registerAdminController({ forceDev: true });
|
||||
app.module.server.client.get("/assets/*", serveStatic({ root: "./" }));
|
||||
},
|
||||
"sync"
|
||||
);
|
||||
await app.build();
|
||||
|
||||
return app.fetch(request);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user