File size: 738 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
/**
* List of valid HTTP methods that can be implemented by Next.js's Custom App
* Routes.
*/
export const HTTP_METHODS = [
'GET',
'HEAD',
'OPTIONS',
'POST',
'PUT',
'DELETE',
'PATCH',
] as const
/**
* A type representing the valid HTTP methods that can be implemented by
* Next.js's Custom App Routes.
*/
export type HTTP_METHOD = (typeof HTTP_METHODS)[number]
/**
* Checks to see if the passed string is an HTTP method. Note that this is case
* sensitive.
*
* @param maybeMethod the string that may be an HTTP method
* @returns true if the string is an HTTP method
*/
export function isHTTPMethod(maybeMethod: string): maybeMethod is HTTP_METHOD {
return HTTP_METHODS.includes(maybeMethod as HTTP_METHOD)
}
|