utils/web: make `tags` optional
This commit is contained in:
parent
1b2a486c65
commit
67bba508af
|
@ -63,3 +63,5 @@ export {
|
||||||
} from 'npm:kysely@^0.25.0';
|
} from 'npm:kysely@^0.25.0';
|
||||||
export { DenoSqliteDialect } from 'https://gitlab.com/soapbox-pub/kysely-deno-sqlite/-/raw/v1.0.0/mod.ts';
|
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 { default as tldts } from 'npm:tldts@^6.0.14';
|
||||||
|
|
||||||
|
export type * as TypeFest from 'npm:type-fest@^4.3.0';
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import { Conf } from '@/config.ts';
|
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 * as pipeline from '@/pipeline.ts';
|
||||||
import { signAdminEvent, signEvent } from '@/sign.ts';
|
import { signAdminEvent, signEvent } from '@/sign.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
|
|
||||||
import type { AppContext } from '@/app.ts';
|
import type { AppContext } from '@/app.ts';
|
||||||
|
|
||||||
/** EventTemplate with or without a timestamp. If no timestamp is given, it will be generated. */
|
/** EventTemplate with defaults. */
|
||||||
interface EventStub<K extends number = number> extends Omit<EventTemplate<K>, 'created_at'> {
|
type EventStub<K extends number = number> = TypeFest.SetOptional<EventTemplate<K>, 'created_at' | 'tags'>;
|
||||||
created_at?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Publish an event through the pipeline. */
|
/** Publish an event through the pipeline. */
|
||||||
async function createEvent<K extends number>(t: EventStub<K>, c: AppContext): Promise<Event<K>> {
|
async function createEvent<K extends number>(t: EventStub<K>, c: AppContext): Promise<Event<K>> {
|
||||||
|
@ -21,6 +19,7 @@ async function createEvent<K extends number>(t: EventStub<K>, c: AppContext): Pr
|
||||||
|
|
||||||
const event = await signEvent({
|
const event = await signEvent({
|
||||||
created_at: nostrNow(),
|
created_at: nostrNow(),
|
||||||
|
tags: [],
|
||||||
...t,
|
...t,
|
||||||
}, c);
|
}, c);
|
||||||
|
|
||||||
|
@ -31,6 +30,7 @@ async function createEvent<K extends number>(t: EventStub<K>, c: AppContext): Pr
|
||||||
async function createAdminEvent<K extends number>(t: EventStub<K>, c: AppContext): Promise<Event<K>> {
|
async function createAdminEvent<K extends number>(t: EventStub<K>, c: AppContext): Promise<Event<K>> {
|
||||||
const event = await signAdminEvent({
|
const event = await signAdminEvent({
|
||||||
created_at: nostrNow(),
|
created_at: nostrNow(),
|
||||||
|
tags: [],
|
||||||
...t,
|
...t,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue