diff --git a/src/deps.ts b/src/deps.ts index d8c9c8f..bcc3f42 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -63,3 +63,5 @@ export { } from 'npm:kysely@^0.25.0'; export { DenoSqliteDialect } from 'https://gitlab.com/soapbox-pub/kysely-deno-sqlite/-/raw/v1.0.0/mod.ts'; export { default as tldts } from 'npm:tldts@^6.0.14'; + +export type * as TypeFest from 'npm:type-fest@^4.3.0'; diff --git a/src/utils/web.ts b/src/utils/web.ts index 5df0060..7044d04 100644 --- a/src/utils/web.ts +++ b/src/utils/web.ts @@ -1,15 +1,13 @@ import { Conf } from '@/config.ts'; -import { type Context, type Event, EventTemplate, HTTPException, parseFormData, z } from '@/deps.ts'; +import { type Context, type Event, EventTemplate, HTTPException, parseFormData, type TypeFest, z } from '@/deps.ts'; import * as pipeline from '@/pipeline.ts'; import { signAdminEvent, signEvent } from '@/sign.ts'; import { nostrNow } from '@/utils.ts'; import type { AppContext } from '@/app.ts'; -/** EventTemplate with or without a timestamp. If no timestamp is given, it will be generated. */ -interface EventStub extends Omit, 'created_at'> { - created_at?: number; -} +/** EventTemplate with defaults. */ +type EventStub = TypeFest.SetOptional, 'created_at' | 'tags'>; /** Publish an event through the pipeline. */ async function createEvent(t: EventStub, c: AppContext): Promise> { @@ -21,6 +19,7 @@ async function createEvent(t: EventStub, c: AppContext): Pr const event = await signEvent({ created_at: nostrNow(), + tags: [], ...t, }, c); @@ -31,6 +30,7 @@ async function createEvent(t: EventStub, c: AppContext): Pr async function createAdminEvent(t: EventStub, c: AppContext): Promise> { const event = await signAdminEvent({ created_at: nostrNow(), + tags: [], ...t, });