mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: rename to routers
This commit is contained in:
1 parent
a0ba60a3fb
commit
f8f95af215
5 files changed
+20
-15
No files matched your search
+7
-7
@@ -1,12 +1,12 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import normalizeResponderReturnable from './core/express/normalizeResponderReturnable.js';
|
||||
import normalizeRouterReturnable from './core/express/normalizeRouterReturnable.js';
|
||||
import isDev from './core/node/isDev.js';
|
||||
import { Registry } from './events/interactionCreate/index.js';
|
||||
import stats from './responders/stats.js';
|
||||
import stats from './routers/stats.js';
|
||||
|
||||
export type ResponderReturnable = JSX.Element | Promise<JSX.Element>;
|
||||
export type RouterReturnable = JSX.Element | Promise<JSX.Element>;
|
||||
|
||||
export interface ResponderRegistry<HandlesInteraction extends boolean = false>
|
||||
export interface RouterRegistry<HandlesInteraction extends boolean = false>
|
||||
extends Registry {
|
||||
route: string;
|
||||
handlesInteraction?: HandlesInteraction;
|
||||
@@ -14,12 +14,12 @@ export interface ResponderRegistry<HandlesInteraction extends boolean = false>
|
||||
handler: (
|
||||
req: Request,
|
||||
res: Response,
|
||||
) => HandlesInteraction extends true ? void : ResponderReturnable;
|
||||
) => HandlesInteraction extends true ? void : RouterReturnable;
|
||||
}
|
||||
|
||||
const app = express();
|
||||
|
||||
([stats] as ResponderRegistry[]).forEach((registry) => {
|
||||
([stats] as RouterRegistry[]).forEach((registry) => {
|
||||
if (!(isDev() ? registry.inDevelopment : registry.inProduction)) return;
|
||||
|
||||
app.get(registry.route, async (req, res) => {
|
||||
@@ -27,7 +27,7 @@ const app = express();
|
||||
|
||||
if (registry.handlesInteraction) return;
|
||||
|
||||
const response = await normalizeResponderReturnable(returnable);
|
||||
const response = await normalizeRouterReturnable(returnable);
|
||||
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'image/svg+xml',
|
||||
|
||||
Reference in new issue
Block a user