import JSONResponseFactory from './JSONResponseFactory.ts' import {make} from '../../../../di/src/global.ts' import HTMLResponseFactory from './HTMLResponseFactory.ts' import ErrorResponseFactory from './ErrorResponseFactory.ts' import {Rehydratable} from '../../support/Rehydratable.ts' import DehydratedStateResponseFactory from './DehydratedStateResponseFactory.ts' import TemporaryRedirectResponseFactory from './TemporaryRedirectResponseFactory.ts' import {HTTPStatus} from '../../const/http.ts' import HTTPErrorResponseFactory from './HTTPErrorResponseFactory.ts' import HTTPError from '../../error/HTTPError.ts' export function json(value: any): JSONResponseFactory { return make(JSONResponseFactory, value) } export function html(value: string): HTMLResponseFactory { return make(HTMLResponseFactory, value) } export function error(error: Error | string, status: number = 500): ErrorResponseFactory { if ( typeof error === 'string' ) error = new Error(error) return make(ErrorResponseFactory, error, status) } export function dehydrate(value: Rehydratable): DehydratedStateResponseFactory { return make(DehydratedStateResponseFactory, value) } export function redirect(destination: string): TemporaryRedirectResponseFactory { return make(TemporaryRedirectResponseFactory, destination) } export function http(status: HTTPStatus, message?: string): HTTPErrorResponseFactory { return make(HTTPErrorResponseFactory, new HTTPError(status, message)) }