409 Conflict
Your request conflicts with the current server state. E.g., trying to register a username that is already taken.
When and Why to Use It
Section titled “When and Why to Use It”Use this for business logic conflicts. The most common example is trying to register a new account with an email address that is already in use.
Usage Examples
Section titled “Usage Examples”import { HttpException, post } from 'shokupan';
export const registerUser = post('/register', async (req) => { const existing = await db.users.findByEmail(req.body.email);
if (existing) { throw new HttpException('Email already registered', 409); }
// ... create user});import { Controller, Post, Body, HttpException } from 'shokupan';
@Controller('/api')export class AuthController { @Post('/register') async registerUser(@Body() body: any) { const existing = await db.users.findByEmail(body.email);
if (existing) { throw new HttpException('Email already registered', 409); }
// ... create user }}import express from 'express';const app = express();
app.post('/register', async (req, res) => { const existing = await db.users.findByEmail(req.body.email);
if (existing) { return res.status(409).json({ error: 'Email already registered' }); }
// ... create user});import { Controller, Post, Body, ConflictException } from '@nestjs/common';
@Controller('auth')export class AuthController { @Post('register') async registerUser(@Body() body: any) { const existing = await db.users.findByEmail(body.email);
if (existing) { throw new ConflictException('Email already registered'); }
// ... create user }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/register' && ctx.method === 'POST') { const existing = await db.users.findByEmail(ctx.request.body.email);
if (existing) { ctx.status = 409; ctx.body = { error: 'Email already registered' }; return; }
// ... create user }});