Clean up how route handlers are called
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user