@types/restify

  • Version 8.5.12
  • Published
  • 49.1 kB
  • 4 dependencies
  • MIT license

Install

npm i @types/restify
yarn add @types/restify
pnpm add @types/restify

Overview

TypeScript definitions for restify

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable formatters

const formatters: Formatters;

    Functions

    function createServer

    createServer: (options?: ServerOptions) => Server;

      Classes

      class Router

      class Router {}

        constructor

        constructor(options: RouterOptions);

          property log

          log?: any;

            property name

            name: string;

              property onceNext

              onceNext: boolean;

                property strictNext

                strictNext: boolean;

                  method defaultRoute

                  defaultRoute: (req: Request, res: Response, next: Next) => void;
                  • Default route, when no route found

                  method getDebugInfo

                  getDebugInfo: () => any;
                  • Return information about the routes registered in the router.

                    Returns

                    The routes in the router.

                  method getRoutes

                  getRoutes: () => Route[];
                  • Return mounted routes.

                  method lookup

                  lookup: (req: Request, res: Response) => Chain | undefined;
                  • Lookup for route

                  method lookupByName

                  lookupByName: (name: string, req: Request, res: Response) => Chain | undefined;
                  • Lookup by name

                  method mount

                  mount: (options: MountOptions, ...handlers: RequestHandlerType[]) => string;
                  • adds a route.

                    Parameter options

                    an options object

                    Returns

                    returns the route name if creation is successful.

                  method render

                  render: (routeName: string, params: object, query?: object) => string;
                  • takes an object of route params and query params, and 'renders' a URL.

                    Parameter routeName

                    the route name

                    Parameter params

                    an object of route params

                    Parameter query

                    an object of query params

                  method toString

                  toString: () => string;
                  • toString() serialization.

                  method unmount

                  unmount: (name: string) => string;
                  • unmounts a route.

                    Parameter name

                    the route name

                    Returns

                    the name of the deleted route.

                  Interfaces

                  interface AddressInterface

                  interface AddressInterface {}

                    property address

                    address: string;

                      property family

                      family: string;

                        property port

                        port: number;

                          interface CacheOptions

                          interface CacheOptions {}

                            property maxAge

                            maxAge: number;

                              interface Chain

                              interface Chain {}

                                property onceNext

                                onceNext: boolean;
                                • Prevents calling next multiple times

                                property strictNext

                                strictNext: boolean;
                                • Throws error when next() is called more than once, enables onceNext option

                                method add

                                add: (handler: RequestHandler) => void;
                                • Utilize the given middleware handler

                                method count

                                count: () => number;
                                • Returns the number of handlers

                                method getHandlers

                                getHandlers: () => RequestHandler[];
                                • Get handlers of a chain instance

                                method run

                                run: (req: Request, res: Response, done: () => any) => void;
                                • Handle server requests, punting them down the middleware stack.

                                interface ChainOptions

                                interface ChainOptions {}

                                  property onceNext

                                  onceNext?: boolean | undefined;

                                    property strictNext

                                    strictNext?: boolean | undefined;

                                      interface Formatters

                                      interface Formatters {}

                                        index signature

                                        [contentType: string]: Formatter;

                                          interface MountOptions

                                          interface MountOptions {}

                                            property contentType

                                            contentType?: string | string[] | undefined;

                                              property method

                                              method: string;

                                                property name

                                                name: string;

                                                  property path

                                                  path?: string | RegExp | undefined;

                                                    property url

                                                    url?: string | RegExp | undefined;

                                                      property urlParamPattern

                                                      urlParamPattern?: RegExp | undefined;

                                                        property version

                                                        version?: string | undefined;

                                                          property versions

                                                          versions?: string[] | undefined;

                                                            interface Next

                                                            interface Next {}

                                                              call signature

                                                              (err?: any): void;

                                                                interface RedirectOptions

                                                                interface RedirectOptions {}

                                                                  property hostname

                                                                  hostname?: string | undefined;
                                                                  • redirect location's hostname

                                                                  property overrideQuery

                                                                  overrideQuery?: boolean | undefined;
                                                                  • if true, options.query stomps over any existing query parameters on current URL. by default, will merge the two.

                                                                  property pathname

                                                                  pathname?: string | undefined;
                                                                  • redirect location's pathname

                                                                  property permanent

                                                                  permanent?: boolean | undefined;
                                                                  • if true, sets 301. defaults to 302.

                                                                  property port

                                                                  port?: string | undefined;
                                                                  • redirect location's port number

                                                                  property query

                                                                  query?: string | object | undefined;
                                                                  • redirect location's query string parameters

                                                                  property secure

                                                                  secure?: boolean | undefined;
                                                                  • whether to redirect to http or https

                                                                  interface Request

                                                                  interface Request extends http.IncomingMessage {}

                                                                    property authorization

                                                                    authorization?: RequestAuthorization | undefined;
                                                                    • available when authorizationParser plugin is used

                                                                    property body

                                                                    body?: any;
                                                                    • available when bodyParser plugin is used.

                                                                    property files

                                                                    files?: { [name: string]: File | undefined } | undefined;
                                                                    • available when multipartBodyParser plugin is used.

                                                                    property log

                                                                    log: Logger;
                                                                    • bunyan logger you can piggyback on.

                                                                    property params

                                                                    params?: any;
                                                                    • available when queryParser or bodyParser plugin is used with mapParams enabled.

                                                                    property query

                                                                    query?: any;
                                                                    • available when queryParser plugin is used.

                                                                    property rawBody

                                                                    rawBody?: any;
                                                                    • available when bodyParser plugin is used.

                                                                    property username

                                                                    username?: string | undefined;
                                                                    • available when authorizationParser plugin is used

                                                                    method absoluteUri

                                                                    absoluteUri: (path: string) => string;
                                                                    • Builds an absolute URI for the request.

                                                                    method accepts

                                                                    accepts: (types: string | string[]) => boolean;
                                                                    • checks if the accept header is present and has the value requested. e.g., req.accepts('html');

                                                                      Parameter types

                                                                      an array of accept type headers

                                                                    method acceptsEncoding

                                                                    acceptsEncoding: (types: string | string[]) => boolean;
                                                                    • checks if the request accepts the encoding types.

                                                                      Parameter types

                                                                      an array of accept type headers

                                                                    method connectionState

                                                                    connectionState: () => string;
                                                                    • returns the connection state of the request. current valid values are 'close' and 'aborted'.

                                                                    method contentLength

                                                                    contentLength: () => number;
                                                                    • pass through to getContentLength.

                                                                    method contentType

                                                                    contentType: () => string;
                                                                    • pass through to getContentType.

                                                                    method endHandlerTimer

                                                                    endHandlerTimer: (handlerName: string) => void;
                                                                    • Stop the timer for a request handler function.

                                                                      Parameter handlerName

                                                                      The name of the handler.

                                                                    method getContentLength

                                                                    getContentLength: () => number;
                                                                    • gets the content-length header off the request.

                                                                    method getContentType

                                                                    getContentType: () => string;
                                                                    • gets the content-type header.

                                                                    method getHref

                                                                    getHref: () => string;
                                                                    • retrieves the complete URI requested by the client.

                                                                    method getId

                                                                    getId: () => string;
                                                                    • retrieves the request uuid. was created when the request was setup.

                                                                    method getPath

                                                                    getPath: () => string;
                                                                    • retrieves the cleaned up url path. e.g., /foo?a=1 => /foo

                                                                    method getQuery

                                                                    getQuery: () => string;
                                                                    • returns the raw query string

                                                                    method getRoute

                                                                    getRoute: () => Route;
                                                                    • returns the route object to which the current request was matched to. Route info object structure: { path: '/ping/:name', method: 'GET', versions: [], name: 'getpingname' }

                                                                    method getUrl

                                                                    getUrl: () => url.Url;
                                                                    • returns a parsed URL object.

                                                                    method getVersion

                                                                    getVersion: () => string;
                                                                    • returns the accept-version header.

                                                                    method header

                                                                    header: (key: string, defaultValue?: string) => string;
                                                                    • Get the case-insensitive request header key, and optionally provide a default value (express-compliant). Returns any header off the request. also, 'correct' any correctly spelled 'referrer' header to the actual spelling used.

                                                                      Parameter key

                                                                      the key of the header

                                                                      Parameter defaultValue

                                                                      default value if header isn't found on the req

                                                                    method href

                                                                    href: () => string;
                                                                    • pass through to getHref.

                                                                    method id

                                                                    id: () => string;
                                                                    • pass through to getId.

                                                                    method is

                                                                    is: (type: string) => boolean;
                                                                    • Check if the incoming request contains the Content-Type header field, and if it contains the given mime type.

                                                                      Parameter type

                                                                      a content-type header value

                                                                    method isChunked

                                                                    isChunked: () => boolean;
                                                                    • Check if the incoming request is chunked.

                                                                    method isKeepAlive

                                                                    isKeepAlive: () => boolean;
                                                                    • Check if the incoming request is kept alive.

                                                                    method isSecure

                                                                    isSecure: () => boolean;
                                                                    • Check if the incoming request is encrypted.

                                                                    method isUpgradeRequest

                                                                    isUpgradeRequest: () => boolean;
                                                                    • Check if the incoming request has been upgraded.

                                                                    method isUpload

                                                                    isUpload: () => boolean;
                                                                    • Check if the incoming request is an upload verb.

                                                                    method matchedVersion

                                                                    matchedVersion: () => string;
                                                                    • returns the version of the route that matched.

                                                                    method path

                                                                    path: () => string;
                                                                    • pass through to getPath.

                                                                    method startHandlerTimer

                                                                    startHandlerTimer: (handlerName: string) => void;
                                                                    • Start the timer for a request handler function. You must explicitly invoke endHandlerTimer() after invoking this function. Otherwise timing information will be inaccurate.

                                                                      Parameter handlerName

                                                                      The name of the handler.

                                                                    method time

                                                                    time: () => number;
                                                                    • returns ms since epoch when request was setup.

                                                                    method toString

                                                                    toString: () => string;
                                                                    • toString serialization

                                                                    method trailer

                                                                    trailer: (name: string, defaultValue?: string) => string;
                                                                    • returns any trailer header off the request. also, 'correct' any correctly spelled 'referrer' header to the actual spelling used.

                                                                      Parameter name

                                                                      the name of the header

                                                                      Parameter defaultValue

                                                                      default value if header isn't found on the req

                                                                    method userAgent

                                                                    userAgent: () => string;
                                                                    • retrieves the user-agent header.

                                                                    method version

                                                                    version: () => string;
                                                                    • pass through to getVersion.

                                                                    interface RequestAuthorization

                                                                    interface RequestAuthorization {}

                                                                      property basic

                                                                      basic?:
                                                                      | {
                                                                      username: string;
                                                                      password: string;
                                                                      }
                                                                      | undefined;

                                                                        property credentials

                                                                        credentials: string;

                                                                          property scheme

                                                                          scheme: string;

                                                                            interface Response

                                                                            interface Response extends http.ServerResponse {}

                                                                              property code

                                                                              code: number;
                                                                              • HTTP status code.

                                                                              property contentLength

                                                                              contentLength: number;
                                                                              • short hand for the header content-length.

                                                                              property contentType

                                                                              contentType: string;
                                                                              • short hand for the header content-type.

                                                                              property id

                                                                              id: string;
                                                                              • A unique request id (x-request-id).

                                                                              method cache

                                                                              cache: {
                                                                              (type: string, options?: CacheOptions): string;
                                                                              (options?: CacheOptions): string;
                                                                              };
                                                                              • sets the cache-control header. type defaults to _public_, and options currently only takes maxAge.

                                                                                Parameter type

                                                                                value of the header

                                                                                Parameter options

                                                                                an options object

                                                                                Returns

                                                                                the value set to the header

                                                                              • sets the cache-control header. type defaults to _public_, and options currently only takes maxAge.

                                                                                Parameter options

                                                                                an options object

                                                                                Returns

                                                                                the value set to the header

                                                                              method charSet

                                                                              charSet: (type: string) => Response;
                                                                              • Appends the provided character set to the response's Content-Type. e.g., res.charSet('utf-8');

                                                                                Parameter type

                                                                                char-set value

                                                                                Returns

                                                                                self, the response object

                                                                              method get

                                                                              get: (name: string) => string;
                                                                              • retrieves a header off the response.

                                                                                Parameter name

                                                                                the header name

                                                                              method getHeaders

                                                                              getHeaders: () => any;
                                                                              • retrieves all headers off the response.

                                                                              method header

                                                                              header: (key: string, value?: any) => any;
                                                                              • sets headers on the response.

                                                                                Parameter key

                                                                                the name of the header

                                                                                Parameter value

                                                                                the value of the header

                                                                              method headers

                                                                              headers: () => any;
                                                                              • pass through to getHeaders.

                                                                              method json

                                                                              json: {
                                                                              (code: number, body: any, headers?: { [header: string]: string }): any;
                                                                              (body: any, headers?: { [header: string]: string }): any;
                                                                              };
                                                                              • short hand method for: res.contentType = 'json'; res.send({hello: 'world'});

                                                                                Parameter code

                                                                                http status code

                                                                                Parameter body

                                                                                value to json.stringify

                                                                                Parameter headers

                                                                                headers to set on the response

                                                                              • short hand method for: res.contentType = 'json'; res.send({hello: 'world'});

                                                                                Parameter body

                                                                                value to json.stringify

                                                                                Parameter headers

                                                                                headers to set on the response

                                                                              link: (key: string, value: string) => string;
                                                                              • sets the link heaader.

                                                                                Parameter key

                                                                                the link key

                                                                                Parameter value

                                                                                the link value

                                                                                Returns

                                                                                the header value set to res

                                                                              method noCache

                                                                              noCache: () => Response;
                                                                              • turns off all cache related headers.

                                                                                Returns

                                                                                self, the response object

                                                                              method redirect

                                                                              redirect: {
                                                                              (code: number, url: string, next: Next): void;
                                                                              (opts: string | RedirectOptions, next: Next): void;
                                                                              };
                                                                              • redirect is sugar method for redirecting. res.redirect(301, 'www.foo.com', next); next is mandatory, to complete the response and trigger audit logger.

                                                                                Parameter code

                                                                                the status code

                                                                                Parameter url

                                                                                to redirect to

                                                                                Parameter next

                                                                                mandatory, to complete the response and trigger audit logger redirect

                                                                              • redirect is sugar method for redirecting. res.redirect({...}, next); next is mandatory, to complete the response and trigger audit logger.

                                                                                Parameter url

                                                                                to redirect to or options object to configure a redirect or

                                                                                Parameter next

                                                                                mandatory, to complete the response and trigger audit logger redirect

                                                                              method send

                                                                              send: {
                                                                              (code?: number, body?: any, headers?: { [header: string]: string }): any;
                                                                              (body?: any, headers?: { [header: string]: string }): any;
                                                                              };
                                                                              • sends the response object. pass through to internal __send that uses a formatter based on the content-type header.

                                                                                Parameter code

                                                                                http status code

                                                                                Parameter body

                                                                                the content to send

                                                                                Parameter headers

                                                                                any add'l headers to set

                                                                                Returns

                                                                                the response object

                                                                              • sends the response object. pass through to internal __send that uses a formatter based on the content-type header.

                                                                                Parameter body

                                                                                the content to send

                                                                                Parameter headers

                                                                                any add'l headers to set

                                                                                Returns

                                                                                the response object

                                                                              method sendRaw

                                                                              sendRaw: {
                                                                              (code?: number, body?: any, headers?: { [header: string]: string }): any;
                                                                              (body?: any, headers?: { [header: string]: string }): any;
                                                                              };
                                                                              • sends the response object. pass through to internal __send that skips formatters entirely and sends the content as is.

                                                                                Parameter code

                                                                                http status code

                                                                                Parameter body

                                                                                the content to send

                                                                                Parameter headers

                                                                                any add'l headers to set

                                                                                Returns

                                                                                the response object

                                                                              • sends the response object. pass through to internal __send that skips formatters entirely and sends the content as is.

                                                                                Parameter body

                                                                                the content to send

                                                                                Parameter headers

                                                                                any add'l headers to set

                                                                                Returns

                                                                                the response object

                                                                              method set

                                                                              set: {
                                                                              (name: string, val: string): Response;
                                                                              (headers?: { [header: string]: string }): Response;
                                                                              };
                                                                              • sets a header on the response.

                                                                                Parameter name

                                                                                name of the header

                                                                                Parameter val

                                                                                value of the header

                                                                                Returns

                                                                                self, the response object

                                                                              • sets a header on the response.

                                                                                Parameter val

                                                                                object of headers

                                                                                Returns

                                                                                self, the response object

                                                                              method status

                                                                              status: (code: number) => number;
                                                                              • sets the http status code on the response.

                                                                                Parameter code

                                                                                http status code

                                                                                Returns

                                                                                the status code passed in

                                                                              method toString

                                                                              toString: () => string;
                                                                              • toString() serialization.

                                                                              interface Route

                                                                              interface Route {}

                                                                                property chain

                                                                                chain: Chain;

                                                                                  property method

                                                                                  method: string;

                                                                                    property name

                                                                                    name: string;

                                                                                      property path

                                                                                      path: string | RegExp;

                                                                                        property spec

                                                                                        spec: RouteSpec;

                                                                                          interface RouteOptions

                                                                                          interface RouteOptions {}

                                                                                            property contentType

                                                                                            contentType?: string | string[] | undefined;

                                                                                              property name

                                                                                              name?: string | undefined;

                                                                                                property path

                                                                                                path?: string | RegExp | undefined;

                                                                                                  property url

                                                                                                  url?: string | RegExp | undefined;

                                                                                                    property urlParamPattern

                                                                                                    urlParamPattern?: RegExp | undefined;

                                                                                                      property version

                                                                                                      version?: string | undefined;

                                                                                                        property versions

                                                                                                        versions?: string[] | undefined;

                                                                                                          interface RouterOptions

                                                                                                          interface RouterOptions {}

                                                                                                            property ignoreTrailingSlash

                                                                                                            ignoreTrailingSlash?: boolean | undefined;

                                                                                                              property log

                                                                                                              log?: Logger | undefined;

                                                                                                                property onceNext

                                                                                                                onceNext?: boolean | undefined;

                                                                                                                  property registry

                                                                                                                  registry?: RouterRegistryRadix | undefined;

                                                                                                                    property strictNext

                                                                                                                    strictNext?: boolean | undefined;

                                                                                                                      interface RouterRegistryRadix

                                                                                                                      interface RouterRegistryRadix {}

                                                                                                                        method add

                                                                                                                        add: (route: Route) => boolean;
                                                                                                                        • Adds a route.

                                                                                                                        method get

                                                                                                                        get: () => Route[];
                                                                                                                        • Get registry.

                                                                                                                        method lookup

                                                                                                                        lookup: (method: string, pathname: string) => Chain | undefined;
                                                                                                                        • Registry for route.

                                                                                                                        method remove

                                                                                                                        remove: (name: string) => Route | undefined;
                                                                                                                        • Removes a route.

                                                                                                                        method toString

                                                                                                                        toString: () => string;
                                                                                                                        • toString() serialization.

                                                                                                                        interface RouteSpec

                                                                                                                        interface RouteSpec {}

                                                                                                                          property method

                                                                                                                          method: string;

                                                                                                                            property name

                                                                                                                            name?: string | undefined;

                                                                                                                              property path

                                                                                                                              path: string | RegExp;

                                                                                                                                property versions

                                                                                                                                versions?: string[] | undefined;

                                                                                                                                  interface Server

                                                                                                                                  interface Server extends http.Server {}

                                                                                                                                    property acceptable

                                                                                                                                    acceptable: string[];
                                                                                                                                    • List of content-types this server can respond with.

                                                                                                                                    property ca

                                                                                                                                    ca: ServerOptions['ca'];

                                                                                                                                      property certificate

                                                                                                                                      certificate: ServerOptions['certificate'];

                                                                                                                                        property dtrace

                                                                                                                                        dtrace: boolean;
                                                                                                                                        • enable DTrace support

                                                                                                                                        property formatters

                                                                                                                                        formatters: Formatters;
                                                                                                                                        • Custom response formatters

                                                                                                                                        property handleUncaughtExceptions

                                                                                                                                        handleUncaughtExceptions: boolean;
                                                                                                                                        • Handle uncaught exceptions

                                                                                                                                        property http2

                                                                                                                                        http2?: boolean | undefined;

                                                                                                                                          property key

                                                                                                                                          key: ServerOptions['key'];

                                                                                                                                            property log

                                                                                                                                            log: Logger;
                                                                                                                                            • bunyan instance.

                                                                                                                                            property name

                                                                                                                                            name: string;
                                                                                                                                            • Name of the server.

                                                                                                                                            property onceNext

                                                                                                                                            onceNext: boolean;
                                                                                                                                            • Prevents calling next multiple times

                                                                                                                                            property passphrase

                                                                                                                                            passphrase: ServerOptions['passphrase'] | null;

                                                                                                                                              property preChain

                                                                                                                                              preChain: Chain;
                                                                                                                                              • Pre handlers

                                                                                                                                              property router

                                                                                                                                              router: Router;
                                                                                                                                              • Router instance

                                                                                                                                              property secure

                                                                                                                                              secure?: boolean | undefined;

                                                                                                                                                property server

                                                                                                                                                server: http.Server | https.Server | spdy.Server;
                                                                                                                                                • Node server instance

                                                                                                                                                property spdy

                                                                                                                                                spdy?: boolean | undefined;

                                                                                                                                                  property strictNext

                                                                                                                                                  strictNext: boolean;
                                                                                                                                                  • Throws error when next() is called more than once, enabled onceNext option

                                                                                                                                                  property url

                                                                                                                                                  url: string;
                                                                                                                                                  • Once listen() is called, this will be filled in with where the server is running.

                                                                                                                                                  property useChain

                                                                                                                                                  useChain: Chain;

                                                                                                                                                    property versions

                                                                                                                                                    versions: string[];
                                                                                                                                                    • Default version(s) to use in all routes.

                                                                                                                                                    method address

                                                                                                                                                    address: () => AddressInterface;
                                                                                                                                                    • Returns the server address. Wraps node's address().

                                                                                                                                                    method close

                                                                                                                                                    close: (callback?: () => any) => any;
                                                                                                                                                    • Shuts down this server, and invokes callback (optionally) when done. Wraps node's close().

                                                                                                                                                      Parameter callback

                                                                                                                                                      optional callback to invoke when done.

                                                                                                                                                    method del

                                                                                                                                                    del: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method get

                                                                                                                                                    get: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method getDebugInfo

                                                                                                                                                    getDebugInfo: () => any;
                                                                                                                                                    • Return debug information about the server.

                                                                                                                                                    method head

                                                                                                                                                    head: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method inflightRequests

                                                                                                                                                    inflightRequests: () => number;
                                                                                                                                                    • Returns the number of currently inflight requests.

                                                                                                                                                    method listen

                                                                                                                                                    listen: (...args: any[]) => any;
                                                                                                                                                    • Gets the server up and listening. Wraps node's listen().

                                                                                                                                                      You can call like: server.listen(80) server.listen(80, '127.0.0.1') server.listen('/tmp/server.sock')

                                                                                                                                                      Parameter callback

                                                                                                                                                      optionally get notified when listening.

                                                                                                                                                      Throws

                                                                                                                                                      {TypeError}

                                                                                                                                                    method opts

                                                                                                                                                    opts: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method param

                                                                                                                                                    param: (name: string, fn: RequestHandler) => Server;
                                                                                                                                                    • Minimal port of the functionality offered by Express.js Route Param Pre-conditions http://expressjs.com/guide.html#route-param%20pre-conditions

                                                                                                                                                      This basically piggy-backs on the server.use method. It attaches a new middleware function that only fires if the specified parameter exists in req.params

                                                                                                                                                      Exposes an API: server.param("user", function (req, res, next) { // load the user's information here, always making sure to call next() });

                                                                                                                                                      Parameter name

                                                                                                                                                      The name of the URL param to respond to

                                                                                                                                                      Parameter fn

                                                                                                                                                      The middleware function to execute

                                                                                                                                                      Returns

                                                                                                                                                      returns self

                                                                                                                                                    method patch

                                                                                                                                                    patch: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method post

                                                                                                                                                    post: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method pre

                                                                                                                                                    pre: (...pre: RequestHandlerType[]) => Server;
                                                                                                                                                    • Gives you hooks to run _before_ any routes are located. This gives you a chance to intercept the request and change headers, etc., that routing depends on. Note that req.params will _not_ be set yet.

                                                                                                                                                      Returns

                                                                                                                                                      returns self

                                                                                                                                                    method put

                                                                                                                                                    put: (
                                                                                                                                                    opts: string | RegExp | RouteOptions,
                                                                                                                                                    ...handlers: RequestHandlerType[]
                                                                                                                                                    ) => Route | boolean;
                                                                                                                                                    • Mounts a chain on the given path against this HTTP verb

                                                                                                                                                      Parameter opts

                                                                                                                                                      if string, the URL to handle. if options, the URL to handle, at minimum.

                                                                                                                                                      Returns

                                                                                                                                                      the newly created route.

                                                                                                                                                    method rm

                                                                                                                                                    rm: (route: string) => boolean;
                                                                                                                                                    • Removes a route from the server. You pass in the route 'blob' you got from a mount call.

                                                                                                                                                      Parameter route

                                                                                                                                                      the route name.

                                                                                                                                                      Returns

                                                                                                                                                      true if route was removed, false if not.

                                                                                                                                                      Throws

                                                                                                                                                      {TypeError} on bad input.

                                                                                                                                                    method toString

                                                                                                                                                    toString: () => string;
                                                                                                                                                    • toString() the server for easy reading/output.

                                                                                                                                                    method use

                                                                                                                                                    use: (...handlers: RequestHandlerType[]) => Server;
                                                                                                                                                    • Installs a list of handlers to run _before_ the "normal" handlers of all routes.

                                                                                                                                                      You can pass in any combination of functions or array of functions.

                                                                                                                                                      Returns

                                                                                                                                                      returns self

                                                                                                                                                    interface ServerOptions

                                                                                                                                                    interface ServerOptions {}

                                                                                                                                                      property ca

                                                                                                                                                      ca?: string | Buffer | ReadonlyArray<string | Buffer> | undefined;

                                                                                                                                                        property cert

                                                                                                                                                        cert?: string | Buffer | ReadonlyArray<string | Buffer> | undefined;

                                                                                                                                                          property certificate

                                                                                                                                                          certificate?: string | Buffer | ReadonlyArray<string | Buffer> | undefined;

                                                                                                                                                            property ciphers

                                                                                                                                                            ciphers?: string | undefined;

                                                                                                                                                              property dtrace

                                                                                                                                                              dtrace?: boolean | undefined;

                                                                                                                                                                property formatters

                                                                                                                                                                formatters?: Formatters | undefined;

                                                                                                                                                                  property handleUncaughtExceptions

                                                                                                                                                                  handleUncaughtExceptions?: boolean | undefined;

                                                                                                                                                                    property handleUpgrades

                                                                                                                                                                    handleUpgrades?: boolean | undefined;

                                                                                                                                                                      property http2

                                                                                                                                                                      http2?: any;

                                                                                                                                                                        property httpsServerOptions

                                                                                                                                                                        httpsServerOptions?: https.ServerOptions | undefined;

                                                                                                                                                                          property ignoreTrailingSlash

                                                                                                                                                                          ignoreTrailingSlash?: boolean | undefined;

                                                                                                                                                                            property key

                                                                                                                                                                            key?: string | Buffer | ReadonlyArray<string | Buffer> | undefined;

                                                                                                                                                                              property log

                                                                                                                                                                              log?: Logger | undefined;

                                                                                                                                                                                property maxParamLength

                                                                                                                                                                                maxParamLength?: number | undefined;

                                                                                                                                                                                  property name

                                                                                                                                                                                  name?: string | undefined;

                                                                                                                                                                                    property noWriteContinue

                                                                                                                                                                                    noWriteContinue?: boolean | undefined;

                                                                                                                                                                                      property onceNext

                                                                                                                                                                                      onceNext?: boolean | undefined;

                                                                                                                                                                                        property passphrase

                                                                                                                                                                                        passphrase?: string | undefined;

                                                                                                                                                                                          property rejectUnauthorized

                                                                                                                                                                                          rejectUnauthorized?: boolean | undefined;

                                                                                                                                                                                            property requestCert

                                                                                                                                                                                            requestCert?: boolean | undefined;

                                                                                                                                                                                              property router

                                                                                                                                                                                              router?: Router | undefined;

                                                                                                                                                                                                property secureOptions

                                                                                                                                                                                                secureOptions?: number | undefined;

                                                                                                                                                                                                  property socketio

                                                                                                                                                                                                  socketio?: boolean | undefined;

                                                                                                                                                                                                    property spdy

                                                                                                                                                                                                    spdy?: spdy.ServerOptions | undefined;

                                                                                                                                                                                                      property strictFormatters

                                                                                                                                                                                                      strictFormatters?: boolean | undefined;

                                                                                                                                                                                                        property strictNext

                                                                                                                                                                                                        strictNext?: boolean | undefined;

                                                                                                                                                                                                          property version

                                                                                                                                                                                                          version?: string | undefined;

                                                                                                                                                                                                            property versions

                                                                                                                                                                                                            versions?: string[] | undefined;

                                                                                                                                                                                                              interface ServerUpgradeResponse

                                                                                                                                                                                                              interface ServerUpgradeResponse {}

                                                                                                                                                                                                                method claimUpgrade

                                                                                                                                                                                                                claimUpgrade: () => any;
                                                                                                                                                                                                                • Attempt to upgrade.

                                                                                                                                                                                                                method end

                                                                                                                                                                                                                end: () => boolean;
                                                                                                                                                                                                                • Ends the response

                                                                                                                                                                                                                method send

                                                                                                                                                                                                                send: { (code: number, body: any): any; (body: any): boolean };
                                                                                                                                                                                                                • Sends the response.

                                                                                                                                                                                                                  Parameter code

                                                                                                                                                                                                                  the http status code

                                                                                                                                                                                                                  Parameter body

                                                                                                                                                                                                                  the response to send out

                                                                                                                                                                                                                • Sends the response.

                                                                                                                                                                                                                  Parameter body

                                                                                                                                                                                                                  the response to send out

                                                                                                                                                                                                                method status

                                                                                                                                                                                                                status: (code: number) => number;
                                                                                                                                                                                                                • Set the status code of the response.

                                                                                                                                                                                                                  Parameter code

                                                                                                                                                                                                                  the http status code

                                                                                                                                                                                                                method write

                                                                                                                                                                                                                write: () => boolean;
                                                                                                                                                                                                                • Write to the response.

                                                                                                                                                                                                                method writeHead

                                                                                                                                                                                                                writeHead: (statusCode: number, reason?: string) => void;
                                                                                                                                                                                                                • Write to the head of the response.

                                                                                                                                                                                                                  Parameter statusCode

                                                                                                                                                                                                                  the http status code

                                                                                                                                                                                                                  Parameter reason

                                                                                                                                                                                                                  a message

                                                                                                                                                                                                                Type Aliases

                                                                                                                                                                                                                type FindRouteCallback

                                                                                                                                                                                                                type FindRouteCallback = (err: Error, route?: Route, params?: any) => void;

                                                                                                                                                                                                                  type Formatter

                                                                                                                                                                                                                  type Formatter = (req: Request, res: Response, body: any) => string | Buffer | null;

                                                                                                                                                                                                                    type RequestHandler

                                                                                                                                                                                                                    type RequestHandler = (req: Request, res: Response, next: Next) => any;

                                                                                                                                                                                                                      type RequestHandlerType

                                                                                                                                                                                                                      type RequestHandlerType = RequestHandler | RequestHandler[];

                                                                                                                                                                                                                        Namespaces

                                                                                                                                                                                                                        namespace bunyan

                                                                                                                                                                                                                        namespace bunyan {}

                                                                                                                                                                                                                          variable serializers

                                                                                                                                                                                                                          const serializers: any;

                                                                                                                                                                                                                            function createLogger

                                                                                                                                                                                                                            createLogger: (name: string) => Logger;
                                                                                                                                                                                                                            • create a bunyan logger

                                                                                                                                                                                                                            class RequestCaptureStream

                                                                                                                                                                                                                            class RequestCaptureStream extends stream.Stream {}
                                                                                                                                                                                                                            • A Bunyan stream to capture records in a ring buffer and only pass through on a higher-level record. E.g. buffer up all records but only dump when getting a WARN or above.

                                                                                                                                                                                                                            constructor

                                                                                                                                                                                                                            constructor(opts: RequestCaptureOptions);

                                                                                                                                                                                                                              method write

                                                                                                                                                                                                                              write: (record: any) => void;
                                                                                                                                                                                                                              • write to the stream

                                                                                                                                                                                                                              interface RequestCaptureOptions

                                                                                                                                                                                                                              interface RequestCaptureOptions {}

                                                                                                                                                                                                                                property dumpDefault

                                                                                                                                                                                                                                dumpDefault?: boolean | undefined;
                                                                                                                                                                                                                                • If true, then dump captured records on the *default* request id when dumping. I.e. dump records logged without "req_id" field. Default false.

                                                                                                                                                                                                                                property level

                                                                                                                                                                                                                                level?: Logger.LogLevel | undefined;
                                                                                                                                                                                                                                • The level at which to trigger dumping captured records. Defaults to bunyan.WARN.

                                                                                                                                                                                                                                property maxRecords

                                                                                                                                                                                                                                maxRecords?: number | undefined;
                                                                                                                                                                                                                                • Number of records to capture. Default 100.

                                                                                                                                                                                                                                property maxRequestIds

                                                                                                                                                                                                                                maxRequestIds?: number | undefined;
                                                                                                                                                                                                                                • Number of simultaneous request id capturing buckets to maintain. Default 1000.

                                                                                                                                                                                                                                property stream

                                                                                                                                                                                                                                stream?: Logger.Stream | undefined;
                                                                                                                                                                                                                                • The stream to which to write when dumping captured records.

                                                                                                                                                                                                                                property streams

                                                                                                                                                                                                                                streams?: readonly Logger.Stream[] | undefined;
                                                                                                                                                                                                                                • The streams to which to write when dumping captured records.

                                                                                                                                                                                                                                namespace plugins

                                                                                                                                                                                                                                namespace plugins {}

                                                                                                                                                                                                                                  function acceptParser

                                                                                                                                                                                                                                  acceptParser: (accepts: string[]) => RequestHandler;
                                                                                                                                                                                                                                  • Check the client's Accept header can be handled by this server.

                                                                                                                                                                                                                                  function auditLogger

                                                                                                                                                                                                                                  auditLogger: (options: AuditLoggerOptions) => (...args: any[]) => void;
                                                                                                                                                                                                                                  • An audit logger for recording all handled requests

                                                                                                                                                                                                                                  function authorizationParser

                                                                                                                                                                                                                                  authorizationParser: (options?: any) => RequestHandler;
                                                                                                                                                                                                                                  • Authorization header

                                                                                                                                                                                                                                  function bodyParser

                                                                                                                                                                                                                                  bodyParser: (options?: BodyParserOptions) => RequestHandler[];
                                                                                                                                                                                                                                  • Parses POST bodies to req.body. automatically uses one of the following parsers based on content type.

                                                                                                                                                                                                                                  function bodyReader

                                                                                                                                                                                                                                  bodyReader: (options?: { maxBodySize?: number | undefined }) => RequestHandler;
                                                                                                                                                                                                                                  • Reads the body of the request.

                                                                                                                                                                                                                                  function conditionalHandler

                                                                                                                                                                                                                                  conditionalHandler: (
                                                                                                                                                                                                                                  candidates: HandlerCandidate | HandlerCandidate[]
                                                                                                                                                                                                                                  ) => RequestHandler;
                                                                                                                                                                                                                                  • Runs first handler that matches to the condition

                                                                                                                                                                                                                                  function conditionalRequest

                                                                                                                                                                                                                                  conditionalRequest: () => RequestHandler[];
                                                                                                                                                                                                                                  • Conditional headers (If-*)

                                                                                                                                                                                                                                  function cpuUsageThrottle

                                                                                                                                                                                                                                  cpuUsageThrottle: (opts?: CpuUsageThrottleOptions) => RequestHandler;
                                                                                                                                                                                                                                  • Cpu Throttle middleware

                                                                                                                                                                                                                                  function dateParser

                                                                                                                                                                                                                                  dateParser: (delta?: number) => RequestHandler;
                                                                                                                                                                                                                                  • expires requests based on current time + delta

                                                                                                                                                                                                                                    Parameter delta

                                                                                                                                                                                                                                    age in seconds

                                                                                                                                                                                                                                  function fullResponse

                                                                                                                                                                                                                                  fullResponse: () => RequestHandler;
                                                                                                                                                                                                                                  • Handles disappeared CORS headers

                                                                                                                                                                                                                                  function gzipResponse

                                                                                                                                                                                                                                  gzipResponse: (options?: zlib.ZlibOptions) => RequestHandler;
                                                                                                                                                                                                                                  • gzips the response if client send accept-encoding: gzip

                                                                                                                                                                                                                                    Parameter options

                                                                                                                                                                                                                                    options to pass to gzlib

                                                                                                                                                                                                                                  function inflightRequestThrottle

                                                                                                                                                                                                                                  inflightRequestThrottle: (
                                                                                                                                                                                                                                  opts: InflightRequestThrottleOptions
                                                                                                                                                                                                                                  ) => RequestHandler;

                                                                                                                                                                                                                                    function jsonBodyParser

                                                                                                                                                                                                                                    jsonBodyParser: (options?: JsonBodyParserOptions) => RequestHandler[];
                                                                                                                                                                                                                                    • Parses JSON POST bodies

                                                                                                                                                                                                                                    function jsonp

                                                                                                                                                                                                                                    jsonp: () => RequestHandler;
                                                                                                                                                                                                                                    • Parses JSONP callback

                                                                                                                                                                                                                                    function metrics

                                                                                                                                                                                                                                    metrics: (
                                                                                                                                                                                                                                    opts: { server: Server },
                                                                                                                                                                                                                                    callback: MetricsCallback
                                                                                                                                                                                                                                    ) => (...args: any[]) => void;
                                                                                                                                                                                                                                    • 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 multipartBodyParser

                                                                                                                                                                                                                                    multipartBodyParser: (options?: MultipartBodyParser) => RequestHandler;
                                                                                                                                                                                                                                    • Parses JSONP callback

                                                                                                                                                                                                                                    function oauth2TokenParser

                                                                                                                                                                                                                                    oauth2TokenParser: () => RequestHandler;
                                                                                                                                                                                                                                    • 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 queryParser

                                                                                                                                                                                                                                    queryParser: (options?: QueryParserOptions) => RequestHandler;
                                                                                                                                                                                                                                    • 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 requestExpiry

                                                                                                                                                                                                                                    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 requestLogger

                                                                                                                                                                                                                                    requestLogger: (options?: RequestLogger) => RequestHandler;
                                                                                                                                                                                                                                    • Adds timers for each handler in your request chain

                                                                                                                                                                                                                                      options.properties properties to pass to bunyan's log.child() method

                                                                                                                                                                                                                                    function serveStatic

                                                                                                                                                                                                                                    serveStatic: (options?: ServeStatic) => RequestHandler;
                                                                                                                                                                                                                                    • Used to serve static files

                                                                                                                                                                                                                                    function serveStaticFiles

                                                                                                                                                                                                                                    serveStaticFiles: (dir: string, options?: ServeStaticFiles) => RequestHandler;
                                                                                                                                                                                                                                    • Used to serve static files from a given directory

                                                                                                                                                                                                                                    function throttle

                                                                                                                                                                                                                                    throttle: (options?: ThrottleOptions) => RequestHandler;
                                                                                                                                                                                                                                    • throttles responses

                                                                                                                                                                                                                                    function urlEncodedBodyParser

                                                                                                                                                                                                                                    urlEncodedBodyParser: (
                                                                                                                                                                                                                                    options?: UrlEncodedBodyParserOptions
                                                                                                                                                                                                                                    ) => RequestHandler[];
                                                                                                                                                                                                                                    • 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.

                                                                                                                                                                                                                                    interface AuditLoggerOptions

                                                                                                                                                                                                                                    interface AuditLoggerOptions {}

                                                                                                                                                                                                                                      property body

                                                                                                                                                                                                                                      body?: boolean | undefined;

                                                                                                                                                                                                                                        property context

                                                                                                                                                                                                                                        context?: AuditLoggerContext | undefined;
                                                                                                                                                                                                                                        • 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.

                                                                                                                                                                                                                                        property event

                                                                                                                                                                                                                                        event: 'pre' | 'routed' | 'after';
                                                                                                                                                                                                                                        • The event from the server which initiates the log, one of 'pre', 'routed', or 'after'

                                                                                                                                                                                                                                        property log

                                                                                                                                                                                                                                        log: Logger;
                                                                                                                                                                                                                                        • Bunyan logger

                                                                                                                                                                                                                                        property logBuffer

                                                                                                                                                                                                                                        logBuffer?: any;
                                                                                                                                                                                                                                        • Ringbuffer which is written to if passed in

                                                                                                                                                                                                                                        property printLog

                                                                                                                                                                                                                                        printLog?: boolean | undefined;
                                                                                                                                                                                                                                        • When true, prints audit logs. default true.

                                                                                                                                                                                                                                        property server

                                                                                                                                                                                                                                        server?: Server | undefined;
                                                                                                                                                                                                                                        • Restify server. If passed in, causes server to emit 'auditlog' event after audit logs are flushed

                                                                                                                                                                                                                                        interface BodyParserOptions

                                                                                                                                                                                                                                        interface BodyParserOptions {}

                                                                                                                                                                                                                                          property hash

                                                                                                                                                                                                                                          hash?: string | undefined;
                                                                                                                                                                                                                                          • If you want checksums calculated for incoming files, set this to either sha1 or md5.

                                                                                                                                                                                                                                          property keepExtensions

                                                                                                                                                                                                                                          keepExtensions?: boolean | undefined;
                                                                                                                                                                                                                                          • If you want the uploaded files to include the extensions of the original files (multipart uploads only). Does nothing if multipartFileHandler is defined.

                                                                                                                                                                                                                                          property mapFiles

                                                                                                                                                                                                                                          mapFiles?: boolean | undefined;
                                                                                                                                                                                                                                          • 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.

                                                                                                                                                                                                                                          property mapParams

                                                                                                                                                                                                                                          mapParams?: boolean | undefined;
                                                                                                                                                                                                                                          • If req.params should be filled with parsed parameters from HTTP body.

                                                                                                                                                                                                                                          property maxBodySize

                                                                                                                                                                                                                                          maxBodySize?: number | undefined;
                                                                                                                                                                                                                                          • The maximum size in bytes allowed in the HTTP body. Useful for limiting clients from hogging server memory.

                                                                                                                                                                                                                                          property maxFieldsSize

                                                                                                                                                                                                                                          maxFieldsSize?: number | undefined;

                                                                                                                                                                                                                                            property maxFileSize

                                                                                                                                                                                                                                            maxFileSize?: number | undefined;

                                                                                                                                                                                                                                              property multiples

                                                                                                                                                                                                                                              multiples?: boolean | undefined;
                                                                                                                                                                                                                                              • If you want to support html5 multiple attribute in upload fields.

                                                                                                                                                                                                                                              property overrideParams

                                                                                                                                                                                                                                              overrideParams?: boolean | undefined;
                                                                                                                                                                                                                                              • 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.

                                                                                                                                                                                                                                              property rejectUnknown

                                                                                                                                                                                                                                              rejectUnknown?: boolean | undefined;
                                                                                                                                                                                                                                              • Set to true if you want to end the request with a UnsupportedMediaTypeError when none of the supported content types was given.

                                                                                                                                                                                                                                              property requestBodyOnGet

                                                                                                                                                                                                                                              requestBodyOnGet?: boolean | undefined;

                                                                                                                                                                                                                                                property reviver

                                                                                                                                                                                                                                                reviver?: any;

                                                                                                                                                                                                                                                  property uploadDir

                                                                                                                                                                                                                                                  uploadDir?: string | undefined;
                                                                                                                                                                                                                                                  • Where uploaded files are intermediately stored during transfer before the contents is mapped into req.params. Does nothing if multipartFileHandler is defined.

                                                                                                                                                                                                                                                  method multipartFileHandler

                                                                                                                                                                                                                                                  multipartFileHandler: () => 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.

                                                                                                                                                                                                                                                  method multipartHandler

                                                                                                                                                                                                                                                  multipartHandler: () => void;
                                                                                                                                                                                                                                                  • 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.

                                                                                                                                                                                                                                                  interface CpuUsageThrottleOptions

                                                                                                                                                                                                                                                  interface CpuUsageThrottleOptions {}

                                                                                                                                                                                                                                                    property halfLife

                                                                                                                                                                                                                                                    halfLife?: number | undefined;

                                                                                                                                                                                                                                                      property interval

                                                                                                                                                                                                                                                      interval?: number | undefined;

                                                                                                                                                                                                                                                        property limit

                                                                                                                                                                                                                                                        limit?: number | undefined;

                                                                                                                                                                                                                                                          property max

                                                                                                                                                                                                                                                          max?: number | undefined;

                                                                                                                                                                                                                                                            interface HandlerCandidate

                                                                                                                                                                                                                                                            interface HandlerCandidate {}

                                                                                                                                                                                                                                                              property contentType

                                                                                                                                                                                                                                                              contentType?: string | string[] | undefined;

                                                                                                                                                                                                                                                                property handler

                                                                                                                                                                                                                                                                handler: RequestHandler | RequestHandler[];

                                                                                                                                                                                                                                                                  property version

                                                                                                                                                                                                                                                                  version?: string | string[] | undefined;

                                                                                                                                                                                                                                                                    interface InflightRequestThrottleOptions

                                                                                                                                                                                                                                                                    interface InflightRequestThrottleOptions {}

                                                                                                                                                                                                                                                                      property err

                                                                                                                                                                                                                                                                      err: any;

                                                                                                                                                                                                                                                                        property limit

                                                                                                                                                                                                                                                                        limit: number;

                                                                                                                                                                                                                                                                          property server

                                                                                                                                                                                                                                                                          server: Server;

                                                                                                                                                                                                                                                                            interface JsonBodyParserOptions

                                                                                                                                                                                                                                                                            interface JsonBodyParserOptions {}

                                                                                                                                                                                                                                                                              property bodyReader

                                                                                                                                                                                                                                                                              bodyReader?: boolean | undefined;

                                                                                                                                                                                                                                                                                property mapParams

                                                                                                                                                                                                                                                                                mapParams?: boolean | undefined;

                                                                                                                                                                                                                                                                                  property overrideParams

                                                                                                                                                                                                                                                                                  overrideParams?: boolean | undefined;

                                                                                                                                                                                                                                                                                    method reviver

                                                                                                                                                                                                                                                                                    reviver: (key: any, value: any) => any;

                                                                                                                                                                                                                                                                                      interface MetricsCallbackOptions

                                                                                                                                                                                                                                                                                      interface MetricsCallbackOptions {}

                                                                                                                                                                                                                                                                                        property connectionState

                                                                                                                                                                                                                                                                                        connectionState: TMetricsCallback;
                                                                                                                                                                                                                                                                                        • 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.

                                                                                                                                                                                                                                                                                        property inflightRequests

                                                                                                                                                                                                                                                                                        inflightRequests: number;
                                                                                                                                                                                                                                                                                        • Number of inflight requests pending in restify

                                                                                                                                                                                                                                                                                        property latency

                                                                                                                                                                                                                                                                                        latency: number;
                                                                                                                                                                                                                                                                                        • Request latency

                                                                                                                                                                                                                                                                                        property method

                                                                                                                                                                                                                                                                                        method: string;
                                                                                                                                                                                                                                                                                        • HTTP request verb

                                                                                                                                                                                                                                                                                        property path

                                                                                                                                                                                                                                                                                        path: string;
                                                                                                                                                                                                                                                                                        • req.path() value

                                                                                                                                                                                                                                                                                        property preLatency

                                                                                                                                                                                                                                                                                        preLatency: number | null;
                                                                                                                                                                                                                                                                                        • pre handlers latency

                                                                                                                                                                                                                                                                                        property statusCode

                                                                                                                                                                                                                                                                                        statusCode: number;
                                                                                                                                                                                                                                                                                        • 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.

                                                                                                                                                                                                                                                                                        property totalLatency

                                                                                                                                                                                                                                                                                        totalLatency: number;
                                                                                                                                                                                                                                                                                        • latency includes both request is flushed and all handlers finished

                                                                                                                                                                                                                                                                                        property unfinishedRequests

                                                                                                                                                                                                                                                                                        unfinishedRequests: number;
                                                                                                                                                                                                                                                                                        • Same as inflightRequests

                                                                                                                                                                                                                                                                                        property useLatency

                                                                                                                                                                                                                                                                                        useLatency: number | null;
                                                                                                                                                                                                                                                                                        • use handlers latency

                                                                                                                                                                                                                                                                                        interface MultipartBodyParser

                                                                                                                                                                                                                                                                                        interface MultipartBodyParser {}

                                                                                                                                                                                                                                                                                          property hash

                                                                                                                                                                                                                                                                                          hash?: string | undefined;

                                                                                                                                                                                                                                                                                            property keepExtensions

                                                                                                                                                                                                                                                                                            keepExtensions?: boolean | undefined;

                                                                                                                                                                                                                                                                                              property mapFiles

                                                                                                                                                                                                                                                                                              mapFiles?: boolean | undefined;

                                                                                                                                                                                                                                                                                                property mapParams

                                                                                                                                                                                                                                                                                                mapParams?: boolean | undefined;

                                                                                                                                                                                                                                                                                                  property maxFieldsSize

                                                                                                                                                                                                                                                                                                  maxFieldsSize?: number | undefined;

                                                                                                                                                                                                                                                                                                    property maxFileSize

                                                                                                                                                                                                                                                                                                    maxFileSize?: number | undefined;

                                                                                                                                                                                                                                                                                                      property multipartFileHandler

                                                                                                                                                                                                                                                                                                      multipartFileHandler?: any;

                                                                                                                                                                                                                                                                                                        property multipartHandler

                                                                                                                                                                                                                                                                                                        multipartHandler?: any;

                                                                                                                                                                                                                                                                                                          property multiples

                                                                                                                                                                                                                                                                                                          multiples?: boolean | undefined;

                                                                                                                                                                                                                                                                                                            property overrideParams

                                                                                                                                                                                                                                                                                                            overrideParams?: boolean | undefined;

                                                                                                                                                                                                                                                                                                              property uploadDir

                                                                                                                                                                                                                                                                                                              uploadDir?: string | undefined;

                                                                                                                                                                                                                                                                                                                interface QueryParserOptions

                                                                                                                                                                                                                                                                                                                interface QueryParserOptions {}

                                                                                                                                                                                                                                                                                                                  property allowDots

                                                                                                                                                                                                                                                                                                                  allowDots?: boolean | undefined;
                                                                                                                                                                                                                                                                                                                  • Default false. Transform ?foo.bar=baz to a nested object: {foo: {bar: 'baz'}}.

                                                                                                                                                                                                                                                                                                                  property arrayLimit

                                                                                                                                                                                                                                                                                                                  arrayLimit?: number | undefined;
                                                                                                                                                                                                                                                                                                                  • Default 20. Only transform ?a[$index]=b to an array if $index is less than arrayLimit.

                                                                                                                                                                                                                                                                                                                  property depth

                                                                                                                                                                                                                                                                                                                  depth?: number | undefined;
                                                                                                                                                                                                                                                                                                                  • Default 5. The depth limit for parsing nested objects, e.g. ?a[b][c][d][e][f][g][h][i]=j.

                                                                                                                                                                                                                                                                                                                  property mapParams

                                                                                                                                                                                                                                                                                                                  mapParams?: boolean | undefined;
                                                                                                                                                                                                                                                                                                                  • Default false. Copies parsed query parameters into req.params.

                                                                                                                                                                                                                                                                                                                  property overrideParams

                                                                                                                                                                                                                                                                                                                  overrideParams?: boolean | undefined;
                                                                                                                                                                                                                                                                                                                  • Default false. Only applies when if mapParams true. When true, will stomp on req.params field when existing value is found.

                                                                                                                                                                                                                                                                                                                  property parameterLimit

                                                                                                                                                                                                                                                                                                                  parameterLimit?: number | undefined;
                                                                                                                                                                                                                                                                                                                  • Default 1000. Maximum number of query params parsed. Additional params are silently dropped.

                                                                                                                                                                                                                                                                                                                  property parseArrays

                                                                                                                                                                                                                                                                                                                  parseArrays?: boolean | undefined;
                                                                                                                                                                                                                                                                                                                  • Default true. Whether to parse ?a[]=b&a[1]=c to an array, e.g. {a: ['b', 'c']}.

                                                                                                                                                                                                                                                                                                                  property plainObjects

                                                                                                                                                                                                                                                                                                                  plainObjects?: boolean | undefined;
                                                                                                                                                                                                                                                                                                                  • 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.

                                                                                                                                                                                                                                                                                                                  property strictNullHandling

                                                                                                                                                                                                                                                                                                                  strictNullHandling?: boolean | undefined;
                                                                                                                                                                                                                                                                                                                  • Default false. If true, ?a&b= results in {a: null, b: ''}. Otherwise, {a: '', b: ''}.

                                                                                                                                                                                                                                                                                                                  interface RequestExpiryOptions

                                                                                                                                                                                                                                                                                                                  interface RequestExpiryOptions {}

                                                                                                                                                                                                                                                                                                                    property absoluteHeader

                                                                                                                                                                                                                                                                                                                    absoluteHeader?: string | undefined;
                                                                                                                                                                                                                                                                                                                    • Header name of the absolute time for request expiration

                                                                                                                                                                                                                                                                                                                    property startHeader

                                                                                                                                                                                                                                                                                                                    startHeader?: string | undefined;
                                                                                                                                                                                                                                                                                                                    • Header name for the start time of the request

                                                                                                                                                                                                                                                                                                                    property timeoutHeader

                                                                                                                                                                                                                                                                                                                    timeoutHeader?: string | undefined;
                                                                                                                                                                                                                                                                                                                    • The header name for the time in milliseconds that should ellapse before the request is considered expired.

                                                                                                                                                                                                                                                                                                                    interface RequestLogger

                                                                                                                                                                                                                                                                                                                    interface RequestLogger {}

                                                                                                                                                                                                                                                                                                                      property headers

                                                                                                                                                                                                                                                                                                                      headers?: any;

                                                                                                                                                                                                                                                                                                                        property log

                                                                                                                                                                                                                                                                                                                        log?: any;

                                                                                                                                                                                                                                                                                                                          property properties

                                                                                                                                                                                                                                                                                                                          properties?: any;

                                                                                                                                                                                                                                                                                                                            property serializers

                                                                                                                                                                                                                                                                                                                            serializers?: any;

                                                                                                                                                                                                                                                                                                                              interface ServeStatic

                                                                                                                                                                                                                                                                                                                              interface ServeStatic {}

                                                                                                                                                                                                                                                                                                                                property appendRequestPath

                                                                                                                                                                                                                                                                                                                                appendRequestPath?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                  property charSet

                                                                                                                                                                                                                                                                                                                                  charSet?: string | undefined;

                                                                                                                                                                                                                                                                                                                                    property default

                                                                                                                                                                                                                                                                                                                                    default?: any;

                                                                                                                                                                                                                                                                                                                                      property directory

                                                                                                                                                                                                                                                                                                                                      directory?: string | undefined;

                                                                                                                                                                                                                                                                                                                                        property etag

                                                                                                                                                                                                                                                                                                                                        etag?: string | undefined;

                                                                                                                                                                                                                                                                                                                                          property file

                                                                                                                                                                                                                                                                                                                                          file?: string | undefined;

                                                                                                                                                                                                                                                                                                                                            property gzip

                                                                                                                                                                                                                                                                                                                                            gzip?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                              property match

                                                                                                                                                                                                                                                                                                                                              match?: any;

                                                                                                                                                                                                                                                                                                                                                property maxAge

                                                                                                                                                                                                                                                                                                                                                maxAge?: number | undefined;

                                                                                                                                                                                                                                                                                                                                                  interface ServeStaticFiles

                                                                                                                                                                                                                                                                                                                                                  interface ServeStaticFiles {}

                                                                                                                                                                                                                                                                                                                                                    property etag

                                                                                                                                                                                                                                                                                                                                                    etag?: string | undefined;

                                                                                                                                                                                                                                                                                                                                                      property maxAge

                                                                                                                                                                                                                                                                                                                                                      maxAge?: number | undefined;

                                                                                                                                                                                                                                                                                                                                                        property setHeaders

                                                                                                                                                                                                                                                                                                                                                        setHeaders?: ((res: Response, path: string, stat: any) => any) | undefined;

                                                                                                                                                                                                                                                                                                                                                          interface ThrottleOptions

                                                                                                                                                                                                                                                                                                                                                          interface ThrottleOptions {}

                                                                                                                                                                                                                                                                                                                                                            property burst

                                                                                                                                                                                                                                                                                                                                                            burst?: number | undefined;

                                                                                                                                                                                                                                                                                                                                                              property ip

                                                                                                                                                                                                                                                                                                                                                              ip?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                property maxKeys

                                                                                                                                                                                                                                                                                                                                                                maxKeys?: number | undefined;

                                                                                                                                                                                                                                                                                                                                                                  property overrides

                                                                                                                                                                                                                                                                                                                                                                  overrides?: any;

                                                                                                                                                                                                                                                                                                                                                                    property rate

                                                                                                                                                                                                                                                                                                                                                                    rate?: number | undefined;

                                                                                                                                                                                                                                                                                                                                                                      property setHeaders

                                                                                                                                                                                                                                                                                                                                                                      setHeaders?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                        property tokensTable

                                                                                                                                                                                                                                                                                                                                                                        tokensTable?: any;

                                                                                                                                                                                                                                                                                                                                                                          property username

                                                                                                                                                                                                                                                                                                                                                                          username?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                            property xff

                                                                                                                                                                                                                                                                                                                                                                            xff?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                              interface UrlEncodedBodyParserOptions

                                                                                                                                                                                                                                                                                                                                                                              interface UrlEncodedBodyParserOptions {}

                                                                                                                                                                                                                                                                                                                                                                                property bodyReader

                                                                                                                                                                                                                                                                                                                                                                                bodyReader?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                                  property mapParams

                                                                                                                                                                                                                                                                                                                                                                                  mapParams?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                                    property overrideParams

                                                                                                                                                                                                                                                                                                                                                                                    overrideParams?: boolean | undefined;

                                                                                                                                                                                                                                                                                                                                                                                      type AuditLoggerContext

                                                                                                                                                                                                                                                                                                                                                                                      type AuditLoggerContext = (
                                                                                                                                                                                                                                                                                                                                                                                      req: Request,
                                                                                                                                                                                                                                                                                                                                                                                      res: Response,
                                                                                                                                                                                                                                                                                                                                                                                      route: any,
                                                                                                                                                                                                                                                                                                                                                                                      error: any
                                                                                                                                                                                                                                                                                                                                                                                      ) => any;

                                                                                                                                                                                                                                                                                                                                                                                        type MetricsCallback

                                                                                                                                                                                                                                                                                                                                                                                        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

                                                                                                                                                                                                                                                                                                                                                                                          type TMetricsCallback = 'close' | 'aborted' | undefined;

                                                                                                                                                                                                                                                                                                                                                                                            namespace plugins.pre

                                                                                                                                                                                                                                                                                                                                                                                            namespace plugins.pre {}

                                                                                                                                                                                                                                                                                                                                                                                              function context

                                                                                                                                                                                                                                                                                                                                                                                              context: () => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                              • Provide req.set(key, val) and req.get(key) methods for setting and retrieving context to a specific request.

                                                                                                                                                                                                                                                                                                                                                                                              function dedupeSlashes

                                                                                                                                                                                                                                                                                                                                                                                              dedupeSlashes: () => RequestHandler;

                                                                                                                                                                                                                                                                                                                                                                                                function pause

                                                                                                                                                                                                                                                                                                                                                                                                pause: () => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                • This pre handler fixes issues with node hanging when an asyncHandler is used prior to bodyParser.

                                                                                                                                                                                                                                                                                                                                                                                                function reqIdHeaders

                                                                                                                                                                                                                                                                                                                                                                                                reqIdHeaders: (options: { headers: string[] }) => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                • Automatically reuse incoming request header as the request id.

                                                                                                                                                                                                                                                                                                                                                                                                function sanitizePath

                                                                                                                                                                                                                                                                                                                                                                                                sanitizePath: () => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                • Cleans up duplicate or trailing / on the URL

                                                                                                                                                                                                                                                                                                                                                                                                function strictQueryParams

                                                                                                                                                                                                                                                                                                                                                                                                strictQueryParams: (options?: { message: string }) => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                • Checks req.urls query params with strict key/val format and rejects non-strict requests with status code 400.

                                                                                                                                                                                                                                                                                                                                                                                                function userAgentConnection

                                                                                                                                                                                                                                                                                                                                                                                                userAgentConnection: (options?: { userAgentRegExp: any }) => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                • Regexp to capture curl user-agents

                                                                                                                                                                                                                                                                                                                                                                                                namespace pre

                                                                                                                                                                                                                                                                                                                                                                                                namespace pre {}

                                                                                                                                                                                                                                                                                                                                                                                                  function context

                                                                                                                                                                                                                                                                                                                                                                                                  context: () => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                  • Provide req.set(key, val) and req.get(key) methods for setting and retrieving context to a specific request.

                                                                                                                                                                                                                                                                                                                                                                                                  function dedupeSlashes

                                                                                                                                                                                                                                                                                                                                                                                                  dedupeSlashes: () => RequestHandler;

                                                                                                                                                                                                                                                                                                                                                                                                    function pause

                                                                                                                                                                                                                                                                                                                                                                                                    pause: () => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                    • This pre handler fixes issues with node hanging when an asyncHandler is used prior to bodyParser.

                                                                                                                                                                                                                                                                                                                                                                                                    function reqIdHeaders

                                                                                                                                                                                                                                                                                                                                                                                                    reqIdHeaders: (options: { headers: string[] }) => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                    • Automatically reuse incoming request header as the request id.

                                                                                                                                                                                                                                                                                                                                                                                                    function sanitizePath

                                                                                                                                                                                                                                                                                                                                                                                                    sanitizePath: () => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                    • Cleans up duplicate or trailing / on the URL

                                                                                                                                                                                                                                                                                                                                                                                                    function strictQueryParams

                                                                                                                                                                                                                                                                                                                                                                                                    strictQueryParams: (options?: { message: string }) => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                    • Checks req.urls query params with strict key/val format and rejects non-strict requests with status code 400.

                                                                                                                                                                                                                                                                                                                                                                                                    function userAgentConnection

                                                                                                                                                                                                                                                                                                                                                                                                    userAgentConnection: (options?: { userAgentRegExp: any }) => RequestHandler;
                                                                                                                                                                                                                                                                                                                                                                                                    • Regexp to capture curl user-agents

                                                                                                                                                                                                                                                                                                                                                                                                    Package Files (1)

                                                                                                                                                                                                                                                                                                                                                                                                    Dependencies (4)

                                                                                                                                                                                                                                                                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                                                                                                                                                                                                                                                                    No dev dependencies.

                                                                                                                                                                                                                                                                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                                                                                                                                                                                                                                                                    No peer dependencies.

                                                                                                                                                                                                                                                                                                                                                                                                    Badge

                                                                                                                                                                                                                                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/restify.

                                                                                                                                                                                                                                                                                                                                                                                                    • Markdown
                                                                                                                                                                                                                                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/restify)
                                                                                                                                                                                                                                                                                                                                                                                                    • HTML
                                                                                                                                                                                                                                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/@types/restify"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>