mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Refactor Vite integration and update docs
Introduced a Vite adapter with "fresh" and "cached" modes, centralized dev server configuration, and streamlined the example setup. Updated documentation with detailed steps for Vite integration and revised the internal dev environment to align with the changes.
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
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);
|
||||
import { serve } from "./src/adapter/vite";
|
||||
|
||||
const credentials = {
|
||||
url: import.meta.env.VITE_DB_URL!,
|
||||
@@ -14,22 +8,10 @@ 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);
|
||||
}
|
||||
};
|
||||
export default serve({
|
||||
connection: {
|
||||
type: "libsql",
|
||||
config: credentials
|
||||
},
|
||||
forceDev: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user