mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix DittoEnv type check
This commit is contained in:
parent
f1cb8c778a
commit
237f6e55ad
3 changed files with 11 additions and 7 deletions
|
|
@ -78,7 +78,6 @@ route.put('/wallet', userMiddleware({ enc: 'nip44' }), async (c) => {
|
||||||
await createEvent({
|
await createEvent({
|
||||||
kind: 17375,
|
kind: 17375,
|
||||||
content: encryptedWalletContentTags,
|
content: encryptedWalletContentTags,
|
||||||
// @ts-ignore kill me
|
|
||||||
}, c);
|
}, c);
|
||||||
|
|
||||||
// Nutzap information
|
// 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
|
['relay', conf.relay], // TODO: add more relays once things get more stable
|
||||||
['pubkey', p2pk],
|
['pubkey', p2pk],
|
||||||
],
|
],
|
||||||
// @ts-ignore kill me
|
|
||||||
}, c);
|
}, c);
|
||||||
|
|
||||||
// TODO: hydrate wallet and add a 'balance' field when a 'renderWallet' view function is created
|
// TODO: hydrate wallet and add a 'balance' field when a 'renderWallet' view function is created
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { User } from '@ditto/mastoapi/middleware';
|
||||||
|
import { DittoEnv } from '@ditto/mastoapi/router';
|
||||||
import { HTTPException } from '@hono/hono/http-exception';
|
import { HTTPException } from '@hono/hono/http-exception';
|
||||||
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { EventTemplate } from 'nostr-tools';
|
import { EventTemplate } from 'nostr-tools';
|
||||||
|
|
@ -6,12 +8,16 @@ import * as TypeFest from 'type-fest';
|
||||||
import { type AppContext } from '@/app.ts';
|
import { type AppContext } from '@/app.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
import { parseFormData } from '@/utils/formdata.ts';
|
import { parseFormData } from '@/utils/formdata.ts';
|
||||||
|
import { Context } from '@hono/hono';
|
||||||
|
|
||||||
/** EventTemplate with defaults. */
|
/** EventTemplate with defaults. */
|
||||||
type EventStub = TypeFest.SetOptional<EventTemplate, 'content' | 'created_at' | 'tags'>;
|
type EventStub = TypeFest.SetOptional<EventTemplate, 'content' | 'created_at' | 'tags'>;
|
||||||
|
|
||||||
/** Publish an event through the pipeline. */
|
/** Publish an event through the pipeline. */
|
||||||
async function createEvent(t: EventStub, c: AppContext): Promise<NostrEvent> {
|
async function createEvent<E extends (DittoEnv & { Variables: { user?: User } })>(
|
||||||
|
t: EventStub,
|
||||||
|
c: Context<E>,
|
||||||
|
): Promise<NostrEvent> {
|
||||||
const { user, relay, signal } = c.var;
|
const { user, relay, signal } = c.var;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import type { NostrEvent } from '@nostrify/nostrify';
|
||||||
type HeaderRecord = Record<string, string | string[]>;
|
type HeaderRecord = Record<string, string | string[]>;
|
||||||
|
|
||||||
/** Return results with pagination headers. Assumes chronological sorting of events. */
|
/** Return results with pagination headers. Assumes chronological sorting of events. */
|
||||||
export function paginated(
|
export function paginated<E extends DittoEnv>(
|
||||||
c: Context<DittoEnv>,
|
c: Context<E>,
|
||||||
events: NostrEvent[],
|
events: NostrEvent[],
|
||||||
body: object | unknown[],
|
body: object | unknown[],
|
||||||
headers: HeaderRecord = {},
|
headers: HeaderRecord = {},
|
||||||
|
|
@ -28,8 +28,8 @@ export function paginated(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** paginate a list of tags. */
|
/** paginate a list of tags. */
|
||||||
export function paginatedList(
|
export function paginatedList<E extends DittoEnv>(
|
||||||
c: Context<DittoEnv>,
|
c: Context<E>,
|
||||||
params: { offset: number; limit: number },
|
params: { offset: number; limit: number },
|
||||||
body: object | unknown[],
|
body: object | unknown[],
|
||||||
headers: HeaderRecord = {},
|
headers: HeaderRecord = {},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue