Skip to content

404 Not Found

The classic dead link. The server cannot find the requested resource.

Use this when the requested URL simply doesn’t exist, or if a user requests a specific ID that isn’t in your database (e.g. GET /users/99999).

import { HttpException, get } from 'shokupan';
export const getUser = get('/users/:id', async (req) => {
const user = await db.users.findById(req.params.id);
if (!user) {
throw new HttpException('User not found in database', 404);
}
return user;
});