* perf: use only one WASM alloc for xxhash * perf(deps): lazy load mercury-parser and use googleapis/youtube instead of heavy googleapis * perf(dx): lazy load dev registry speed up npm dev script * perf: close playwright browser on destroy * fix: show exception msg in prod * revert: "perf: use only one WASM alloc for xxhash" This reverts commit 01ecdd48d09a046dce05f440814dcbec0323a7de. * perf: use only one WASM alloc for xxhash * test: add claim for worker * fix: missing piece from 8dd9c9a * feat: add namespace to the chunkfilename * fix: keep var naming
38 lines
889 B
TypeScript
38 lines
889 B
TypeScript
import type { RouteHandler } from '@hono/zod-openapi';
|
|
import { createRoute, z } from '@hono/zod-openapi';
|
|
|
|
import { getRadarRules } from './utils';
|
|
|
|
const ParamsSchema = z.object({
|
|
domain: z.string().openapi({
|
|
param: {
|
|
name: 'domain',
|
|
in: 'path',
|
|
},
|
|
example: 'github.com',
|
|
}),
|
|
});
|
|
|
|
const route = createRoute({
|
|
method: 'get',
|
|
path: '/radar/rules/{domain}',
|
|
description: 'Radar rules for a domain name',
|
|
tags: ['Radar'],
|
|
request: {
|
|
params: ParamsSchema,
|
|
},
|
|
responses: {
|
|
200: {
|
|
description: 'Radar rules for a domain name (no subdomains)',
|
|
},
|
|
},
|
|
});
|
|
|
|
const handler: RouteHandler<typeof route> = async (ctx) => {
|
|
const { domain } = ctx.req.valid('param');
|
|
const rules = await getRadarRules();
|
|
return ctx.json(rules[domain]);
|
|
};
|
|
|
|
export { handler, route };
|