mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
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.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
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!,
|
|
authToken: import.meta.env.VITE_DB_TOKEN!
|
|
};
|
|
if (!credentials.url) {
|
|
throw new Error("Missing VITE_DB_URL env variable. Add it to .env file");
|
|
}
|
|
|
|
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);
|
|
}
|
|
};
|