DefinitelyTyped/types/host-validation/index.d.ts
Rich Liu 7b3d73edb1 Added type definitions for Host Validation. (#29533)
* Created host-validation typings.

* Fixed tsconfig.json.

* Added strictFunctionTypes to true in tsconfig.json.

* Changed T[] to Array<T> because it is non-simple type.

* Added optional parameters.

* Added more tests.

* trailing whitespace fix

* Fixed Spelling.

* Change hosts parameter to opts.

* Changed import in test, and added namespace.
2018-10-15 10:04:57 -07:00

22 lines
720 B
TypeScript

// Type definitions for host-validation 2.0
// Project: https://github.com/brannondorsey/host-validation
// Definitions by: Rich Liu <https://github.com/dintopple>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { Request, Response, NextFunction } from 'express';
declare namespace hostValidation {
interface config {
hosts?: Array<string|RegExp>;
referers?: Array<string|RegExp>;
mode?: 'both' | 'either';
fail?(req: Request, res: Response, next: NextFunction): void;
}
}
declare function hostValidation(opts: hostValidation.config):
(req: Request, res: Response, next: NextFunction) => void;
export = hostValidation;