Skip to content

Commit

Permalink
Expressing Method via IRouter (#1735)
Browse files Browse the repository at this point in the history
This serves two purposes:

- Enforcing constraints on its actual usage in `walkRouting()`,
- Should ease adoption of the new `QUERY` method in the future, see:
  - expressjs/express#5615
  - nodejs/node#51562
  • Loading branch information
RobinTail committed May 6, 2024
1 parent 572ba79 commit abc5ba9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/method.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
export type Method = "get" | "post" | "put" | "delete" | "patch";
export const methods: Method[] = ["get", "post", "put", "delete", "patch"];
export type AuxMethod = "options";
import type { IRouter } from "express";

export const methods = [
"get",
"post",
"put",
"delete",
"patch",
] satisfies Array<keyof IRouter>;

export type Method = (typeof methods)[number];

export type AuxMethod = Extract<keyof IRouter, "options">;

0 comments on commit abc5ba9

Please sign in to comment.