diff --git a/deno.json b/deno.json index b417514..26cf366 100644 --- a/deno.json +++ b/deno.json @@ -19,7 +19,8 @@ "hono": "https://deno.land/x/hono@v3.10.1/mod.ts", "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", "kysely": "npm:kysely@^0.26.3", - "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts" + "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts", + "zod": "npm:zod@^3.23.4" }, "lint": { "include": ["src/", "scripts/"], diff --git a/src/config.ts b/src/config.ts index 4723a54..dfcd2f7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,7 @@ import url from 'node:url'; +import { z } from 'zod'; -import { dotenv, getPublicKey, nip19, z } from '@/deps.ts'; +import { dotenv, getPublicKey, nip19 } from '@/deps.ts'; /** Load environment config from `.env` */ await dotenv.load({ diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index 472c9e5..466725d 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -1,7 +1,9 @@ import { NostrFilter } from '@nostrify/nostrify'; +import { z } from 'zod'; + import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { nip19, z } from '@/deps.ts'; +import { nip19 } from '@/deps.ts'; import { getAuthor, getFollowedPubkeys } from '@/queries.ts'; import { booleanParamSchema, fileSchema } from '@/schema.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; diff --git a/src/controllers/api/admin.ts b/src/controllers/api/admin.ts index c3a5c3d..990c0fc 100644 --- a/src/controllers/api/admin.ts +++ b/src/controllers/api/admin.ts @@ -1,6 +1,7 @@ +import { z } from 'zod'; + import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { z } from '@/deps.ts'; import { booleanParamSchema } from '@/schema.ts'; import { eventsDB } from '@/storages.ts'; import { renderAdminAccount } from '@/views/mastodon/admin-accounts.ts'; diff --git a/src/controllers/api/media.ts b/src/controllers/api/media.ts index 3a77175..dd36a53 100644 --- a/src/controllers/api/media.ts +++ b/src/controllers/api/media.ts @@ -1,5 +1,6 @@ +import { z } from 'zod'; + import { AppController } from '@/app.ts'; -import { z } from '@/deps.ts'; import { fileSchema } from '@/schema.ts'; import { parseBody } from '@/utils/api.ts'; import { renderAttachment } from '@/views/mastodon/attachments.ts'; diff --git a/src/controllers/api/oauth.ts b/src/controllers/api/oauth.ts index 267abb7..7ada2a4 100644 --- a/src/controllers/api/oauth.ts +++ b/src/controllers/api/oauth.ts @@ -1,4 +1,6 @@ -import { lodash, nip19, z } from '@/deps.ts'; +import { z } from 'zod'; + +import { lodash, nip19 } from '@/deps.ts'; import { AppController } from '@/app.ts'; import { nostrNow } from '@/utils.ts'; import { parseBody } from '@/utils/api.ts'; diff --git a/src/controllers/api/pleroma.ts b/src/controllers/api/pleroma.ts index 9425878..64984d7 100644 --- a/src/controllers/api/pleroma.ts +++ b/src/controllers/api/pleroma.ts @@ -1,6 +1,7 @@ +import { z } from 'zod'; + import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { z } from '@/deps.ts'; import { configSchema, elixirTupleSchema, type PleromaConfig } from '@/schemas/pleroma-api.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { eventsDB } from '@/storages.ts'; diff --git a/src/controllers/api/search.ts b/src/controllers/api/search.ts index 628bb3a..1e1e509 100644 --- a/src/controllers/api/search.ts +++ b/src/controllers/api/search.ts @@ -1,6 +1,8 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; +import { z } from 'zod'; + import { AppController } from '@/app.ts'; -import { nip19, z } from '@/deps.ts'; +import { nip19 } from '@/deps.ts'; import { booleanParamSchema } from '@/schema.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts'; import { searchStore } from '@/storages.ts'; diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index b063abd..ff7724f 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -1,8 +1,10 @@ import { NIP05, NostrEvent, NostrFilter } from '@nostrify/nostrify'; +import { z } from 'zod'; + import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; import { getUnattachedMediaByIds } from '@/db/unattached-media.ts'; -import { ISO6391, nip19, z } from '@/deps.ts'; +import { ISO6391, nip19 } from '@/deps.ts'; import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { addTag, deleteTag } from '@/tags.ts'; diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 4ad878e..fcfc5d3 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -1,7 +1,9 @@ import { NostrFilter } from '@nostrify/nostrify'; +import { z } from 'zod'; + import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { Debug, z } from '@/deps.ts'; +import { Debug } from '@/deps.ts'; import { getFeedPubkeys } from '@/queries.ts'; import { Sub } from '@/subs.ts'; import { bech32ToPubkey } from '@/utils.ts'; diff --git a/src/controllers/api/timelines.ts b/src/controllers/api/timelines.ts index ebf1912..18bb25e 100644 --- a/src/controllers/api/timelines.ts +++ b/src/controllers/api/timelines.ts @@ -1,7 +1,8 @@ import { NostrFilter } from '@nostrify/nostrify'; +import { z } from 'zod'; + import { type AppContext, type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { z } from '@/deps.ts'; import { getFeedPubkeys } from '@/queries.ts'; import { booleanParamSchema } from '@/schema.ts'; import { eventsDB } from '@/storages.ts'; diff --git a/src/controllers/api/trends.ts b/src/controllers/api/trends.ts index 7970300..cd4d0f2 100644 --- a/src/controllers/api/trends.ts +++ b/src/controllers/api/trends.ts @@ -1,6 +1,7 @@ +import { z } from 'zod'; + import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { z } from '@/deps.ts'; import { Time } from '@/utils.ts'; import { stripTime } from '@/utils/time.ts'; import { TrendsWorker } from '@/workers/trends.ts'; diff --git a/src/controllers/well-known/nostr.ts b/src/controllers/well-known/nostr.ts index 7c812c7..f1ebb6b 100644 --- a/src/controllers/well-known/nostr.ts +++ b/src/controllers/well-known/nostr.ts @@ -1,5 +1,6 @@ +import { z } from 'zod'; + import { AppController } from '@/app.ts'; -import { z } from '@/deps.ts'; import { localNip05Lookup } from '@/utils/nip05.ts'; const nameSchema = z.string().min(1).regex(/^\w+$/); diff --git a/src/controllers/well-known/webfinger.ts b/src/controllers/well-known/webfinger.ts index 1b353ee..9a24576 100644 --- a/src/controllers/well-known/webfinger.ts +++ b/src/controllers/well-known/webfinger.ts @@ -1,5 +1,7 @@ +import { z } from 'zod'; + import { Conf } from '@/config.ts'; -import { nip19, z } from '@/deps.ts'; +import { nip19 } from '@/deps.ts'; import { localNip05Lookup } from '@/utils/nip05.ts'; import type { AppContext, AppController } from '@/app.ts'; diff --git a/src/deps.ts b/src/deps.ts index f8ba0a8..3beda47 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,5 +1,4 @@ import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts'; -export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts'; export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34'; export { type EventTemplate, diff --git a/src/filter.ts b/src/filter.ts index 7dc7523..9e99c4a 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,5 +1,7 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; -import { stringifyStable, z } from '@/deps.ts'; +import { z } from 'zod'; + +import { stringifyStable } from '@/deps.ts'; import { isReplaceableKind } from '@/kinds.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts'; diff --git a/src/schema.ts b/src/schema.ts index 8868cca..74dc7af 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,4 +1,4 @@ -import { z } from '@/deps.ts'; +import { z } from 'zod'; /** Validates individual items in an array, dropping any that aren't valid. */ function filteredArray(schema: T) { diff --git a/src/schemas/activitypub.ts b/src/schemas/activitypub.ts index 04fac39..f14c994 100644 --- a/src/schemas/activitypub.ts +++ b/src/schemas/activitypub.ts @@ -1,4 +1,4 @@ -import { z } from '@/deps.ts'; +import { z } from 'zod'; const apId = z.string().url(); const recipients = z.array(z.string()).catch([]); diff --git a/src/schemas/nostr.ts b/src/schemas/nostr.ts index 708ba96..0497093 100644 --- a/src/schemas/nostr.ts +++ b/src/schemas/nostr.ts @@ -1,4 +1,6 @@ -import { getEventHash, verifyEvent, z } from '@/deps.ts'; +import { z } from 'zod'; + +import { getEventHash, verifyEvent } from '@/deps.ts'; import { jsonSchema, safeUrlSchema } from '@/schema.ts'; /** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */ diff --git a/src/schemas/pleroma-api.ts b/src/schemas/pleroma-api.ts index 7ccd87d..1de171d 100644 --- a/src/schemas/pleroma-api.ts +++ b/src/schemas/pleroma-api.ts @@ -1,4 +1,4 @@ -import { z } from '@/deps.ts'; +import { z } from 'zod'; type ElixirValue = | string diff --git a/src/schemas/webfinger.ts b/src/schemas/webfinger.ts index 2372cf8..8c9cf57 100644 --- a/src/schemas/webfinger.ts +++ b/src/schemas/webfinger.ts @@ -1,4 +1,4 @@ -import { z } from '@/deps.ts'; +import { z } from 'zod'; const linkSchema = z.object({ rel: z.string().optional(), diff --git a/src/uploaders/ipfs.ts b/src/uploaders/ipfs.ts index 7623cd4..5d82e2d 100644 --- a/src/uploaders/ipfs.ts +++ b/src/uploaders/ipfs.ts @@ -1,5 +1,6 @@ +import { z } from 'zod'; + import { Conf } from '@/config.ts'; -import { z } from '@/deps.ts'; import { fetchWorker } from '@/workers/fetch.ts'; import type { Uploader } from './types.ts'; diff --git a/src/utils.ts b/src/utils.ts index 13e5bfc..747ea43 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,7 @@ import { NostrEvent } from '@nostrify/nostrify'; -import { type EventTemplate, getEventHash, nip19, z } from '@/deps.ts'; +import { z } from 'zod'; + +import { type EventTemplate, getEventHash, nip19 } from '@/deps.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts'; /** Get the current time in Nostr format. */ diff --git a/src/utils/api.ts b/src/utils/api.ts index 8e57c1d..79b383d 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,8 +1,10 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import { type Context, HTTPException } from 'hono'; +import { z } from 'zod'; + import { type AppContext } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { Debug, EventTemplate, parseFormData, type TypeFest, z } from '@/deps.ts'; +import { Debug, EventTemplate, parseFormData, type TypeFest } from '@/deps.ts'; import * as pipeline from '@/pipeline.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { APISigner } from '@/signers/APISigner.ts';