mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
updated examples: astro, nextjs, remix, bun, node
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"_variables": {
|
||||
"lastUpdateCheck": 1732785435939
|
||||
"lastUpdateCheck": 1734966049246
|
||||
}
|
||||
}
|
||||
3
examples/astro/.gitignore
vendored
3
examples/astro/.gitignore
vendored
@@ -21,4 +21,5 @@ pnpm-debug.log*
|
||||
.DS_Store
|
||||
|
||||
# jetbrains setting folder
|
||||
.idea/
|
||||
.idea/
|
||||
*.db
|
||||
@@ -14,7 +14,7 @@ export const prerender = false;
|
||||
<body>
|
||||
<Admin
|
||||
withProvider={{ user }}
|
||||
config={{ basepath: "/admin", color_scheme: "dark" }}
|
||||
config={{ basepath: "/admin", color_scheme: "dark", logo_return_path: "/../" }}
|
||||
client:only
|
||||
/>
|
||||
</body>
|
||||
|
||||
@@ -1,12 +1,70 @@
|
||||
import { App } from "bknd";
|
||||
import { serve } from "bknd/adapter/astro";
|
||||
import { registerLocalMediaAdapter } from "bknd/adapter/node";
|
||||
import { boolean, em, entity, text } from "bknd/data";
|
||||
import { secureRandomString } from "bknd/utils";
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
// since we're running in node, we can register the local media adapter
|
||||
registerLocalMediaAdapter();
|
||||
|
||||
export const ALL = serve({
|
||||
// we can use any libsql config, and if omitted, uses in-memory
|
||||
connection: {
|
||||
type: "libsql",
|
||||
config: {
|
||||
url: "file:test.db"
|
||||
}
|
||||
},
|
||||
// an initial config is only applied if the database is empty
|
||||
initialConfig: {
|
||||
// the em() function makes it easy to create an initial schema
|
||||
data: em({
|
||||
todos: entity("todos", {
|
||||
title: text(),
|
||||
done: boolean()
|
||||
})
|
||||
}).toJSON(),
|
||||
// we're enabling auth ...
|
||||
auth: {
|
||||
enabled: true,
|
||||
jwt: {
|
||||
secret: secureRandomString(64)
|
||||
}
|
||||
},
|
||||
// ... and media
|
||||
media: {
|
||||
enabled: true,
|
||||
adapter: {
|
||||
type: "local",
|
||||
config: {
|
||||
path: "./public"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
// the seed option is only executed if the database was empty
|
||||
seed: async (ctx) => {
|
||||
await ctx.em.mutator("todos").insertMany([
|
||||
{ title: "Learn bknd", done: true },
|
||||
{ title: "Build something cool", done: false }
|
||||
]);
|
||||
}
|
||||
},
|
||||
// here we can hook into the app lifecycle events ...
|
||||
beforeBuild: async (app) => {
|
||||
app.emgr.onEvent(
|
||||
App.Events.AppFirstBoot,
|
||||
async () => {
|
||||
// ... to create an initial user
|
||||
await app.module.auth.createUser({
|
||||
email: "ds@bknd.io",
|
||||
password: "12345678"
|
||||
});
|
||||
},
|
||||
"sync"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user