mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +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
@@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatTypeSubCommandGroups(
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import { RouterReturnable } from '../../server.js';
|
||||
import { RouteReturnable } from '../../server.js';
|
||||
import jsxToSvg from '../node/jsxToSvg.js';
|
||||
|
||||
export default async function normalizeRouterReturnable(
|
||||
returnable: RouterReturnable,
|
||||
export default async function normalizeRouteReturnable(
|
||||
returnable: RouteReturnable,
|
||||
) {
|
||||
const awaitedReturnable = await returnable;
|
||||
const svg = await jsxToSvg(awaitedReturnable);
|
||||
@@ -1,7 +1,7 @@
|
||||
import resolvePeriodFromRequest from '../core/express/resolvePeriodFromRequest.js';
|
||||
import resolvePlayerFromRequest from '../core/express/resolvePlayerFromRequest.js';
|
||||
import stats, { StatType } from '../renderers/stats.js';
|
||||
import { RouterRegistry } from '../server.js';
|
||||
import { RouteRegistry } from '../server.js';
|
||||
|
||||
export default {
|
||||
route: '/stats/:type/:period',
|
||||
@@ -21,4 +21,4 @@ export default {
|
||||
true,
|
||||
);
|
||||
},
|
||||
} satisfies RouterRegistry;
|
||||
} satisfies RouteRegistry;
|
||||
+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