@sigiljs/sigil
Version:
TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating
24 lines (23 loc) • 789 B
TypeScript
import { default as SigilResponse } from './sigil-response';
/**
* Response class representing HTTP redirects (3xx status codes).
* Extends SigilResponse by enforcing a Location header and redirect status code.
*/
export default class Redirect extends SigilResponse {
/**
* HTTP status code for the redirect (300-399).
*/
code: number;
/**
* Target URL for the redirect.
*/
readonly to: string;
/**
* Creates a new Redirect response.
*
* @param to - The URL to redirect to, set as the Location header.
* @param code - Optional redirect status code (must be between 300 and 399). Defaults to 302.
* @throws Error if the provided code is not a valid 3xx redirect code.
*/
constructor(to: string, code?: number);
}