Merge branch 'hono-alias' into 'main'
Import hono with an import alias See merge request soapbox-pub/ditto!172
This commit is contained in:
commit
1c126425ac
|
@ -15,6 +15,8 @@
|
|||
"@/": "./src/",
|
||||
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.9.7",
|
||||
"~/fixtures/": "./fixtures/",
|
||||
"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"
|
||||
},
|
||||
|
|
18
src/app.ts
18
src/app.ts
|
@ -1,21 +1,11 @@
|
|||
import { NostrEvent } from '@nostrify/nostrify';
|
||||
import { type Context, Env as HonoEnv, type Handler, Hono, Input as HonoInput, type MiddlewareHandler } from 'hono';
|
||||
import { cors, logger, serveStatic } from 'hono/middleware';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import '@/cron.ts';
|
||||
import { type User } from '@/db/users.ts';
|
||||
import {
|
||||
type Context,
|
||||
cors,
|
||||
Debug,
|
||||
type Handler,
|
||||
Hono,
|
||||
type HonoEnv,
|
||||
Input,
|
||||
logger,
|
||||
type MiddlewareHandler,
|
||||
sentryMiddleware,
|
||||
serveStatic,
|
||||
} from '@/deps.ts';
|
||||
import { Debug, sentryMiddleware } from '@/deps.ts';
|
||||
import '@/firehose.ts';
|
||||
import { Time } from '@/utils.ts';
|
||||
|
||||
|
@ -103,7 +93,7 @@ interface AppEnv extends HonoEnv {
|
|||
|
||||
type AppContext = Context<AppEnv>;
|
||||
type AppMiddleware = MiddlewareHandler<AppEnv>;
|
||||
type AppController = Handler<AppEnv, any, Input, Response | Promise<Response>>;
|
||||
type AppController = Handler<AppEnv, any, HonoInput, Response | Promise<Response>>;
|
||||
|
||||
const app = new Hono<AppEnv>();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Context } from '@/deps.ts';
|
||||
import type { Context } from 'hono';
|
||||
|
||||
const emptyArrayController = (c: Context) => c.json([]);
|
||||
const emptyObjectController = (c: Context) => c.json({});
|
||||
|
|
10
src/deps.ts
10
src/deps.ts
|
@ -1,14 +1,4 @@
|
|||
import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts';
|
||||
export {
|
||||
type Context,
|
||||
type Env as HonoEnv,
|
||||
type Handler,
|
||||
Hono,
|
||||
HTTPException,
|
||||
type Input,
|
||||
type MiddlewareHandler,
|
||||
} from 'https://deno.land/x/hono@v3.10.1/mod.ts';
|
||||
export { cors, logger, serveStatic } from 'https://deno.land/x/hono@v3.10.1/middleware.ts';
|
||||
export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
|
||||
export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34';
|
||||
export {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { HTTPException } from 'hono';
|
||||
import { type AppMiddleware } from '@/app.ts';
|
||||
import { getPublicKey, HTTPException, nip19 } from '@/deps.ts';
|
||||
import { getPublicKey, nip19 } from '@/deps.ts';
|
||||
|
||||
/** We only accept "Bearer" type. */
|
||||
const BEARER_REGEX = new RegExp(`^Bearer (${nip19.BECH32_REGEX.source})$`);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { NostrEvent } from '@nostrify/nostrify';
|
||||
import { HTTPException } from 'hono';
|
||||
import { type AppContext, type AppMiddleware } from '@/app.ts';
|
||||
import { HTTPException } from '@/deps.ts';
|
||||
import {
|
||||
buildAuthEventTemplate,
|
||||
parseAuthRequest,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Debug, type MiddlewareHandler } from '@/deps.ts';
|
||||
import { type MiddlewareHandler } from 'hono';
|
||||
import { Debug } from '@/deps.ts';
|
||||
import ExpiringCache from '@/utils/expiring-cache.ts';
|
||||
|
||||
const debug = Debug('ditto:middleware:cache');
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { NostrEvent, NostrSigner, NSecSigner } from '@nostrify/nostrify';
|
||||
import { HTTPException } from 'hono';
|
||||
import { type AppContext } from '@/app.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { HTTPException, Stickynotes } from '@/deps.ts';
|
||||
import { Stickynotes } from '@/deps.ts';
|
||||
import { connectResponseSchema } from '@/schemas/nostr.ts';
|
||||
import { jsonSchema } from '@/schema.ts';
|
||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||
import { type Context, HTTPException } from 'hono';
|
||||
import { type AppContext } from '@/app.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { type Context, Debug, EventTemplate, HTTPException, parseFormData, type TypeFest, z } from '@/deps.ts';
|
||||
import { Debug, EventTemplate, parseFormData, type TypeFest, z } from '@/deps.ts';
|
||||
import * as pipeline from '@/pipeline.ts';
|
||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||
import { APISigner } from '@/signers/APISigner.ts';
|
||||
|
|
Loading…
Reference in New Issue