Files
bknd-examples/bknd.config.ts
Shishant Biswas d9c3de22cb testing mirror
2026-02-27 09:16:29 +05:30

51 lines
1.2 KiB
TypeScript

import { type BkndConfig, em, entity, text, boolean, libsql } from "bknd";
import { registerLocalMediaAdapter } from "bknd/adapter/node";
const local = registerLocalMediaAdapter();
const schema = em({
todos: entity("todos", {
title: text(),
done: boolean(),
}),
});
// register your schema to get automatic type completion
type Database = (typeof schema)["DB"];
declare module "bknd" {
interface DB extends Database {}
}
export default {
connection: libsql({
url: process.env.DATABASE_URL || "http://localhost:8080",
}),
options: {
// the seed option is only executed if the database was empty
seed: async (ctx) => {
// create some entries
await ctx.em.mutator("todos").insertMany([
{ title: "Learn bknd", done: true },
{ title: "Build something cool", done: false },
]);
// and create a user
await ctx.app.module.auth.createUser({
email: "dswbx@bknd.io",
password: "12345678",
});
},
},
config: {
data: schema.toJSON(),
auth: { enabled: true },
media: {
enabled: true,
adapter: local({
path: "./public/uploads",
}),
},
},
} satisfies BkndConfig;