413 Content Too Large
You tried to upload a baby hippo and the server only accepts hamsters. The payload is too big.
When and Why to Use It
Section titled “When and Why to Use It”Use this to reject massive uploads. If you set a 5MB limit for profile pictures, and they upload a 10GB file, throw a 413 to protect your server’s disk space.
Usage Examples
Section titled “Usage Examples”import { HttpException, get } from 'shokupan';
export const getResource = get('/resource', () => { throw new HttpException('Content Too Large', 413);});import { Controller, Get, HttpException } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') getResource() { throw new HttpException('Content Too Large', 413); }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(413).json({ error: 'Content Too Large' });});import { Controller, Get, HttpException } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') getResource() { throw new HttpException('Content Too Large', 413); }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 413; ctx.body = { error: 'Content Too Large' }; }});