mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: renamed routers to routes
This commit is contained in:
1 parent
e81c0cbc1e
commit
3fd90588a3
4 files changed
+13
-13
No files matched your search
+7
-7
@@ -1,12 +1,12 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import normalizeRouterReturnable from './core/express/normalizeRouterReturnable.js';
|
||||
import normalizeRouteReturnable from './core/express/normalizeRouteReturnable.js';
|
||||
import isDev from './core/node/isDev.js';
|
||||
import { Registry } from './events/interactionCreate/index.js';
|
||||
import stats from './routers/stats.js';
|
||||
import stats from './routes/stats.js';
|
||||
|
||||
export type RouterReturnable = JSX.Element | Promise<JSX.Element>;
|
||||
export type RouteReturnable = JSX.Element | Promise<JSX.Element>;
|
||||
|
||||
export interface RouterRegistry<HandlesInteraction extends boolean = false>
|
||||
export interface RouteRegistry<HandlesInteraction extends boolean = false>
|
||||
extends Registry {
|
||||
route: string;
|
||||
handlesInteraction?: HandlesInteraction;
|
||||
@@ -14,12 +14,12 @@ export interface RouterRegistry<HandlesInteraction extends boolean = false>
|
||||
handler: (
|
||||
req: Request,
|
||||
res: Response,
|
||||
) => HandlesInteraction extends true ? void : RouterReturnable;
|
||||
) => HandlesInteraction extends true ? void : RouteReturnable;
|
||||
}
|
||||
|
||||
const app = express();
|
||||
|
||||
([stats] as RouterRegistry[]).forEach((registry) => {
|
||||
([stats] as RouteRegistry[]).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 normalizeRouterReturnable(returnable);
|
||||
const response = await normalizeRouteReturnable(returnable);
|
||||
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'image/svg+xml',
|
||||
|
||||
Reference in new issue
Block a user