diff --git a/types/restify/index.d.ts b/types/restify/index.d.ts index 446f434bcf..5e5bc1e0e5 100644 --- a/types/restify/index.d.ts +++ b/types/restify/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for restify 7.2 +// Type definitions for restify 8.4 // Project: https://github.com/restify/node-restify, http://restify.com // Definitions by: Bret Little // Steve Hipwell // Leandro Almeida // Mitchell Bundy +// Alexandre Moraes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -1042,527 +1043,557 @@ export interface Formatters { export const formatters: Formatters; export namespace plugins { - namespace pre { - /** - * Provide req.set(key, val) and req.get(key) methods for setting and retrieving context to a specific request. - */ - function context(): RequestHandler; - - function dedupeSlashes(): RequestHandler; - - /** - * This pre handler fixes issues with node hanging when an asyncHandler is used prior to bodyParser. - */ - function pause(): RequestHandler; - - /** - * Cleans up duplicate or trailing / on the URL - */ - function sanitizePath(): RequestHandler; - - /** - * Automatically reuse incoming request header as the request id. - */ - function reqIdHeaders(options: { headers: string[] }): RequestHandler; - - /** - * Checks req.urls query params with strict key/val format and rejects non-strict requests with status code 400. - */ - function strictQueryParams(options?: { message: string }): RequestHandler; - - /** - * Regexp to capture curl user-agents - */ - function userAgentConnection(options?: { userAgentRegExp: any }): RequestHandler; - } - - // *************** This module includes the following header parser plugins: - + namespace pre { /** - * Check the client's Accept header can be handled by this server. + * Provide req.set(key, val) and req.get(key) methods for setting and retrieving context to a specific request. */ - function acceptParser(accepts: string[]): RequestHandler; + function context(): RequestHandler; - type AuditLoggerContext = (req: Request, res: Response, route: any, error: any) => any; - - interface AuditLoggerOptions { - /** - * Bunyan logger - */ - log: Logger; - - /** - * The event from the server which initiates the - * log, one of 'pre', 'routed', or 'after' - */ - event: 'pre' | 'routed' | 'after'; - - /** - * Restify server. If passed in, causes server to emit 'auditlog' event after audit logs are flushed - */ - server?: Server; - - /** - * The optional context function of signature - * f(req, res, route, err). Invoked each time an audit log is generated. This - * function can return an object that customizes the format of anything off the - * req, res, route, and err objects. The output of this function will be - * available on the `context` key in the audit object. - */ - context?: AuditLoggerContext; - - /** - * Ringbuffer which is written to if passed in - */ - logBuffer?: any; - - /** - * When true, prints audit logs. default true. - */ - printLog?: boolean; - - body?: boolean; - } + function dedupeSlashes(): RequestHandler; /** - * An audit logger for recording all handled requests + * This pre handler fixes issues with node hanging when an asyncHandler is used prior to bodyParser. */ - function auditLogger(options: AuditLoggerOptions): (...args: any[]) => void; + function pause(): RequestHandler; /** - * Authorization header + * Cleans up duplicate or trailing / on the URL */ - function authorizationParser(options?: any): RequestHandler; - - interface HandlerCandidate { - handler: RequestHandler | RequestHandler[]; - version?: string | string[]; - contentType?: string | string[]; - } + function sanitizePath(): RequestHandler; /** - * Runs first handler that matches to the condition + * Automatically reuse incoming request header as the request id. */ - function conditionalHandler(candidates: HandlerCandidate | HandlerCandidate[]): RequestHandler; + function reqIdHeaders(options: { headers: string[] }): RequestHandler; /** - * Conditional headers (If-*) + * Checks req.urls query params with strict key/val format and rejects non-strict requests with status code 400. */ - function conditionalRequest(): RequestHandler[]; - - interface CpuUsageThrottleOptions { - limit?: number; - max?: number; - interval?: number; - halfLife?: number; - } + function strictQueryParams(options?: { message: string }): RequestHandler; /** - * Cpu Throttle middleware + * Regexp to capture curl user-agents */ - function cpuUsageThrottle(opts?: CpuUsageThrottleOptions): RequestHandler; + function userAgentConnection(options?: { + userAgentRegExp: any; + }): RequestHandler; + } + // *************** This module includes the following header parser plugins: + + /** + * Check the client's Accept header can be handled by this server. + */ + function acceptParser(accepts: string[]): RequestHandler; + + type AuditLoggerContext = ( + req: Request, + res: Response, + route: any, + error: any, + ) => any; + + interface AuditLoggerOptions { /** - * Handles disappeared CORS headers + * Bunyan logger */ - function fullResponse(): RequestHandler; - - // ************ This module includes the following data parsing plugins: - - interface BodyParserOptions { - /** - * The maximum size in bytes allowed in the HTTP body. Useful for limiting clients from hogging server memory. - */ - maxBodySize?: number; - - /** - * If req.params should be filled with parsed parameters from HTTP body. - */ - mapParams?: boolean; - - /** - * If req.params should be filled with the contents of files sent through a multipart request. - * Formidable is used internally for parsing, and a file is denoted as a multipart part with the filename option set in its Content-Disposition. - * This will only be performed if mapParams is true. - */ - mapFiles?: boolean; - - /** - * If an entry in req.params should be overwritten by the value in the body if the names are the same. - * For instance, if you have the route /:someval, and someone posts an x-www-form-urlencoded Content-Type with the body someval=happy to /sad, - * the value will be happy if overrideParams is true, sad otherwise. - */ - overrideParams?: boolean; - - /** - * A callback to handle any multipart part which is not a file. - * If this is omitted, the default handler is invoked which may or may not map the parts into req.params, depending on the mapParams-option. - */ - multipartHandler?(): void; - - /** - * A callback to handle any multipart file. - * It will be a file if the part have a Content-Disposition with the filename parameter set. - * This typically happens when a browser sends a form and there is a parameter similar to . - * If this is not provided, the default behaviour is to map the contents into req.params. - */ - multipartFileHandler?(): void; - - /** - * If you want the uploaded files to include the extensions of the original files (multipart uploads only). Does nothing if multipartFileHandler is defined. - */ - keepExtensions?: boolean; - - /** - * Where uploaded files are intermediately stored during transfer before the contents is mapped into req.params. Does nothing if multipartFileHandler is defined. - */ - uploadDir?: string; - - /** - * If you want to support html5 multiple attribute in upload fields. - */ - multiples?: boolean; - - /** - * If you want checksums calculated for incoming files, set this to either sha1 or md5. - */ - hash?: string; - - /** - * Set to true if you want to end the request with a UnsupportedMediaTypeError when none of the supported content types was given. - */ - rejectUnknown?: boolean; - - requestBodyOnGet?: boolean; - - reviver?: any; - - maxFieldsSize?: number; - - maxFileSize?: number; - } + log: Logger; /** - * Parses POST bodies to req.body. automatically uses one of the following parsers based on content type. + * The event from the server which initiates the + * log, one of 'pre', 'routed', or 'after' */ - function bodyParser(options?: BodyParserOptions): RequestHandler[]; + event: 'pre' | 'routed' | 'after'; /** - * Reads the body of the request. + * Restify server. If passed in, causes server to emit 'auditlog' event after audit logs are flushed */ - function bodyReader(options?: { maxBodySize?: number }): RequestHandler; - - interface UrlEncodedBodyParserOptions { - mapParams?: boolean; - overrideParams?: boolean; - bodyReader?: boolean; - } + server?: Server; /** - * Parse the HTTP request body IFF the contentType is application/x-www-form-urlencoded. + * The optional context function of signature + * f(req, res, route, err). Invoked each time an audit log is generated. This + * function can return an object that customizes the format of anything off the + * req, res, route, and err objects. The output of this function will be + * available on the `context` key in the audit object. + */ + context?: AuditLoggerContext; + + /** + * Ringbuffer which is written to if passed in + */ + logBuffer?: any; + + /** + * When true, prints audit logs. default true. + */ + printLog?: boolean; + + body?: boolean; + } + + /** + * An audit logger for recording all handled requests + */ + function auditLogger(options: AuditLoggerOptions): (...args: any[]) => void; + + /** + * Authorization header + */ + function authorizationParser(options?: any): RequestHandler; + + interface HandlerCandidate { + handler: RequestHandler | RequestHandler[]; + version?: string | string[]; + contentType?: string | string[]; + } + + /** + * Runs first handler that matches to the condition + */ + function conditionalHandler( + candidates: HandlerCandidate | HandlerCandidate[], + ): RequestHandler; + + /** + * Conditional headers (If-*) + */ + function conditionalRequest(): RequestHandler[]; + + interface CpuUsageThrottleOptions { + limit?: number; + max?: number; + interval?: number; + halfLife?: number; + } + + /** + * Cpu Throttle middleware + */ + function cpuUsageThrottle(opts?: CpuUsageThrottleOptions): RequestHandler; + + /** + * Handles disappeared CORS headers + */ + function fullResponse(): RequestHandler; + + // ************ This module includes the following data parsing plugins: + + interface BodyParserOptions { + /** + * The maximum size in bytes allowed in the HTTP body. Useful for limiting clients from hogging server memory. + */ + maxBodySize?: number; + + /** + * If req.params should be filled with parsed parameters from HTTP body. + */ + mapParams?: boolean; + + /** + * If req.params should be filled with the contents of files sent through a multipart request. + * Formidable is used internally for parsing, and a file is denoted as a multipart part with the filename option set in its Content-Disposition. + * This will only be performed if mapParams is true. + */ + mapFiles?: boolean; + + /** + * If an entry in req.params should be overwritten by the value in the body if the names are the same. + * For instance, if you have the route /:someval, and someone posts an x-www-form-urlencoded Content-Type with the body someval=happy to /sad, + * the value will be happy if overrideParams is true, sad otherwise. + */ + overrideParams?: boolean; + + /** + * A callback to handle any multipart part which is not a file. + * If this is omitted, the default handler is invoked which may or may not map the parts into req.params, depending on the mapParams-option. + */ + multipartHandler?(): void; + + /** + * A callback to handle any multipart file. + * It will be a file if the part have a Content-Disposition with the filename parameter set. + * This typically happens when a browser sends a form and there is a parameter similar to . + * If this is not provided, the default behaviour is to map the contents into req.params. + */ + multipartFileHandler?(): void; + + /** + * If you want the uploaded files to include the extensions of the original files (multipart uploads only). Does nothing if multipartFileHandler is defined. + */ + keepExtensions?: boolean; + + /** + * Where uploaded files are intermediately stored during transfer before the contents is mapped into req.params. Does nothing if multipartFileHandler is defined. + */ + uploadDir?: string; + + /** + * If you want to support html5 multiple attribute in upload fields. + */ + multiples?: boolean; + + /** + * If you want checksums calculated for incoming files, set this to either sha1 or md5. + */ + hash?: string; + + /** + * Set to true if you want to end the request with a UnsupportedMediaTypeError when none of the supported content types was given. + */ + rejectUnknown?: boolean; + + requestBodyOnGet?: boolean; + + reviver?: any; + + maxFieldsSize?: number; + + maxFileSize?: number; + } + + /** + * Parses POST bodies to req.body. automatically uses one of the following parsers based on content type. + */ + function bodyParser(options?: BodyParserOptions): RequestHandler[]; + + /** + * Reads the body of the request. + */ + function bodyReader(options?: { maxBodySize?: number }): RequestHandler; + + interface UrlEncodedBodyParserOptions { + mapParams?: boolean; + overrideParams?: boolean; + bodyReader?: boolean; + } + + /** + * Parse the HTTP request body IFF the contentType is application/x-www-form-urlencoded. + * + * If req.params already contains a given key, that key is skipped and an + * error is logged. + */ + function urlEncodedBodyParser( + options?: UrlEncodedBodyParserOptions, + ): RequestHandler[]; + + interface JsonBodyParserOptions { + mapParams?: boolean; + overrideParams?: boolean; + reviver?(key: any, value: any): any; + bodyReader?: boolean; + } + + /** + * Parses JSON POST bodies + */ + function jsonBodyParser(options?: JsonBodyParserOptions): RequestHandler[]; + + /** + * Parses JSONP callback + */ + function jsonp(): RequestHandler; + + interface MultipartBodyParser { + overrideParams?: boolean; + multiples?: boolean; + keepExtensions?: boolean; + uploadDir?: string; + maxFieldsSize?: number; + hash?: string; + multipartFileHandler?: any; + multipartHandler?: any; + mapParams?: boolean; + mapFiles?: boolean; + maxFileSize?: number; + } + + /** + * Parses JSONP callback + */ + function multipartBodyParser(options?: MultipartBodyParser): RequestHandler; + + interface QueryParserOptions { + /** + * Default `false`. Copies parsed query parameters into `req.params`. + */ + mapParams?: boolean; + + /** + * Default `false`. Only applies when if mapParams true. When true, will stomp on req.params field when existing value is found. + */ + overrideParams?: boolean; + + /** + * Default false. Transform `?foo.bar=baz` to a nested object: `{foo: {bar: 'baz'}}`. + */ + allowDots?: boolean; + + /** + * Default 20. Only transform `?a[$index]=b` to an array if `$index` is less than `arrayLimit`. + */ + arrayLimit?: number; + + /** + * Default 5. The depth limit for parsing nested objects, e.g. `?a[b][c][d][e][f][g][h][i]=j`. + */ + depth?: number; + + /** + * Default 1000. Maximum number of query params parsed. Additional params are silently dropped. + */ + parameterLimit?: number; + + /** + * Default true. Whether to parse `?a[]=b&a[1]=c` to an array, e.g. `{a: ['b', 'c']}`. + */ + parseArrays?: boolean; + + /** + * Default false. Whether `req.query` is a "plain" object -- does not inherit from `Object`. + * This can be used to allow query params whose names collide with Object methods, e.g. `?hasOwnProperty=blah`. + */ + plainObjects?: boolean; + + /** + * Default false. If true, `?a&b=` results in `{a: null, b: ''}`. Otherwise, `{a: '', b: ''}`. + */ + strictNullHandling?: boolean; + } + + /** + * Parses URL query parameters into `req.query`. Many options correspond directly to option defined for the underlying [qs.parse](https://github.com/ljharb/qs) + */ + function queryParser(options?: QueryParserOptions): RequestHandler; + + interface RequestLogger { + properties?: any; + serializers?: any; + headers?: any; + log?: any; + } + + /** + * Adds timers for each handler in your request chain + * + * `options.properties` properties to pass to bunyan's `log.child()` method + */ + function requestLogger(options?: RequestLogger): RequestHandler; + + // ******************** The module includes the following response plugins: + + /** + * expires requests based on current time + delta + * @param delta - age in seconds + */ + function dateParser(delta?: number): RequestHandler; + + /** + * gzips the response if client send `accept-encoding: gzip` + * @param options options to pass to gzlib + */ + function gzipResponse(options?: zlib.ZlibOptions): RequestHandler; + + interface InflightRequestThrottleOptions { + limit: number; + server: Server; + err: any; + } + + function inflightRequestThrottle( + opts: InflightRequestThrottleOptions, + ): RequestHandler; + + interface ServeStatic { + appendRequestPath?: boolean; + directory?: string; + maxAge?: number; + match?: any; + charSet?: string; + file?: string; + etag?: string; + default?: any; + gzip?: boolean; + } + + /** + * Used to serve static files + */ + function serveStatic(options?: ServeStatic): RequestHandler; + + interface ServeStaticFiles { + maxAge?: number; + etag?: string; + setHeaders?: (res: Response, path: string, stat: any) => any; + } + + /** + * Used to serve static files from a given directory + */ + function serveStaticFiles( + dir: string, + options?: ServeStaticFiles, + ): RequestHandler; + + interface ThrottleOptions { + burst?: number; + rate?: number; + setHeaders?: boolean; + ip?: boolean; + username?: boolean; + xff?: boolean; + tokensTable?: any; + maxKeys?: number; + overrides?: any; // any + } + + /** + * throttles responses + */ + function throttle(options?: ThrottleOptions): RequestHandler; + + type MetricsCallback = ( + /** + * An error if the request had an error + */ + err: Error, + + /** + * Object that contains the various metrics that are returned + */ + metrics: MetricsCallbackOptions, + + /** + * The request obj + */ + req: Request, + + /** + * The response obj + */ + res: Response, + + /** + * The route obj that serviced the request + */ + route: Route, + ) => void; + + type TMetricsCallback = 'close' | 'aborted' | undefined; + + interface MetricsCallbackOptions { + /** + * Status code of the response. Can be undefined in the case of an `uncaughtException`. + * Otherwise, in most normal scenarios, even calling `res.send()` or `res.end()` should result in a 200 by default. + */ + statusCode: number; + + /** + * HTTP request verb + */ + method: string; + + /** + * latency includes both request is flushed and all handlers finished + */ + totalLatency: number; + + /** + * Request latency + */ + latency: number; + + /** + * pre handlers latency + */ + preLatency: number | null; + + /** + * use handlers latency + */ + useLatency: number | null; + + /** + * req.path() value + */ + path: string; + + /** + * Number of inflight requests pending in restify + */ + inflightRequests: number; + + /** + * Same as `inflightRequests` + */ + unfinishedRequests: number; + + /** + * If this value is set, err will be a corresponding `RequestCloseError` or `RequestAbortedError`. * - * If req.params already contains a given key, that key is skipped and an - * error is logged. + * If connectionState is either 'close' or 'aborted', then the statusCode is not applicable since the connection was severed before a response was written. */ - function urlEncodedBodyParser(options?: UrlEncodedBodyParserOptions): RequestHandler[]; + connectionState: TMetricsCallback; + } - interface JsonBodyParserOptions { - mapParams?: boolean; - overrideParams?: boolean; - reviver?(key: any, value: any): any; - bodyReader?: boolean; - } + /** + * Listens to the server's after event and emits information about that request (5.x compatible only). + * + * ``` + * server.on('after', plugins.metrics({ server }, (err, metrics, req, res, route) => + * { + * // metrics is an object containing information about the request + * })); + * ``` + */ + function metrics( + opts: { server: Server }, + callback: MetricsCallback, + ): (...args: any[]) => void; + + /** + * Parse the client's request for an OAUTH2 access tokensTable + * + * Subsequent handlers will see `req.oauth2`, which looks like: + * ``` + * { + * oauth2: {accessToken: 'mF_9.B5f-4.1JqM&p=q'} + * } + * ``` + */ + function oauth2TokenParser(): RequestHandler; + + interface RequestExpiryOptions { + /** + * Header name of the absolute time for request expiration + */ + absoluteHeader?: string; /** - * Parses JSON POST bodies + * Header name for the start time of the request */ - function jsonBodyParser(options?: JsonBodyParserOptions): RequestHandler[]; + startHeader?: string; /** - * Parses JSONP callback + * The header name for the time in milliseconds that should ellapse before the request is considered expired. */ - function jsonp(): RequestHandler; + timeoutHeader?: string; + } - interface MultipartBodyParser { - overrideParams?: boolean; - multiples?: boolean; - keepExtensions?: boolean; - uploadDir?: string; - maxFieldsSize?: number; - hash?: string; - multipartFileHandler?: any; - multipartHandler?: any; - mapParams?: boolean; - mapFiles?: boolean; - maxFileSize?: number; - } - - /** - * Parses JSONP callback - */ - function multipartBodyParser(options?: MultipartBodyParser): RequestHandler; - - interface QueryParserOptions { - /** - * Default `false`. Copies parsed query parameters into `req.params`. - */ - mapParams?: boolean; - - /** - * Default `false`. Only applies when if mapParams true. When true, will stomp on req.params field when existing value is found. - */ - overrideParams?: boolean; - - /** - * Default false. Transform `?foo.bar=baz` to a nested object: `{foo: {bar: 'baz'}}`. - */ - allowDots?: boolean; - - /** - * Default 20. Only transform `?a[$index]=b` to an array if `$index` is less than `arrayLimit`. - */ - arrayLimit?: number; - - /** - * Default 5. The depth limit for parsing nested objects, e.g. `?a[b][c][d][e][f][g][h][i]=j`. - */ - depth?: number; - - /** - * Default 1000. Maximum number of query params parsed. Additional params are silently dropped. - */ - parameterLimit?: number; - - /** - * Default true. Whether to parse `?a[]=b&a[1]=c` to an array, e.g. `{a: ['b', 'c']}`. - */ - parseArrays?: boolean; - - /** - * Default false. Whether `req.query` is a "plain" object -- does not inherit from `Object`. - * This can be used to allow query params whose names collide with Object methods, e.g. `?hasOwnProperty=blah`. - */ - plainObjects?: boolean; - - /** - * Default false. If true, `?a&b=` results in `{a: null, b: ''}`. Otherwise, `{a: '', b: ''}`. - */ - strictNullHandling?: boolean; - } - - /** - * Parses URL query parameters into `req.query`. Many options correspond directly to option defined for the underlying [qs.parse](https://github.com/ljharb/qs) - */ - function queryParser(options?: QueryParserOptions): RequestHandler; - - interface RequestLogger { - properties?: any; - serializers?: any; - headers?: any; - log?: any; - } - - /** - * Adds timers for each handler in your request chain - * - * `options.properties` properties to pass to bunyan's `log.child()` method - */ - function requestLogger(options?: RequestLogger): RequestHandler; - - // ******************** The module includes the following response plugins: - - /** - * expires requests based on current time + delta - * @param delta - age in seconds - */ - function dateParser(delta?: number): RequestHandler; - - /** - * gzips the response if client send `accept-encoding: gzip` - * @param options options to pass to gzlib - */ - function gzipResponse(options?: zlib.ZlibOptions): RequestHandler; - - interface InflightRequestThrottleOptions { - limit: number; - server: Server; - err: any; - } - - function inflightRequestThrottle(opts: InflightRequestThrottleOptions): RequestHandler; - - interface ServeStatic { - appendRequestPath?: boolean; - directory?: string; - maxAge?: number; - match?: any; - charSet?: string; - file?: string; - etag?: string; - default?: any; - gzip?: boolean; - } - - /** - * Used to serve static files - */ - function serveStatic(options?: ServeStatic): RequestHandler; - - interface ThrottleOptions { - burst?: number; - rate?: number; - setHeaders?: boolean; - ip?: boolean; - username?: boolean; - xff?: boolean; - tokensTable?: any; - maxKeys?: number; - overrides?: any; // any - } - - /** - * throttles responses - */ - function throttle(options?: ThrottleOptions): RequestHandler; - - type MetricsCallback = ( - /** - * An error if the request had an error - */ - err: Error, - - /** - * Object that contains the various metrics that are returned - */ - metrics: MetricsCallbackOptions, - - /** - * The request obj - */ - req: Request, - - /** - * The response obj - */ - res: Response, - - /** - * The route obj that serviced the request - */ - route: Route, - ) => void; - - type TMetricsCallback = 'close' | 'aborted' | undefined; - - interface MetricsCallbackOptions { - /** - * Status code of the response. Can be undefined in the case of an `uncaughtException`. - * Otherwise, in most normal scenarios, even calling `res.send()` or `res.end()` should result in a 200 by default. - */ - statusCode: number; - - /** - * HTTP request verb - */ - method: string; - - /** - * latency includes both request is flushed and all handlers finished - */ - totalLatency: number; - - /** - * Request latency - */ - latency: number; - - /** - * pre handlers latency - */ - preLatency: number | null; - - /** - * use handlers latency - */ - useLatency: number | null; - - /** - * req.path() value - */ - path: string; - - /** - * Number of inflight requests pending in restify - */ - inflightRequests: number; - - /** - * Same as `inflightRequests` - */ - unfinishedRequests: number; - - /** - * If this value is set, err will be a corresponding `RequestCloseError` or `RequestAbortedError`. - * - * If connectionState is either 'close' or 'aborted', then the statusCode is not applicable since the connection was severed before a response was written. - */ - connectionState: TMetricsCallback; - } - - /** - * Listens to the server's after event and emits information about that request (5.x compatible only). - * - * ``` - * server.on('after', plugins.metrics({ server }, (err, metrics, req, res, route) => - * { - * // metrics is an object containing information about the request - * })); - * ``` - */ - function metrics(opts: { server: Server }, callback: MetricsCallback): (...args: any[]) => void; - - /** - * Parse the client's request for an OAUTH2 access tokensTable - * - * Subsequent handlers will see `req.oauth2`, which looks like: - * ``` - * { - * oauth2: {accessToken: 'mF_9.B5f-4.1JqM&p=q'} - * } - * ``` - */ - function oauth2TokenParser(): RequestHandler; - - interface RequestExpiryOptions { - /** - * Header name of the absolute time for request expiration - */ - absoluteHeader?: string; - - /** - * Header name for the start time of the request - */ - startHeader?: string; - - /** - * The header name for the time in milliseconds that should ellapse before the request is considered expired. - */ - timeoutHeader?: string; - } - - /** - * A request expiry will use headers to tell if the incoming request has expired or not. - * - * There are two options for this plugin: - * 1. Absolute Time - * * Time in Milliseconds since the Epoch when this request should be considered expired - * 2. Timeout - * * The request start time is supplied - * * A timeout, in milliseconds, is given - * * The timeout is added to the request start time to arrive at the absolute time - * in which the request is considered expires - */ - function requestExpiry(options?: RequestExpiryOptions): RequestHandler; + /** + * A request expiry will use headers to tell if the incoming request has expired or not. + * + * There are two options for this plugin: + * 1. Absolute Time + * * Time in Milliseconds since the Epoch when this request should be considered expired + * 2. Timeout + * * The request start time is supplied + * * A timeout, in milliseconds, is given + * * The timeout is added to the request start time to arrive at the absolute time + * in which the request is considered expires + */ + function requestExpiry(options?: RequestExpiryOptions): RequestHandler; } export namespace pre { diff --git a/types/restify/restify-tests.ts b/types/restify/restify-tests.ts index 46da929a50..b81ecfebd1 100644 --- a/types/restify/restify-tests.ts +++ b/types/restify/restify-tests.ts @@ -143,6 +143,15 @@ server.use(restify.plugins.queryParser()); server.use(restify.plugins.jsonp()); server.use(restify.plugins.gzipResponse()); server.use(restify.plugins.bodyParser()); +server.use( + restify.plugins.serveStaticFiles('somePath', { + etag: '1', + maxAge: 10, + setHeaders: (res: restify.Response, path: string, stat: object) => { + res.setHeader('header-set-x', 'some-header'); + }, + }), +); server.use(restify.plugins.throttle({ burst: 100, rate: 50,