UNPKG

edge-master

Version:
49 lines (48 loc) 1.37 kB
/** * Response helper utilities to reduce boilerplate */ /// <reference types="@cloudflare/workers-types" /> /** * Creates a JSON response */ export declare function json(data: any, init?: ResponseInit): Response; /** * Creates a text response */ export declare function text(content: string, init?: ResponseInit): Response; /** * Creates an HTML response */ export declare function html(content: string, init?: ResponseInit): Response; /** * Creates a redirect response */ export declare function redirect(url: string, status?: number): Response; /** * Creates a 404 Not Found response */ export declare function notFound(message?: string): Response; /** * Creates a 400 Bad Request response */ export declare function badRequest(message?: string): Response; /** * Creates a 401 Unauthorized response */ export declare function unauthorized(message?: string): Response; /** * Creates a 403 Forbidden response */ export declare function forbidden(message?: string): Response; /** * Creates a 500 Internal Server Error response */ export declare function serverError(message?: string): Response; /** * Creates a 204 No Content response */ export declare function noContent(): Response; /** * Creates a response with custom status and JSON body */ export declare function jsonWithStatus(data: any, status: number, init?: ResponseInit): Response;