200 OK
The classic success code. Everything went perfectly. For GET requests, you get your data. For POST/PUT, the action succeeded.
When and Why to Use It
Section titled “When and Why to Use It”This is your bread and butter. Use it whenever a standard request works perfectly. For a GET, return the data. For a POST/PUT, return the updated object.
Usage Examples
Section titled “Usage Examples”import { HttpCode, get } from 'shokupan';
export const getResource = get('/resource', () => { return { message: 'OK' };}).pipe(HttpCode(200));import { Controller, Get, HttpCode } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') @HttpCode(200) getResource() { return { message: 'OK' }; }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(200).json({ message: 'OK' });});import { Controller, Get, HttpCode } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') @HttpCode(200) getResource() { return { message: 'OK' }; }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 200; ctx.body = { message: 'OK' }; }});