Clean up how route handlers are called

This commit is contained in:
Michael Wolf
2025-03-07 21:22:31 -06:00
parent 6ed81e871f
commit ecdbedc135
4 changed files with 64 additions and 27 deletions

View File

@@ -30,18 +30,18 @@ const okText = (out: string) => {
const routes: Route[] = [
{
path: "/slow",
methods: ["get"],
handler: async (_req) => {
methods: ["GET"],
handler: async (_req: Request) => {
console.log("starting slow request");
await sleep(10);
await sleep(2);
console.log("finishing slow request");
return okText("that was slow");
},
},
{
path: "/list",
methods: ["get"],
handler: async (_req) => {
methods: ["GET"],
handler: (_req: Request) => {
const code = httpCodes.success.OK;
const lr = (rr: Route[]) => {
const ret = rr.map((r: Route) => {
@@ -61,8 +61,8 @@ const routes: Route[] = [
},
{
path: "/ok",
methods: ["get"],
handler: async (_req) => {
methods: ["GET"],
handler: (_req: Request) => {
const code = httpCodes.success.OK;
const rn = services.random.randomNumber();
@@ -75,8 +75,8 @@ const routes: Route[] = [
},
{
path: "/alsook",
methods: ["get"],
handler: async (_req) => {
methods: ["GET"],
handler: (_req) => {
const code = httpCodes.success.OK;
return {
code,