@riddance/service
Version:
Too much code slows you down, creates risks, increases maintainability burdens, confuses AI. So let's commit less of it.
30 lines (29 loc) • 990 B
TypeScript
import { Context, Json } from './context.js';
export * from '@riddance/host/lib/http';
export * from './context.js';
export declare function withStatus<Status extends number>(error: Error, status: Status): Error & {
statusCode: Status;
};
export declare function withPublicMessage<TError extends Error>(error: TError, message?: string): TError;
export declare function badRequest(publicMessage?: string): Error & {
statusCode: 400;
};
/** Please authenticate yourself, e.g. log in or refresh your tokens. */
export declare function unauthorized(): Error & {
statusCode: 401;
};
/** I known who you are; you're not getting in. */
export declare function forbidden(): Error & {
statusCode: 403;
};
export declare function notFound(): Error & {
statusCode: 404;
};
export declare function notImplemented(): Error & {
statusCode: 501;
};
export declare function getBearer(context: Context, req: {
headers: {
authorization?: string;
};
}): Promise<Json>;