2023-07-09 17:27:10 +00:00
|
|
|
import { createPentagon, z } from '@/deps.ts';
|
2023-07-25 20:30:58 +00:00
|
|
|
import { hexIdSchema } from '@/schema.ts';
|
2023-07-09 16:47:19 +00:00
|
|
|
|
2023-07-09 17:27:10 +00:00
|
|
|
const kv = await Deno.openKv();
|
2023-07-09 16:47:19 +00:00
|
|
|
|
2023-07-09 17:27:10 +00:00
|
|
|
const userSchema = z.object({
|
2023-07-25 20:30:58 +00:00
|
|
|
pubkey: hexIdSchema.describe('primary'),
|
2023-07-09 19:22:18 +00:00
|
|
|
username: z.string().regex(/^\w{1,30}$/).describe('unique'),
|
2023-07-09 17:27:10 +00:00
|
|
|
createdAt: z.date(),
|
2023-07-09 16:47:19 +00:00
|
|
|
});
|
|
|
|
|
2023-07-09 17:27:10 +00:00
|
|
|
const db = createPentagon(kv, {
|
|
|
|
users: {
|
|
|
|
schema: userSchema,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export { db };
|