Import hono with an import alias
This commit is contained in:
parent
505a9bced1
commit
64d50552b7
|
@ -15,6 +15,8 @@
|
||||||
"@/": "./src/",
|
"@/": "./src/",
|
||||||
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.9.7",
|
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.9.7",
|
||||||
"~/fixtures/": "./fixtures/",
|
"~/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": "npm:kysely@^0.26.3",
|
||||||
"kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts"
|
"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 { 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 { Conf } from '@/config.ts';
|
||||||
import '@/cron.ts';
|
import '@/cron.ts';
|
||||||
import { type User } from '@/db/users.ts';
|
import { type User } from '@/db/users.ts';
|
||||||
import {
|
import { Debug, sentryMiddleware } from '@/deps.ts';
|
||||||
type Context,
|
|
||||||
cors,
|
|
||||||
Debug,
|
|
||||||
type Handler,
|
|
||||||
Hono,
|
|
||||||
type HonoEnv,
|
|
||||||
Input,
|
|
||||||
logger,
|
|
||||||
type MiddlewareHandler,
|
|
||||||
sentryMiddleware,
|
|
||||||
serveStatic,
|
|
||||||
} from '@/deps.ts';
|
|
||||||
import '@/firehose.ts';
|
import '@/firehose.ts';
|
||||||
import { Time } from '@/utils.ts';
|
import { Time } from '@/utils.ts';
|
||||||
|
|
||||||
|
@ -103,7 +93,7 @@ interface AppEnv extends HonoEnv {
|
||||||
|
|
||||||
type AppContext = Context<AppEnv>;
|
type AppContext = Context<AppEnv>;
|
||||||
type AppMiddleware = MiddlewareHandler<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>();
|
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 emptyArrayController = (c: Context) => c.json([]);
|
||||||
const emptyObjectController = (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';
|
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 { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
|
||||||
export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34';
|
export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34';
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { HTTPException } from 'hono';
|
||||||
import { type AppMiddleware } from '@/app.ts';
|
import { type AppMiddleware } from '@/app.ts';
|
||||||
import { getPublicKey, HTTPException, nip19 } from '@/deps.ts';
|
import { getPublicKey, nip19 } from '@/deps.ts';
|
||||||
|
|
||||||
/** We only accept "Bearer" type. */
|
/** We only accept "Bearer" type. */
|
||||||
const BEARER_REGEX = new RegExp(`^Bearer (${nip19.BECH32_REGEX.source})$`);
|
const BEARER_REGEX = new RegExp(`^Bearer (${nip19.BECH32_REGEX.source})$`);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { NostrEvent } from '@nostrify/nostrify';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { HTTPException } from 'hono';
|
||||||
import { type AppContext, type AppMiddleware } from '@/app.ts';
|
import { type AppContext, type AppMiddleware } from '@/app.ts';
|
||||||
import { HTTPException } from '@/deps.ts';
|
|
||||||
import {
|
import {
|
||||||
buildAuthEventTemplate,
|
buildAuthEventTemplate,
|
||||||
parseAuthRequest,
|
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';
|
import ExpiringCache from '@/utils/expiring-cache.ts';
|
||||||
|
|
||||||
const debug = Debug('ditto:middleware:cache');
|
const debug = Debug('ditto:middleware:cache');
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { NostrEvent, NostrSigner, NSecSigner } from '@nostrify/nostrify';
|
import { NostrEvent, NostrSigner, NSecSigner } from '@nostrify/nostrify';
|
||||||
|
import { HTTPException } from 'hono';
|
||||||
import { type AppContext } from '@/app.ts';
|
import { type AppContext } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { HTTPException, Stickynotes } from '@/deps.ts';
|
import { Stickynotes } from '@/deps.ts';
|
||||||
import { connectResponseSchema } from '@/schemas/nostr.ts';
|
import { connectResponseSchema } from '@/schemas/nostr.ts';
|
||||||
import { jsonSchema } from '@/schema.ts';
|
import { jsonSchema } from '@/schema.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
|
import { type Context, HTTPException } from 'hono';
|
||||||
import { type AppContext } from '@/app.ts';
|
import { type AppContext } from '@/app.ts';
|
||||||
import { Conf } from '@/config.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 * as pipeline from '@/pipeline.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
import { APISigner } from '@/signers/APISigner.ts';
|
import { APISigner } from '@/signers/APISigner.ts';
|
||||||
|
|
Loading…
Reference in New Issue