GitNexus/gitnexus/test/fixtures/data-route-table-app/routes.js
azizur100389 7f0ab16ffe
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Gitleaks / gitleaks (push) Waiting to run
Publish / RC guard (marker + release-PR skip) (push) Blocked by required conditions
Publish / Classify release event (push) Waiting to run
Publish / ci (push) Blocked by required conditions
Publish / Publish to npm (push) Blocked by required conditions
Publish / Build & Push RC Docker images (push) Blocked by required conditions
Scorecard / Scorecard analysis (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-cli) (push) Waiting to run
Trivy Image Scan / Trivy (gitnexus-web) (push) Waiting to run
feat(routes): support JS data route tables (#2972)
2026-08-18 04:39:45 +01:00

23 lines
876 B
JavaScript

import { auth, createUser, listUsers as handleUsers } from './handlers.js';
const runtimePath = '/dynamic';
const baseRoute = { path: '/spread', method: 'GET', handler: spreadHandler };
const apiRoutes = [
{ path: '/users', method: 'GET', handler: handleUsers },
{ path: '/users', method: 'POST', handler: createUser },
{ path: '/auth/me', method: 'GET', handler: auth.getCurrentUser, auth: true },
{ path: runtimePath, method: 'GET', handler: dynamicHandler },
{ ...baseRoute },
{ ['path']: '/computed', method: 'GET', handler: computedHandler },
{ path: '/inline', method: 'GET', handler: () => null },
{ path: '/unresolved', method: 'GET', handler: missing.handler },
];
for (const route of apiRoutes) {
if (route.path === request.path && route.method === request.method) route.handler();
}
export function routeCount() {
return apiRoutes.length;
}