UNPKG

1.96 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Request, Response, NextFunction } from 'express';
3export interface AnyErrorDuck extends Error {
4 code?: string;
5 status?: number;
6 [key: string]: any;
7}
8export type ServeFunction = (req: Request, res: Response) => void;
9export type MiddlewareFunction = (req: Request, res: Response, next: NextFunction) => void;
10export type TransformPromiseFromFileName = ((fileName: string) => Promise<any>);
11export declare let globalOpts: {
12 serveErr: {
13 propertiesWhiteList: string[];
14 sendStack: boolean;
15 };
16 logServe: boolean;
17 readConfig: {
18 exts: {
19 [key: string]: TransformPromiseFromFileName;
20 };
21 };
22};
23export declare function serveErr(_req: Request, res: Response, next: NextFunction): (err: AnyErrorDuck) => Promise<void>;
24export type IdentsMap = {
25 [key: string]: boolean;
26};
27export declare function preEval(expresion: string, vars: IdentsMap, functions: IdentsMap): boolean;
28export declare function serveBuffer(buf: Buffer, headers: [type: string, value: string][]): ServeFunction;
29export declare function serveImage(imageBuffer: Buffer, headers: [type: string, value: string][]): ServeFunction;
30export declare function serveText(htmlText: string, contentTypeText: string): ServeFunction;
31export declare function serveFile(fileName: string, options: object): ServeFunction;
32export declare function escapeRegExp(string: string): string;
33export declare function getTraceroute(): string;
34export declare function serveStylus(pathToFile: string, anyFile: boolean): MiddlewareFunction;
35export declare function serveJade(pathToFile: string, anyFileOrOptions: boolean): MiddlewareFunction;
36export declare function serveJson(object: any): MiddlewareFunction;
37export declare function serveYaml(object: any): MiddlewareFunction;
38export declare function readConfig<T>(listOfFileNamesOrConfigObjects: (string | T)[], opts?: {
39 whenNotExist?: 'ignore';
40}): Promise<T>;