Skip to content

400 Bad Request

The server couldn’t understand your request because the syntax is bad, the data is malformed, or it’s missing required fields.

Use this when the client sends you garbage. E.g., they sent invalid JSON, they missed a required field, or their search query was formatted illegally. Do not use this for server crashes.

import { HttpException, post } from 'shokupan';
export const createUser = post('/users', (req) => {
// Basic input validation
if (!req.body || !req.body.email) {
throw new HttpException('Missing required field: email', 400);
}
// ... create user
});