amati/src/core/utils/applicationJsonOnly.ts
2024-02-28 21:21:55 +07:00

12 lines
351 B
TypeScript

import BaseError from "../error/BaseError";
export default function applicationJsonOnly(headers: Headers) {
if (headers.get("Content-Type") !== "application/json")
throw new BaseError({
errorCode: "UNSUPPORTED_CONTENT_TYPE",
message:
"This content type is not supported. Please use application/json instead",
statusCode: 400,
});
}