tspace-spear
Version:
tspace-spear is a lightweight, high-performance API framework for Node.js that leverages the native HTTP server and supports uWebSockets.js (C++) for maximum speed and efficiency.
27 lines (26 loc) • 808 B
TypeScript
import { type T } from '../types';
/**
* Sets the HTTP response status code before executing the controller method.
*
* The provided status code will be automatically clamped between **100** and **599**
* to ensure a valid HTTP status range. It also sets the default
* `Content-Type` header to `application/json`.
*
* @example
* ```ts
* class UserController {
* \@StatusCode(201)
* async create(ctx: T.Context) {
* return { success: true };
* }
* }
* ```
*
* In this example the response will be sent with:
* - Status: **201 Created**
* - Header: `Content-Type: application/json`
*
* @param {T.StatusCode} statusCode - HTTP status code to send with the response.
* @returns {MethodDecorator}
*/
export declare const StatusCode: (statusCode: T.StatusCode) => MethodDecorator;