From f39c37e18d7d9867c154042e5ea3bab0492cb1b1 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Mon, 6 May 2024 21:25:59 +0200 Subject: [PATCH] Expressing `Method` via `IRouter` (#1735) This serves two purposes: - Enforcing constraints on its actual usage in `walkRouting()`, - Should ease adoption of the new `QUERY` method in the future, see: - https://github.com/expressjs/express/issues/5615 - https://github.com/nodejs/node/issues/51562 --- src/method.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/method.ts b/src/method.ts index 8d0edfe80..83ff789d9 100644 --- a/src/method.ts +++ b/src/method.ts @@ -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; + +export type Method = (typeof methods)[number]; + +export type AuxMethod = Extract;