From 237f6e55ad3312b50a93f32f91233f90b0879cf7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 22 Feb 2025 21:52:26 -0600 Subject: [PATCH] Fix DittoEnv type check --- packages/ditto/controllers/api/cashu.ts | 2 -- packages/ditto/utils/api.ts | 8 +++++++- packages/mastoapi/pagination/paginate.ts | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/ditto/controllers/api/cashu.ts b/packages/ditto/controllers/api/cashu.ts index a98a0309..4546dda3 100644 --- a/packages/ditto/controllers/api/cashu.ts +++ b/packages/ditto/controllers/api/cashu.ts @@ -78,7 +78,6 @@ route.put('/wallet', userMiddleware({ enc: 'nip44' }), async (c) => { await createEvent({ kind: 17375, content: encryptedWalletContentTags, - // @ts-ignore kill me }, c); // Nutzap information @@ -89,7 +88,6 @@ route.put('/wallet', userMiddleware({ enc: 'nip44' }), async (c) => { ['relay', conf.relay], // TODO: add more relays once things get more stable ['pubkey', p2pk], ], - // @ts-ignore kill me }, c); // TODO: hydrate wallet and add a 'balance' field when a 'renderWallet' view function is created diff --git a/packages/ditto/utils/api.ts b/packages/ditto/utils/api.ts index 80dc4e57..58740917 100644 --- a/packages/ditto/utils/api.ts +++ b/packages/ditto/utils/api.ts @@ -1,3 +1,5 @@ +import { User } from '@ditto/mastoapi/middleware'; +import { DittoEnv } from '@ditto/mastoapi/router'; import { HTTPException } from '@hono/hono/http-exception'; import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import { EventTemplate } from 'nostr-tools'; @@ -6,12 +8,16 @@ import * as TypeFest from 'type-fest'; import { type AppContext } from '@/app.ts'; import { nostrNow } from '@/utils.ts'; import { parseFormData } from '@/utils/formdata.ts'; +import { Context } from '@hono/hono'; /** EventTemplate with defaults. */ type EventStub = TypeFest.SetOptional; /** Publish an event through the pipeline. */ -async function createEvent(t: EventStub, c: AppContext): Promise { +async function createEvent( + t: EventStub, + c: Context, +): Promise { const { user, relay, signal } = c.var; if (!user) { diff --git a/packages/mastoapi/pagination/paginate.ts b/packages/mastoapi/pagination/paginate.ts index 26be72bd..aab93a47 100644 --- a/packages/mastoapi/pagination/paginate.ts +++ b/packages/mastoapi/pagination/paginate.ts @@ -7,8 +7,8 @@ import type { NostrEvent } from '@nostrify/nostrify'; type HeaderRecord = Record; /** Return results with pagination headers. Assumes chronological sorting of events. */ -export function paginated( - c: Context, +export function paginated( + c: Context, events: NostrEvent[], body: object | unknown[], headers: HeaderRecord = {}, @@ -28,8 +28,8 @@ export function paginated( } /** paginate a list of tags. */ -export function paginatedList( - c: Context, +export function paginatedList( + c: Context, params: { offset: number; limit: number }, body: object | unknown[], headers: HeaderRecord = {},