From 505b9db409038d77e1c772989642b85576312818 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 9 Jul 2023 11:47:19 -0500 Subject: [PATCH] Try adding Dongoose and a users table --- src/db.ts | 14 ++++++++++++++ src/deps.ts | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/db.ts diff --git a/src/db.ts b/src/db.ts new file mode 100644 index 0000000..9c63ce7 --- /dev/null +++ b/src/db.ts @@ -0,0 +1,14 @@ +import { Dongoose, z } from '@/deps.ts'; + +const db = await Deno.openKv(); + +const Users = Dongoose({ + pubkey: z.string(), + username: z.string(), +}, { + db, + name: 'users', + indexes: ['pubkey', 'username'], +}); + +export { db, Users }; diff --git a/src/deps.ts b/src/deps.ts index 0988800..2b3250e 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -7,7 +7,7 @@ export { } from 'https://deno.land/x/hono@v3.0.2/mod.ts'; export { HTTPException } from 'https://deno.land/x/hono@v3.0.2/http-exception.ts'; export { cors, logger } from 'https://deno.land/x/hono@v3.0.2/middleware.ts'; -export { z } from 'https://deno.land/x/zod@v3.20.5/mod.ts'; +export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts'; export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.5.3'; export { type Filter, @@ -37,3 +37,4 @@ export { default as uuid62 } from 'npm:uuid62@^1.0.2'; // @deno-types="npm:@types/sanitize-html@2.9.0" export { default as sanitizeHtml } from 'npm:sanitize-html@^2.10.0'; export { default as ISO6391 } from 'npm:iso-639-1@2.1.15'; +export { Dongoose } from 'https://raw.githubusercontent.com/alexgleason/dongoose/68b7ad9dd7b6ec0615e246a9f1603123c1709793/mod.ts';