ditto/src/db.ts

18 lines
358 B
TypeScript
Raw Normal View History

import { createPentagon, z } from '@/deps.ts';
2023-07-09 16:47:19 +00:00
const kv = await Deno.openKv();
2023-07-09 16:47:19 +00:00
const userSchema = z.object({
pubkey: z.string().regex(/^[0-9a-f]{64}$/).describe('primary'),
username: z.string().regex(/^[\w_]+$/).describe('unique'),
createdAt: z.date(),
2023-07-09 16:47:19 +00:00
});
const db = createPentagon(kv, {
users: {
schema: userSchema,
},
});
export { db };