battlelog/middleware/bodyExists.ts

10 lines
256 B
TypeScript

import { Middleware } from "oak"
export const bodyExists: Middleware = async (ctx, next) => {
if (ctx.request.hasBody) await next();
else {
ctx.response.status = 400;
ctx.response.body = 'Body not provided to endpoint that requires it';
}
}