@types/express-serve-static-core

  • Version 4.17.33
  • Published
  • 44.9 kB
  • 3 dependencies
  • MIT license

Install

npm i @types/express-serve-static-core
yarn add @types/express-serve-static-core
pnpm add @types/express-serve-static-core

Overview

TypeScript definitions for Express

Index

Interfaces

interface Application

interface Application<LocalsObj extends Record<string, any> = Record<string, any>>
extends EventEmitter,
IRouter,
Express.Application {}

    property get

    get: ((name: string) => any) & IRouterMatcher<this>;

      property locals

      locals: LocalsObj & Locals;

        property map

        map: any;

          property mountpath

          mountpath: string | string[];
          • The app.mountpath property contains one or more path patterns on which a sub-app was mounted.

          property on

          on: (event: string, callback: (parent: Application) => void) => this;
          • The mount event is fired on a sub-app, when it is mounted on a parent app. The parent app is passed to the callback function.

            NOTE: Sub-apps will: - Not inherit the value of settings that have a default value. You must set the value in the sub-app. - Inherit the value of settings with no default value.

          property resource

          resource: any;

            property router

            router: string;

              property routes

              routes: any;
              • The app.routes object houses all of the routes defined mapped by the associated HTTP verb. This object may be used for introspection capabilities, for example Express uses this internally not only for routing but to provide default OPTIONS behaviour unless app.options() is used. Your application or framework may also remove routes by simply by removing them from this object.

              property settings

              settings: any;

                property use

                use: ApplicationRequestHandler<this>;

                  method defaultConfiguration

                  defaultConfiguration: () => void;
                  • Initialize application configuration.

                  method disable

                  disable: (setting: string) => this;
                  • Disable setting.

                  method disabled

                  disabled: (setting: string) => boolean;
                  • Check if setting is disabled.

                    app.disabled('foo') // => true

                    app.enable('foo') app.disabled('foo') // => false

                  method enable

                  enable: (setting: string) => this;
                  • Enable setting.

                  method enabled

                  enabled: (setting: string) => boolean;
                  • Check if setting is enabled (truthy).

                    app.enabled('foo') // => false

                    app.enable('foo') app.enabled('foo') // => true

                  method engine

                  engine: (
                  ext: string,
                  fn: (
                  path: string,
                  options: object,
                  callback: (e: any, rendered?: string) => void
                  ) => void
                  ) => this;
                  • Register the given template engine callback fn as ext.

                    By default will require() the engine based on the file extension. For example if you try to render a "foo.jade" file Express will invoke the following internally:

                    app.engine('jade', require('jade').__express);

                    For engines that do not provide .__express out of the box, or if you wish to "map" a different extension to the template engine you may use this method. For example mapping the EJS template engine to ".html" files:

                    app.engine('html', require('ejs').renderFile);

                    In this case EJS provides a .renderFile() method with the same signature that Express expects: (path, options, callback), though note that it aliases this method as ejs.__express internally so if you're using ".ejs" extensions you dont need to do anything.

                    Some template engines do not follow this convention, the [Consolidate.js](https://github.com/visionmedia/consolidate.js) library was created to map all of node's popular template engines to follow this convention, thus allowing them to work seamlessly within Express.

                  method init

                  init: () => void;
                  • Initialize the server.

                    - setup default configuration - setup default middleware - setup route reflection methods

                  method listen

                  listen: {
                  (
                  port: number,
                  hostname: string,
                  backlog: number,
                  callback?: () => void
                  ): http.Server;
                  (port: number, hostname: string, callback?: () => void): http.Server;
                  (port: number, callback?: () => void): http.Server;
                  (callback?: () => void): http.Server;
                  (path: string, callback?: () => void): http.Server;
                  (handle: any, listeningListener?: () => void): http.Server;
                  };
                  • Listen for connections.

                    A node http.Server is returned, with this application (which is a Function) as its callback. If you wish to create both an HTTP and HTTPS server you may do so with the "http" and "https" modules as shown here:

                    var http = require('http') , https = require('https') , express = require('express') , app = express();

                    http.createServer(app).listen(80); https.createServer({ ... }, app).listen(443);

                  method param

                  param: {
                  (name: string | string[], handler: RequestParamHandler): this;
                  (callback: (name: string, matcher: RegExp) => RequestParamHandler): this;
                  };
                  • Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param()

                    Deprecated

                    since version 4.11

                  method path

                  path: () => string;
                  • Return the app's absolute pathname based on the parent(s) that have mounted it.

                    For example if the application was mounted as "/admin", which itself was mounted as "/blog" then the return value would be "/blog/admin".

                  method render

                  render: {
                  (
                  name: string,
                  options?: object,
                  callback?: (err: Error, html: string) => void
                  ): void;
                  (name: string, callback: (err: Error, html: string) => void): void;
                  };
                  • Render the given view name name with options and a callback accepting an error and the rendered template string.

                    Example:

                    app.render('email', { name: 'Tobi' }, function(err, html){ // ... })

                  method set

                  set: (setting: string, val: any) => this;
                  • Assign setting to val, or return setting's value.

                    app.set('foo', 'bar'); app.get('foo'); // => "bar" app.set('foo', ['bar', 'baz']); app.get('foo'); // => ["bar", "baz"]

                    Mounted servers inherit their parent server's settings.

                  call signature

                  (req: Request | http.IncomingMessage, res: Response | http.ServerResponse): any;
                  • Express instance itself is a request handler, which could be invoked without third argument.

                  interface ByteRange

                  interface ByteRange {}

                    property end

                    end: number;

                      property start

                      start: number;

                        interface CookieOptions

                        interface CookieOptions {}

                          property domain

                          domain?: string | undefined;

                            property encode

                            encode?: ((val: string) => string) | undefined;

                              property expires

                              expires?: Date | undefined;

                                property httpOnly

                                httpOnly?: boolean | undefined;

                                  property maxAge

                                  maxAge?: number | undefined;

                                    property path

                                    path?: string | undefined;

                                      property sameSite

                                      sameSite?: boolean | 'lax' | 'strict' | 'none' | undefined;

                                        property secure

                                        secure?: boolean | undefined;

                                          property signed

                                          signed?: boolean | undefined;

                                            interface Dictionary

                                            interface Dictionary<T> {}

                                              index signature

                                              [key: string]: T;

                                                interface Express

                                                interface Express extends Application {}

                                                  property request

                                                  request: Request;

                                                    property response

                                                    response: Response;

                                                      interface Handler

                                                      interface Handler extends RequestHandler {}

                                                        interface IRoute

                                                        interface IRoute<Route extends string = string> {}

                                                          property 'm-search'

                                                          'm-search': IRouterHandler<this, Route>;

                                                            property all

                                                            all: IRouterHandler<this, Route>;

                                                              property checkout

                                                              checkout: IRouterHandler<this, Route>;

                                                                property copy

                                                                copy: IRouterHandler<this, Route>;

                                                                  property delete

                                                                  delete: IRouterHandler<this, Route>;

                                                                    property get

                                                                    get: IRouterHandler<this, Route>;

                                                                      property head

                                                                      head: IRouterHandler<this, Route>;

                                                                        property lock

                                                                        lock: IRouterHandler<this, Route>;

                                                                          property merge

                                                                          merge: IRouterHandler<this, Route>;

                                                                            property mkactivity

                                                                            mkactivity: IRouterHandler<this, Route>;

                                                                              property mkcol

                                                                              mkcol: IRouterHandler<this, Route>;

                                                                                property move

                                                                                move: IRouterHandler<this, Route>;

                                                                                  property notify

                                                                                  notify: IRouterHandler<this, Route>;

                                                                                    property options

                                                                                    options: IRouterHandler<this, Route>;

                                                                                      property patch

                                                                                      patch: IRouterHandler<this, Route>;

                                                                                        property path

                                                                                        path: string;

                                                                                          property post

                                                                                          post: IRouterHandler<this, Route>;

                                                                                            property purge

                                                                                            purge: IRouterHandler<this, Route>;

                                                                                              property put

                                                                                              put: IRouterHandler<this, Route>;

                                                                                                property report

                                                                                                report: IRouterHandler<this, Route>;

                                                                                                  property search

                                                                                                  search: IRouterHandler<this, Route>;

                                                                                                    property stack

                                                                                                    stack: any;

                                                                                                      property subscribe

                                                                                                      subscribe: IRouterHandler<this, Route>;

                                                                                                        property trace

                                                                                                        trace: IRouterHandler<this, Route>;

                                                                                                          property unlock

                                                                                                          unlock: IRouterHandler<this, Route>;

                                                                                                            property unsubscribe

                                                                                                            unsubscribe: IRouterHandler<this, Route>;

                                                                                                              interface IRouter

                                                                                                              interface IRouter extends RequestHandler {}

                                                                                                                property 'm-search'

                                                                                                                'm-search': IRouterMatcher<this>;

                                                                                                                  property all

                                                                                                                  all: IRouterMatcher<this, 'all'>;
                                                                                                                  • Special-cased "all" method, applying the given route path, middleware, and callback to _every_ HTTP method.

                                                                                                                  property checkout

                                                                                                                  checkout: IRouterMatcher<this>;

                                                                                                                    property connect

                                                                                                                    connect: IRouterMatcher<this>;

                                                                                                                      property copy

                                                                                                                      copy: IRouterMatcher<this>;

                                                                                                                        property delete

                                                                                                                        delete: IRouterMatcher<this, 'delete'>;

                                                                                                                          property get

                                                                                                                          get: IRouterMatcher<this, 'get'>;

                                                                                                                            property head

                                                                                                                            head: IRouterMatcher<this, 'head'>;

                                                                                                                              property lock

                                                                                                                              lock: IRouterMatcher<this>;

                                                                                                                                property merge

                                                                                                                                merge: IRouterMatcher<this>;

                                                                                                                                  property mkactivity

                                                                                                                                  mkactivity: IRouterMatcher<this>;

                                                                                                                                    property mkcol

                                                                                                                                    mkcol: IRouterMatcher<this>;

                                                                                                                                      property move

                                                                                                                                      move: IRouterMatcher<this>;

                                                                                                                                        property notify

                                                                                                                                        notify: IRouterMatcher<this>;

                                                                                                                                          property options

                                                                                                                                          options: IRouterMatcher<this, 'options'>;

                                                                                                                                            property patch

                                                                                                                                            patch: IRouterMatcher<this, 'patch'>;

                                                                                                                                              property post

                                                                                                                                              post: IRouterMatcher<this, 'post'>;

                                                                                                                                                property propfind

                                                                                                                                                propfind: IRouterMatcher<this>;

                                                                                                                                                  property proppatch

                                                                                                                                                  proppatch: IRouterMatcher<this>;

                                                                                                                                                    property purge

                                                                                                                                                    purge: IRouterMatcher<this>;

                                                                                                                                                      property put

                                                                                                                                                      put: IRouterMatcher<this, 'put'>;

                                                                                                                                                        property report

                                                                                                                                                        report: IRouterMatcher<this>;

                                                                                                                                                          property search

                                                                                                                                                          search: IRouterMatcher<this>;

                                                                                                                                                            property stack

                                                                                                                                                            stack: any[];
                                                                                                                                                            • Stack of configured routes

                                                                                                                                                            property subscribe

                                                                                                                                                            subscribe: IRouterMatcher<this>;

                                                                                                                                                              property trace

                                                                                                                                                              trace: IRouterMatcher<this>;

                                                                                                                                                                property unlock

                                                                                                                                                                unlock: IRouterMatcher<this>;

                                                                                                                                                                  property unsubscribe

                                                                                                                                                                  unsubscribe: IRouterMatcher<this>;

                                                                                                                                                                    property use

                                                                                                                                                                    use: IRouterHandler<this> & IRouterMatcher<this>;

                                                                                                                                                                      method param

                                                                                                                                                                      param: {
                                                                                                                                                                      (name: string, handler: RequestParamHandler): this;
                                                                                                                                                                      (callback: (name: string, matcher: RegExp) => RequestParamHandler): this;
                                                                                                                                                                      };
                                                                                                                                                                      • Map the given param placeholder name(s) to the given callback(s).

                                                                                                                                                                        Parameter mapping is used to provide pre-conditions to routes which use normalized placeholders. For example a _:user_id_ parameter could automatically load a user's information from the database without any additional code,

                                                                                                                                                                        The callback uses the samesignature as middleware, the only differencing being that the value of the placeholder is passed, in this case the _id_ of the user. Once the next() function is invoked, just like middleware it will continue on to execute the route, or subsequent parameter functions.

                                                                                                                                                                        app.param('user_id', function(req, res, next, id){ User.find(id, function(err, user){ if (err) { next(err); } else if (user) { req.user = user; next(); } else { next(new Error('failed to load user')); } }); });

                                                                                                                                                                      • Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param()

                                                                                                                                                                        Deprecated

                                                                                                                                                                        since version 4.11

                                                                                                                                                                      method route

                                                                                                                                                                      route: {
                                                                                                                                                                      <T extends string>(prefix: T): IRoute<T>;
                                                                                                                                                                      (prefix: PathParams): IRoute<string>;
                                                                                                                                                                      };

                                                                                                                                                                        interface IRouterHandler

                                                                                                                                                                        interface IRouterHandler<T, Route extends string = string> {}

                                                                                                                                                                          call signature

                                                                                                                                                                          (...handlers: Array<RequestHandler<RouteParameters<Route>>>): T;

                                                                                                                                                                            call signature

                                                                                                                                                                            (...handlers: Array<RequestHandlerParams<RouteParameters<Route>>>): T;

                                                                                                                                                                              call signature

                                                                                                                                                                              <
                                                                                                                                                                              P = RouteParameters<Route>,
                                                                                                                                                                              ResBody = any,
                                                                                                                                                                              ReqBody = any,
                                                                                                                                                                              ReqQuery = ParsedQs,
                                                                                                                                                                              LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                              >(
                                                                                                                                                                              // (This generic is meant to be passed explicitly.)
                                                                                                                                                                              // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                              ...handlers: Array<RequestHandler<P, ResBody, ReqBody, ReqQuery, LocalsObj>>
                                                                                                                                                                              ): T;

                                                                                                                                                                                call signature

                                                                                                                                                                                <
                                                                                                                                                                                P = RouteParameters<Route>,
                                                                                                                                                                                ResBody = any,
                                                                                                                                                                                ReqBody = any,
                                                                                                                                                                                ReqQuery = ParsedQs,
                                                                                                                                                                                LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                >(
                                                                                                                                                                                // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                ...handlers: Array<
                                                                                                                                                                                RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, LocalsObj>
                                                                                                                                                                                >
                                                                                                                                                                                ): T;

                                                                                                                                                                                  call signature

                                                                                                                                                                                  <
                                                                                                                                                                                  P = ParamsDictionary,
                                                                                                                                                                                  ResBody = any,
                                                                                                                                                                                  ReqBody = any,
                                                                                                                                                                                  ReqQuery = ParsedQs,
                                                                                                                                                                                  LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                  >(
                                                                                                                                                                                  // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                  // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                  ...handlers: Array<RequestHandler<P, ResBody, ReqBody, ReqQuery, LocalsObj>>
                                                                                                                                                                                  ): T;

                                                                                                                                                                                    call signature

                                                                                                                                                                                    <
                                                                                                                                                                                    P = ParamsDictionary,
                                                                                                                                                                                    ResBody = any,
                                                                                                                                                                                    ReqBody = any,
                                                                                                                                                                                    ReqQuery = ParsedQs,
                                                                                                                                                                                    LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                    >(
                                                                                                                                                                                    // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                    // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                    ...handlers: Array<
                                                                                                                                                                                    RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, LocalsObj>
                                                                                                                                                                                    >
                                                                                                                                                                                    ): T;

                                                                                                                                                                                      interface IRouterMatcher

                                                                                                                                                                                      interface IRouterMatcher<
                                                                                                                                                                                      T,
                                                                                                                                                                                      Method extends
                                                                                                                                                                                      | 'all'
                                                                                                                                                                                      | 'get'
                                                                                                                                                                                      | 'post'
                                                                                                                                                                                      | 'put'
                                                                                                                                                                                      | 'delete'
                                                                                                                                                                                      | 'patch'
                                                                                                                                                                                      | 'options'
                                                                                                                                                                                      | 'head' = any
                                                                                                                                                                                      > {}

                                                                                                                                                                                        call signature

                                                                                                                                                                                        <
                                                                                                                                                                                        Route extends string,
                                                                                                                                                                                        P = RouteParameters<Route>,
                                                                                                                                                                                        ResBody = any,
                                                                                                                                                                                        ReqBody = any,
                                                                                                                                                                                        ReqQuery = ParsedQs,
                                                                                                                                                                                        LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                        >(
                                                                                                                                                                                        // (it's used as the default type parameter for P)
                                                                                                                                                                                        // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                        path: Route,
                                                                                                                                                                                        // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                        // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                        ...handlers: Array<RequestHandler<P, ResBody, ReqBody, ReqQuery, LocalsObj>>
                                                                                                                                                                                        ): T;

                                                                                                                                                                                          call signature

                                                                                                                                                                                          <
                                                                                                                                                                                          Path extends string,
                                                                                                                                                                                          P = RouteParameters<Path>,
                                                                                                                                                                                          ResBody = any,
                                                                                                                                                                                          ReqBody = any,
                                                                                                                                                                                          ReqQuery = ParsedQs,
                                                                                                                                                                                          LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                          >(
                                                                                                                                                                                          // (it's used as the default type parameter for P)
                                                                                                                                                                                          // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                          path: Path,
                                                                                                                                                                                          // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                          // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                          ...handlers: Array<
                                                                                                                                                                                          RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, LocalsObj>
                                                                                                                                                                                          >
                                                                                                                                                                                          ): T;

                                                                                                                                                                                            call signature

                                                                                                                                                                                            <
                                                                                                                                                                                            P = ParamsDictionary,
                                                                                                                                                                                            ResBody = any,
                                                                                                                                                                                            ReqBody = any,
                                                                                                                                                                                            ReqQuery = ParsedQs,
                                                                                                                                                                                            LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                            >(
                                                                                                                                                                                            path: PathParams,
                                                                                                                                                                                            // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                            // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                            ...handlers: Array<RequestHandler<P, ResBody, ReqBody, ReqQuery, LocalsObj>>
                                                                                                                                                                                            ): T;

                                                                                                                                                                                              call signature

                                                                                                                                                                                              <
                                                                                                                                                                                              P = ParamsDictionary,
                                                                                                                                                                                              ResBody = any,
                                                                                                                                                                                              ReqBody = any,
                                                                                                                                                                                              ReqQuery = ParsedQs,
                                                                                                                                                                                              LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                              >(
                                                                                                                                                                                              path: PathParams,
                                                                                                                                                                                              // (This generic is meant to be passed explicitly.)
                                                                                                                                                                                              // eslint-disable-next-line no-unnecessary-generics
                                                                                                                                                                                              ...handlers: Array<
                                                                                                                                                                                              RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, LocalsObj>
                                                                                                                                                                                              >
                                                                                                                                                                                              ): T;

                                                                                                                                                                                                call signature

                                                                                                                                                                                                (path: PathParams, subApplication: Application): T;

                                                                                                                                                                                                  interface Locals

                                                                                                                                                                                                  interface Locals extends Express.Locals {}

                                                                                                                                                                                                    interface MediaType

                                                                                                                                                                                                    interface MediaType {}

                                                                                                                                                                                                      property quality

                                                                                                                                                                                                      quality: number;

                                                                                                                                                                                                        property subtype

                                                                                                                                                                                                        subtype: string;

                                                                                                                                                                                                          property type

                                                                                                                                                                                                          type: string;

                                                                                                                                                                                                            property value

                                                                                                                                                                                                            value: string;

                                                                                                                                                                                                              interface NextFunction

                                                                                                                                                                                                              interface NextFunction {}

                                                                                                                                                                                                                call signature

                                                                                                                                                                                                                (err?: any): void;

                                                                                                                                                                                                                  call signature

                                                                                                                                                                                                                  (deferToNext: 'router'): void;
                                                                                                                                                                                                                  • "Break-out" of a router by calling {next('router')};

                                                                                                                                                                                                                    See Also

                                                                                                                                                                                                                    • {https://expressjs.com/en/guide/using-middleware.html#middleware.router}

                                                                                                                                                                                                                  call signature

                                                                                                                                                                                                                  (deferToNext: 'route'): void;
                                                                                                                                                                                                                  • "Break-out" of a route by calling {next('route')};

                                                                                                                                                                                                                    See Also

                                                                                                                                                                                                                    • {https://expressjs.com/en/guide/using-middleware.html#middleware.application}

                                                                                                                                                                                                                  interface ParamsDictionary

                                                                                                                                                                                                                  interface ParamsDictionary {}

                                                                                                                                                                                                                    index signature

                                                                                                                                                                                                                    [key: string]: string;

                                                                                                                                                                                                                      interface Request

                                                                                                                                                                                                                      interface Request<
                                                                                                                                                                                                                      P = ParamsDictionary,
                                                                                                                                                                                                                      ResBody = any,
                                                                                                                                                                                                                      ReqBody = any,
                                                                                                                                                                                                                      ReqQuery = ParsedQs,
                                                                                                                                                                                                                      LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                                                      > extends http.IncomingMessage,
                                                                                                                                                                                                                      Express.Request {}
                                                                                                                                                                                                                      • Parameter P

                                                                                                                                                                                                                        For most requests, this should be ParamsDictionary, but if you're using this in a route handler for a route that uses a RegExp or a wildcard string path (e.g. '/user/*'), then req.params will be an array, in which case you should use ParamsArray instead.

                                                                                                                                                                                                                        Example 1

                                                                                                                                                                                                                        app.get('/user/:id', (req, res) => res.send(req.params.id)); // implicitly ParamsDictionary app.get(/user/(.*)/, (req, res) => res.send(req.params[0])); app.get('/user/*', (req, res) => res.send(req.params[0]));

                                                                                                                                                                                                                        See Also

                                                                                                                                                                                                                        • https://expressjs.com/en/api.html#req.params

                                                                                                                                                                                                                      property accepted

                                                                                                                                                                                                                      accepted: MediaType[];
                                                                                                                                                                                                                      • Return an array of Accepted media types ordered from highest quality to lowest.

                                                                                                                                                                                                                      property app

                                                                                                                                                                                                                      app: Application;

                                                                                                                                                                                                                        property baseUrl

                                                                                                                                                                                                                        baseUrl: string;

                                                                                                                                                                                                                          property body

                                                                                                                                                                                                                          body: ReqBody;

                                                                                                                                                                                                                            property cookies

                                                                                                                                                                                                                            cookies: any;

                                                                                                                                                                                                                              property fresh

                                                                                                                                                                                                                              fresh: boolean;
                                                                                                                                                                                                                              • Check if the request is fresh, aka Last-Modified and/or the ETag still match.

                                                                                                                                                                                                                              property host

                                                                                                                                                                                                                              host: string;
                                                                                                                                                                                                                              • Deprecated

                                                                                                                                                                                                                                Use hostname instead.

                                                                                                                                                                                                                              property hostname

                                                                                                                                                                                                                              hostname: string;
                                                                                                                                                                                                                              • Parse the "Host" header field hostname.

                                                                                                                                                                                                                              property ip

                                                                                                                                                                                                                              ip: string;
                                                                                                                                                                                                                              • Return the remote address, or when "trust proxy" is true return the upstream addr.

                                                                                                                                                                                                                              property ips

                                                                                                                                                                                                                              ips: string[];
                                                                                                                                                                                                                              • When "trust proxy" is true, parse the "X-Forwarded-For" ip address list.

                                                                                                                                                                                                                                For example if the value were "client, proxy1, proxy2" you would receive the array ["client", "proxy1", "proxy2"] where "proxy2" is the furthest down-stream.

                                                                                                                                                                                                                              property method

                                                                                                                                                                                                                              method: string;

                                                                                                                                                                                                                                property next

                                                                                                                                                                                                                                next?: NextFunction | undefined;

                                                                                                                                                                                                                                  property originalUrl

                                                                                                                                                                                                                                  originalUrl: string;

                                                                                                                                                                                                                                    property params

                                                                                                                                                                                                                                    params: P;

                                                                                                                                                                                                                                      property path

                                                                                                                                                                                                                                      path: string;
                                                                                                                                                                                                                                      • Short-hand for url.parse(req.url).pathname.

                                                                                                                                                                                                                                      property protocol

                                                                                                                                                                                                                                      protocol: string;
                                                                                                                                                                                                                                      • Return the protocol string "http" or "https" when requested with TLS. When the "trust proxy" setting is enabled the "X-Forwarded-Proto" header field will be trusted. If you're running behind a reverse proxy that supplies https for you this may be enabled.

                                                                                                                                                                                                                                      property query

                                                                                                                                                                                                                                      query: ReqQuery;

                                                                                                                                                                                                                                        property res

                                                                                                                                                                                                                                        res?: Response<ResBody, LocalsObj> | undefined;
                                                                                                                                                                                                                                        • After middleware.init executed, Request will contain res and next properties See: express/lib/middleware/init.js

                                                                                                                                                                                                                                        property route

                                                                                                                                                                                                                                        route: any;

                                                                                                                                                                                                                                          property secure

                                                                                                                                                                                                                                          secure: boolean;
                                                                                                                                                                                                                                          • Short-hand for:

                                                                                                                                                                                                                                            req.protocol == 'https'

                                                                                                                                                                                                                                          property signedCookies

                                                                                                                                                                                                                                          signedCookies: any;

                                                                                                                                                                                                                                            property stale

                                                                                                                                                                                                                                            stale: boolean;
                                                                                                                                                                                                                                            • Check if the request is stale, aka "Last-Modified" and / or the "ETag" for the resource has changed.

                                                                                                                                                                                                                                            property subdomains

                                                                                                                                                                                                                                            subdomains: string[];
                                                                                                                                                                                                                                            • Return subdomains as an array.

                                                                                                                                                                                                                                              Subdomains are the dot-separated parts of the host before the main domain of the app. By default, the domain of the app is assumed to be the last two parts of the host. This can be changed by setting "subdomain offset".

                                                                                                                                                                                                                                              For example, if the domain is "tobi.ferrets.example.com": If "subdomain offset" is not set, req.subdomains is ["ferrets", "tobi"]. If "subdomain offset" is 3, req.subdomains is ["tobi"].

                                                                                                                                                                                                                                            property url

                                                                                                                                                                                                                                            url: string;

                                                                                                                                                                                                                                              property xhr

                                                                                                                                                                                                                                              xhr: boolean;
                                                                                                                                                                                                                                              • Check if the request was an _XMLHttpRequest_.

                                                                                                                                                                                                                                              method accepts

                                                                                                                                                                                                                                              accepts: {
                                                                                                                                                                                                                                              (): string[];
                                                                                                                                                                                                                                              (type: string): string | false;
                                                                                                                                                                                                                                              (type: string[]): string | false;
                                                                                                                                                                                                                                              (...type: string[]): string | false;
                                                                                                                                                                                                                                              };
                                                                                                                                                                                                                                              • Check if the given type(s) is acceptable, returning the best match when true, otherwise undefined, in which case you should respond with 406 "Not Acceptable".

                                                                                                                                                                                                                                                The type value may be a single mime type string such as "application/json", the extension name such as "json", a comma-delimted list such as "json, html, text/plain", or an array ["json", "html", "text/plain"]. When a list or array is given the _best_ match, if any is returned.

                                                                                                                                                                                                                                                Examples:

                                                                                                                                                                                                                                                // Accept: text/html req.accepts('html'); // => "html"

                                                                                                                                                                                                                                                // Accept: text/*, application/json req.accepts('html'); // => "html" req.accepts('text/html'); // => "text/html" req.accepts('json, text'); // => "json" req.accepts('application/json'); // => "application/json"

                                                                                                                                                                                                                                                // Accept: text/*, application/json req.accepts('image/png'); req.accepts('png'); // => undefined

                                                                                                                                                                                                                                                // Accept: text/*;q=.5, application/json req.accepts(['html', 'json']); req.accepts('html, json'); // => "json"

                                                                                                                                                                                                                                              method acceptsCharsets

                                                                                                                                                                                                                                              acceptsCharsets: {
                                                                                                                                                                                                                                              (): string[];
                                                                                                                                                                                                                                              (charset: string): string | false;
                                                                                                                                                                                                                                              (charset: string[]): string | false;
                                                                                                                                                                                                                                              (...charset: string[]): string | false;
                                                                                                                                                                                                                                              };
                                                                                                                                                                                                                                              • Returns the first accepted charset of the specified character sets, based on the request's Accept-Charset HTTP header field. If none of the specified charsets is accepted, returns false.

                                                                                                                                                                                                                                                For more information, or if you have issues or concerns, see accepts.

                                                                                                                                                                                                                                              method acceptsEncodings

                                                                                                                                                                                                                                              acceptsEncodings: {
                                                                                                                                                                                                                                              (): string[];
                                                                                                                                                                                                                                              (encoding: string): string | false;
                                                                                                                                                                                                                                              (encoding: string[]): string | false;
                                                                                                                                                                                                                                              (...encoding: string[]): string | false;
                                                                                                                                                                                                                                              };
                                                                                                                                                                                                                                              • Returns the first accepted encoding of the specified encodings, based on the request's Accept-Encoding HTTP header field. If none of the specified encodings is accepted, returns false.

                                                                                                                                                                                                                                                For more information, or if you have issues or concerns, see accepts.

                                                                                                                                                                                                                                              method acceptsLanguages

                                                                                                                                                                                                                                              acceptsLanguages: {
                                                                                                                                                                                                                                              (): string[];
                                                                                                                                                                                                                                              (lang: string): string | false;
                                                                                                                                                                                                                                              (lang: string[]): string | false;
                                                                                                                                                                                                                                              (...lang: string[]): string | false;
                                                                                                                                                                                                                                              };
                                                                                                                                                                                                                                              • Returns the first accepted language of the specified languages, based on the request's Accept-Language HTTP header field. If none of the specified languages is accepted, returns false.

                                                                                                                                                                                                                                                For more information, or if you have issues or concerns, see accepts.

                                                                                                                                                                                                                                              method get

                                                                                                                                                                                                                                              get: { (name: 'set-cookie'): string[] | undefined; (name: string): string };
                                                                                                                                                                                                                                              • Return request header.

                                                                                                                                                                                                                                                The Referrer header field is special-cased, both Referrer and Referer are interchangeable.

                                                                                                                                                                                                                                                Examples:

                                                                                                                                                                                                                                                req.get('Content-Type'); // => "text/plain"

                                                                                                                                                                                                                                                req.get('content-type'); // => "text/plain"

                                                                                                                                                                                                                                                req.get('Something'); // => undefined

                                                                                                                                                                                                                                                Aliased as req.header().

                                                                                                                                                                                                                                              method header

                                                                                                                                                                                                                                              header: { (name: 'set-cookie'): string[] | undefined; (name: string): string };

                                                                                                                                                                                                                                                method is

                                                                                                                                                                                                                                                is: (type: string | string[]) => string | false | null;
                                                                                                                                                                                                                                                • Check if the incoming request contains the "Content-Type" header field, and it contains the give mime type.

                                                                                                                                                                                                                                                  Examples:

                                                                                                                                                                                                                                                  // With Content-Type: text/html; charset=utf-8 req.is('html'); req.is('text/html'); req.is('text/*'); // => true

                                                                                                                                                                                                                                                  // When Content-Type is application/json req.is('json'); req.is('application/json'); req.is('application/*'); // => true

                                                                                                                                                                                                                                                  req.is('html'); // => false

                                                                                                                                                                                                                                                method param

                                                                                                                                                                                                                                                param: (name: string, defaultValue?: any) => string;
                                                                                                                                                                                                                                                • Deprecated

                                                                                                                                                                                                                                                  since 4.11 Use either req.params, req.body or req.query, as applicable.

                                                                                                                                                                                                                                                  Return the value of param name when present or defaultValue.

                                                                                                                                                                                                                                                  - Checks route placeholders, ex: _/user/:id_ - Checks body params, ex: id=12, {"id":12} - Checks query string params, ex: ?id=12

                                                                                                                                                                                                                                                  To utilize request bodies, req.body should be an object. This can be done by using the connect.bodyParser() middleware.

                                                                                                                                                                                                                                                method range

                                                                                                                                                                                                                                                range: (
                                                                                                                                                                                                                                                size: number,
                                                                                                                                                                                                                                                options?: RangeParserOptions
                                                                                                                                                                                                                                                ) => RangeParserRanges | RangeParserResult | undefined;
                                                                                                                                                                                                                                                • Parse Range header field, capping to the given size.

                                                                                                                                                                                                                                                  Unspecified ranges such as "0-" require knowledge of your resource length. In the case of a byte range this is of course the total number of bytes. If the Range header field is not given undefined is returned. If the Range header field is given, return value is a result of range-parser. See more ./types/range-parser/index.d.ts

                                                                                                                                                                                                                                                  NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" should respond with 4 users when available, not 3.

                                                                                                                                                                                                                                                interface RequestHandler

                                                                                                                                                                                                                                                interface RequestHandler<
                                                                                                                                                                                                                                                P = ParamsDictionary,
                                                                                                                                                                                                                                                ResBody = any,
                                                                                                                                                                                                                                                ReqBody = any,
                                                                                                                                                                                                                                                ReqQuery = ParsedQs,
                                                                                                                                                                                                                                                LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                                                                                > {}

                                                                                                                                                                                                                                                  call signature

                                                                                                                                                                                                                                                  (
                                                                                                                                                                                                                                                  req: Request<P, ResBody, ReqBody, ReqQuery, LocalsObj>,
                                                                                                                                                                                                                                                  res: Response<ResBody, LocalsObj>,
                                                                                                                                                                                                                                                  next: NextFunction
                                                                                                                                                                                                                                                  ): void;

                                                                                                                                                                                                                                                    interface RequestRanges

                                                                                                                                                                                                                                                    interface RequestRanges extends RangeParserRanges {}

                                                                                                                                                                                                                                                      interface Response

                                                                                                                                                                                                                                                      interface Response<
                                                                                                                                                                                                                                                      ResBody = any,
                                                                                                                                                                                                                                                      LocalsObj extends Record<string, any> = Record<string, any>,
                                                                                                                                                                                                                                                      StatusCode extends number = number
                                                                                                                                                                                                                                                      > extends http.ServerResponse,
                                                                                                                                                                                                                                                      Express.Response {}

                                                                                                                                                                                                                                                        property app

                                                                                                                                                                                                                                                        app: Application;

                                                                                                                                                                                                                                                          property charset

                                                                                                                                                                                                                                                          charset: string;

                                                                                                                                                                                                                                                            property headersSent

                                                                                                                                                                                                                                                            headersSent: boolean;

                                                                                                                                                                                                                                                              property json

                                                                                                                                                                                                                                                              json: Send<ResBody, this>;
                                                                                                                                                                                                                                                              • Send JSON response.

                                                                                                                                                                                                                                                                Examples:

                                                                                                                                                                                                                                                                res.json(null); res.json({ user: 'tj' }); res.status(500).json('oh noes!'); res.status(404).json('I dont have that');

                                                                                                                                                                                                                                                              property jsonp

                                                                                                                                                                                                                                                              jsonp: Send<ResBody, this>;
                                                                                                                                                                                                                                                              • Send JSON response with JSONP callback support.

                                                                                                                                                                                                                                                                Examples:

                                                                                                                                                                                                                                                                res.jsonp(null); res.jsonp({ user: 'tj' }); res.status(500).jsonp('oh noes!'); res.status(404).jsonp('I dont have that');

                                                                                                                                                                                                                                                              property locals

                                                                                                                                                                                                                                                              locals: LocalsObj & Locals;

                                                                                                                                                                                                                                                                property req

                                                                                                                                                                                                                                                                req: Request;
                                                                                                                                                                                                                                                                • After middleware.init executed, Response will contain req property See: express/lib/middleware/init.js

                                                                                                                                                                                                                                                                property send

                                                                                                                                                                                                                                                                send: Send<ResBody, this>;
                                                                                                                                                                                                                                                                • Send a response.

                                                                                                                                                                                                                                                                  Examples:

                                                                                                                                                                                                                                                                  res.send(new Buffer('wahoo')); res.send({ some: 'json' }); res.send('some html'); res.status(404).send('Sorry, cant find that');

                                                                                                                                                                                                                                                                method append

                                                                                                                                                                                                                                                                append: (field: string, value?: string[] | string) => this;
                                                                                                                                                                                                                                                                • Appends the specified value to the HTTP response header field. If the header is not already set, it creates the header with the specified value. The value parameter can be a string or an array.

                                                                                                                                                                                                                                                                  Note: calling res.set() after res.append() will reset the previously-set header value.

                                                                                                                                                                                                                                                                  4.11.0

                                                                                                                                                                                                                                                                method attachment

                                                                                                                                                                                                                                                                attachment: (filename?: string) => this;
                                                                                                                                                                                                                                                                • Set _Content-Disposition_ header to _attachment_ with optional filename.

                                                                                                                                                                                                                                                                method clearCookie

                                                                                                                                                                                                                                                                clearCookie: (name: string, options?: CookieOptions) => this;
                                                                                                                                                                                                                                                                • Clear cookie name.

                                                                                                                                                                                                                                                                method contentType

                                                                                                                                                                                                                                                                contentType: (type: string) => this;
                                                                                                                                                                                                                                                                • Set _Content-Type_ response header with type through mime.lookup() when it does not contain "/", or set the Content-Type to type otherwise.

                                                                                                                                                                                                                                                                  Examples:

                                                                                                                                                                                                                                                                  res.type('.html'); res.type('html'); res.type('json'); res.type('application/json'); res.type('png');

                                                                                                                                                                                                                                                                method cookie

                                                                                                                                                                                                                                                                cookie: {
                                                                                                                                                                                                                                                                (name: string, val: string, options: CookieOptions): this;
                                                                                                                                                                                                                                                                (name: string, val: any, options: CookieOptions): this;
                                                                                                                                                                                                                                                                (name: string, val: any): this;
                                                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                                                • Set cookie name to val, with the given options.

                                                                                                                                                                                                                                                                  Options:

                                                                                                                                                                                                                                                                  - maxAge max-age in milliseconds, converted to expires - signed sign the cookie - path defaults to "/"

                                                                                                                                                                                                                                                                  Examples:

                                                                                                                                                                                                                                                                  // "Remember Me" for 15 minutes res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });

                                                                                                                                                                                                                                                                  // save as above res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })

                                                                                                                                                                                                                                                                method download

                                                                                                                                                                                                                                                                download: {
                                                                                                                                                                                                                                                                (path: string, fn?: Errback): void;
                                                                                                                                                                                                                                                                (path: string, filename: string, fn?: Errback): void;
                                                                                                                                                                                                                                                                (path: string, filename: string, options: any, fn?: Errback): void;
                                                                                                                                                                                                                                                                };
                                                                                                                                                                                                                                                                • Transfer the file at the given path as an attachment.

                                                                                                                                                                                                                                                                  Optionally providing an alternate attachment filename, and optional callback fn(err). The callback is invoked when the data transfer is complete, or when an error has ocurred. Be sure to check res.headersSent if you plan to respond.

                                                                                                                                                                                                                                                                  The optional options argument passes through to the underlying res.sendFile() call, and takes the exact same parameters.

                                                                                                                                                                                                                                                                  This method uses res.sendfile().

                                                                                                                                                                                                                                                                method format

                                                                                                                                                                                                                                                                format: (obj: any) => this;
                                                                                                                                                                                                                                                                • Respond to the Acceptable formats using an obj of mime-type callbacks.

                                                                                                                                                                                                                                                                  This method uses req.accepted, an array of acceptable types ordered by their quality values. When "Accept" is not present the _first_ callback is invoked, otherwise the first match is used. When no match is performed the server responds with 406 "Not Acceptable".

                                                                                                                                                                                                                                                                  Content-Type is set for you, however if you choose you may alter this within the callback using res.type() or res.set('Content-Type', ...).

                                                                                                                                                                                                                                                                  res.format({ 'text/plain': function(){ res.send('hey'); },

                                                                                                                                                                                                                                                                  'text/html': function(){ res.send('hey'); },

                                                                                                                                                                                                                                                                  'appliation/json': function(){ res.send({ message: 'hey' }); } });

                                                                                                                                                                                                                                                                  In addition to canonicalized MIME types you may also use extnames mapped to these types:

                                                                                                                                                                                                                                                                  res.format({ text: function(){ res.send('hey'); },

                                                                                                                                                                                                                                                                  html: function(){ res.send('hey'); },

                                                                                                                                                                                                                                                                  json: function(){ res.send({ message: 'hey' }); } });

                                                                                                                                                                                                                                                                  By default Express passes an Error with a .status of 406 to next(err) if a match is not made. If you provide a .default callback it will be invoked instead.

                                                                                                                                                                                                                                                                method get

                                                                                                                                                                                                                                                                get: (field: string) => string | undefined;
                                                                                                                                                                                                                                                                • Get value for header field.

                                                                                                                                                                                                                                                                method header

                                                                                                                                                                                                                                                                header: { (field: any): this; (field: string, value?: string | string[]): this };
                                                                                                                                                                                                                                                                  links: (links: any) => this;
                                                                                                                                                                                                                                                                  • Set Link header field with the given links.

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' });

                                                                                                                                                                                                                                                                  method location

                                                                                                                                                                                                                                                                  location: (url: string) => this;
                                                                                                                                                                                                                                                                  • Set the location header to url.

                                                                                                                                                                                                                                                                    The given url can also be the name of a mapped url, for example by default express supports "back" which redirects to the _Referrer_ or _Referer_ headers or "/".

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    res.location('/foo/bar').; res.location('http://example.com'); res.location('../login'); // /blog/post/1 -> /blog/login

                                                                                                                                                                                                                                                                    Mounting:

                                                                                                                                                                                                                                                                    When an application is mounted and res.location() is given a path that does _not_ lead with "/" it becomes relative to the mount-point. For example if the application is mounted at "/blog", the following would become "/blog/login".

                                                                                                                                                                                                                                                                    res.location('login');

                                                                                                                                                                                                                                                                    While the leading slash would result in a location of "/login":

                                                                                                                                                                                                                                                                    res.location('/login');

                                                                                                                                                                                                                                                                  method redirect

                                                                                                                                                                                                                                                                  redirect: {
                                                                                                                                                                                                                                                                  (url: string): void;
                                                                                                                                                                                                                                                                  (status: number, url: string): void;
                                                                                                                                                                                                                                                                  (url: string, status: number): void;
                                                                                                                                                                                                                                                                  };
                                                                                                                                                                                                                                                                  • Redirect to the given url with optional response status defaulting to 302.

                                                                                                                                                                                                                                                                    The resulting url is determined by res.location(), so it will play nicely with mounted apps, relative paths, "back" etc.

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    res.redirect('back'); res.redirect('/foo/bar'); res.redirect('http://example.com'); res.redirect(301, 'http://example.com'); res.redirect('http://example.com', 301); res.redirect('../login'); // /blog/post/1 -> /blog/login

                                                                                                                                                                                                                                                                  • Deprecated

                                                                                                                                                                                                                                                                    use res.redirect(status, url) instead

                                                                                                                                                                                                                                                                  method render

                                                                                                                                                                                                                                                                  render: {
                                                                                                                                                                                                                                                                  (
                                                                                                                                                                                                                                                                  view: string,
                                                                                                                                                                                                                                                                  options?: object,
                                                                                                                                                                                                                                                                  callback?: (err: Error, html: string) => void
                                                                                                                                                                                                                                                                  ): void;
                                                                                                                                                                                                                                                                  (view: string, callback?: (err: Error, html: string) => void): void;
                                                                                                                                                                                                                                                                  };
                                                                                                                                                                                                                                                                  • Render view with the given options and optional callback fn. When a callback function is given a response will _not_ be made automatically, otherwise a response of _200_ and _text/html_ is given.

                                                                                                                                                                                                                                                                    Options:

                                                                                                                                                                                                                                                                    - cache boolean hinting to the engine it should cache - filename filename of the view being rendered

                                                                                                                                                                                                                                                                  method sendfile

                                                                                                                                                                                                                                                                  sendfile: {
                                                                                                                                                                                                                                                                  (path: string): void;
                                                                                                                                                                                                                                                                  (path: string, options: any): void;
                                                                                                                                                                                                                                                                  (path: string, fn: Errback): void;
                                                                                                                                                                                                                                                                  (path: string, options: any, fn: Errback): void;
                                                                                                                                                                                                                                                                  };
                                                                                                                                                                                                                                                                  • Deprecated

                                                                                                                                                                                                                                                                    Use sendFile instead.

                                                                                                                                                                                                                                                                  method sendFile

                                                                                                                                                                                                                                                                  sendFile: {
                                                                                                                                                                                                                                                                  (path: string, fn?: Errback): void;
                                                                                                                                                                                                                                                                  (path: string, options: any, fn?: Errback): void;
                                                                                                                                                                                                                                                                  };
                                                                                                                                                                                                                                                                  • Transfer the file at the given path.

                                                                                                                                                                                                                                                                    Automatically sets the _Content-Type_ response header field. The callback fn(err) is invoked when the transfer is complete or when an error occurs. Be sure to check res.headersSent if you wish to attempt responding, as the header and some data may have already been transferred.

                                                                                                                                                                                                                                                                    Options:

                                                                                                                                                                                                                                                                    - maxAge defaulting to 0 (can be string converted by ms) - root root directory for relative filenames - headers object of headers to serve with file - dotfiles serve dotfiles, defaulting to false; can be "allow" to send them

                                                                                                                                                                                                                                                                    Other options are passed along to send.

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    The following example illustrates how res.sendFile() may be used as an alternative for the static() middleware for dynamic situations. The code backing res.sendFile() is actually the same code, so HTTP cache support etc is identical.

                                                                                                                                                                                                                                                                    app.get('/user/:uid/photos/:file', function(req, res){ var uid = req.params.uid , file = req.params.file;

                                                                                                                                                                                                                                                                    req.user.mayViewFilesFrom(uid, function(yes){ if (yes) { res.sendFile('/uploads/' + uid + '/' + file); } else { res.send(403, 'Sorry! you cant see that.'); } }); });

                                                                                                                                                                                                                                                                    public

                                                                                                                                                                                                                                                                  method sendStatus

                                                                                                                                                                                                                                                                  sendStatus: (code: StatusCode) => this;
                                                                                                                                                                                                                                                                  • Set the response HTTP status code to statusCode and send its string representation as the response body. http://expressjs.com/4x/api.html#res.sendStatus

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    res.sendStatus(200); // equivalent to res.status(200).send('OK') res.sendStatus(403); // equivalent to res.status(403).send('Forbidden') res.sendStatus(404); // equivalent to res.status(404).send('Not Found') res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')

                                                                                                                                                                                                                                                                  method set

                                                                                                                                                                                                                                                                  set: { (field: any): this; (field: string, value?: string | string[]): this };
                                                                                                                                                                                                                                                                  • Set header field to val, or pass an object of header fields.

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    res.set('Foo', ['bar', 'baz']); res.set('Accept', 'application/json'); res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });

                                                                                                                                                                                                                                                                    Aliased as res.header().

                                                                                                                                                                                                                                                                  method status

                                                                                                                                                                                                                                                                  status: (code: StatusCode) => this;
                                                                                                                                                                                                                                                                  • Set status code.

                                                                                                                                                                                                                                                                  method type

                                                                                                                                                                                                                                                                  type: (type: string) => this;
                                                                                                                                                                                                                                                                  • Set _Content-Type_ response header with type through mime.lookup() when it does not contain "/", or set the Content-Type to type otherwise.

                                                                                                                                                                                                                                                                    Examples:

                                                                                                                                                                                                                                                                    res.type('.html'); res.type('html'); res.type('json'); res.type('application/json'); res.type('png');

                                                                                                                                                                                                                                                                  method vary

                                                                                                                                                                                                                                                                  vary: (field: string) => this;
                                                                                                                                                                                                                                                                  • Adds the field to the Vary response header, if it is not there already. Examples:

                                                                                                                                                                                                                                                                    res.vary('User-Agent').render('docs');

                                                                                                                                                                                                                                                                  interface Router

                                                                                                                                                                                                                                                                  interface Router extends IRouter {}

                                                                                                                                                                                                                                                                    Type Aliases

                                                                                                                                                                                                                                                                    type ApplicationRequestHandler

                                                                                                                                                                                                                                                                    type ApplicationRequestHandler<T> = IRouterHandler<T> &
                                                                                                                                                                                                                                                                    IRouterMatcher<T> &
                                                                                                                                                                                                                                                                    ((...handlers: RequestHandlerParams[]) => T);

                                                                                                                                                                                                                                                                      type Errback

                                                                                                                                                                                                                                                                      type Errback = (err: Error) => void;

                                                                                                                                                                                                                                                                        type ErrorRequestHandler

                                                                                                                                                                                                                                                                        type ErrorRequestHandler<
                                                                                                                                                                                                                                                                        P = ParamsDictionary,
                                                                                                                                                                                                                                                                        ResBody = any,
                                                                                                                                                                                                                                                                        ReqBody = any,
                                                                                                                                                                                                                                                                        ReqQuery = ParsedQs,
                                                                                                                                                                                                                                                                        LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                                                                                                        > = (
                                                                                                                                                                                                                                                                        err: any,
                                                                                                                                                                                                                                                                        req: Request<P, ResBody, ReqBody, ReqQuery, LocalsObj>,
                                                                                                                                                                                                                                                                        res: Response<ResBody, LocalsObj>,
                                                                                                                                                                                                                                                                        next: NextFunction
                                                                                                                                                                                                                                                                        ) => void;

                                                                                                                                                                                                                                                                          type Params

                                                                                                                                                                                                                                                                          type Params = ParamsDictionary | ParamsArray;

                                                                                                                                                                                                                                                                            type ParamsArray

                                                                                                                                                                                                                                                                            type ParamsArray = string[];

                                                                                                                                                                                                                                                                              type PathParams

                                                                                                                                                                                                                                                                              type PathParams = string | RegExp | Array<string | RegExp>;

                                                                                                                                                                                                                                                                                type Query

                                                                                                                                                                                                                                                                                type Query = ParsedQs;

                                                                                                                                                                                                                                                                                  type RequestHandlerParams

                                                                                                                                                                                                                                                                                  type RequestHandlerParams<
                                                                                                                                                                                                                                                                                  P = ParamsDictionary,
                                                                                                                                                                                                                                                                                  ResBody = any,
                                                                                                                                                                                                                                                                                  ReqBody = any,
                                                                                                                                                                                                                                                                                  ReqQuery = ParsedQs,
                                                                                                                                                                                                                                                                                  LocalsObj extends Record<string, any> = Record<string, any>
                                                                                                                                                                                                                                                                                  > =
                                                                                                                                                                                                                                                                                  | RequestHandler<P, ResBody, ReqBody, ReqQuery, LocalsObj>
                                                                                                                                                                                                                                                                                  | ErrorRequestHandler<P, ResBody, ReqBody, ReqQuery, LocalsObj>
                                                                                                                                                                                                                                                                                  | Array<RequestHandler<P> | ErrorRequestHandler<P>>;

                                                                                                                                                                                                                                                                                    type RequestParamHandler

                                                                                                                                                                                                                                                                                    type RequestParamHandler = (
                                                                                                                                                                                                                                                                                    req: Request,
                                                                                                                                                                                                                                                                                    res: Response,
                                                                                                                                                                                                                                                                                    next: NextFunction,
                                                                                                                                                                                                                                                                                    value: any,
                                                                                                                                                                                                                                                                                    name: string
                                                                                                                                                                                                                                                                                    ) => any;

                                                                                                                                                                                                                                                                                      type RouteParameters

                                                                                                                                                                                                                                                                                      type RouteParameters<Route extends string> = string extends Route
                                                                                                                                                                                                                                                                                      ? ParamsDictionary
                                                                                                                                                                                                                                                                                      : Route extends `${string}(${string}`
                                                                                                                                                                                                                                                                                      ? ParamsDictionary //TODO: handling for regex parameters
                                                                                                                                                                                                                                                                                      : Route extends `${string}:${infer Rest}`
                                                                                                                                                                                                                                                                                      ? (GetRouteParameter<Rest> extends never
                                                                                                                                                                                                                                                                                      ? ParamsDictionary
                                                                                                                                                                                                                                                                                      : GetRouteParameter<Rest> extends `${infer ParamName}?`
                                                                                                                                                                                                                                                                                      ? { [P in ParamName]?: string }
                                                                                                                                                                                                                                                                                      : { [P in GetRouteParameter<Rest>]: string }) &
                                                                                                                                                                                                                                                                                      (Rest extends `${GetRouteParameter<Rest>}${infer Next}`
                                                                                                                                                                                                                                                                                      ? RouteParameters<Next>
                                                                                                                                                                                                                                                                                      : unknown)
                                                                                                                                                                                                                                                                                      : {};

                                                                                                                                                                                                                                                                                        type Send

                                                                                                                                                                                                                                                                                        type Send<ResBody = any, T = Response<ResBody>> = (body?: ResBody) => T;

                                                                                                                                                                                                                                                                                          Namespaces

                                                                                                                                                                                                                                                                                          namespace global

                                                                                                                                                                                                                                                                                          namespace global {}

                                                                                                                                                                                                                                                                                            namespace global.Express

                                                                                                                                                                                                                                                                                            namespace global.Express {}

                                                                                                                                                                                                                                                                                              interface Application

                                                                                                                                                                                                                                                                                              interface Application {}

                                                                                                                                                                                                                                                                                                interface Locals

                                                                                                                                                                                                                                                                                                interface Locals {}

                                                                                                                                                                                                                                                                                                  interface Request

                                                                                                                                                                                                                                                                                                  interface Request {}

                                                                                                                                                                                                                                                                                                    interface Response

                                                                                                                                                                                                                                                                                                    interface Response {}

                                                                                                                                                                                                                                                                                                      Package Files (1)

                                                                                                                                                                                                                                                                                                      Dependencies (3)

                                                                                                                                                                                                                                                                                                      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/express-serve-static-core.

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