Add typecheck
This commit is contained in:
parent
419ebf3d51
commit
6d8999dbf5
|
|
@ -1,5 +1,6 @@
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import BaseError from "../error/BaseError";
|
import BaseError from "../error/BaseError";
|
||||||
|
import ContentType from "@/types/ContentType";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the current request's content type is one of the allowed types.
|
* Ensures that the current request's content type is one of the allowed types.
|
||||||
|
|
@ -9,7 +10,7 @@ import BaseError from "../error/BaseError";
|
||||||
* @throws {BaseError} Throws a BaseError if the current request's content type is not in the allowed content types.
|
* @throws {BaseError} Throws a BaseError if the current request's content type is not in the allowed content types.
|
||||||
*/
|
*/
|
||||||
export default function onlyAllowFollowingContentType(
|
export default function onlyAllowFollowingContentType(
|
||||||
contentTypes: string | string[]
|
contentTypes: ContentType & (string | {}) | ContentType[] | (string | {})[]
|
||||||
) {
|
) {
|
||||||
// Retrieve the current request's content type.
|
// Retrieve the current request's content type.
|
||||||
const currentContentType = headers().get("Content-Type");
|
const currentContentType = headers().get("Content-Type");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user