mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
update plasmic package to omit cjs, migrated example from nextjs to vite/wouter
This commit is contained in:
43
examples/plasmic/src/server.ts
Normal file
43
examples/plasmic/src/server.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { App } from "bknd";
|
||||
import { serve } from "bknd/adapter/vite";
|
||||
import { boolean, em, entity, text } from "bknd/data";
|
||||
import { secureRandomString } from "bknd/utils";
|
||||
|
||||
export default serve({
|
||||
initialConfig: {
|
||||
data: em({
|
||||
todos: entity("todos", {
|
||||
title: text(),
|
||||
done: boolean()
|
||||
})
|
||||
}).toJSON(),
|
||||
auth: {
|
||||
enabled: true,
|
||||
jwt: {
|
||||
secret: secureRandomString(64)
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
seed: async (ctx) => {
|
||||
await ctx.em.mutator("todos" as any).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"
|
||||
);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user