Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Callable

Index

Properties

_router: any

Used to get all registered routes in Express Application

Special-cased "all" method, applying the given route path, middleware, and callback to every HTTP method.

locals: Record<string, any>
map: any
mountpath: string | string[]

The app.mountpath property contains one or more path patterns on which a sub-app was mounted.

resource: any
router: string
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.

settings: any
stack: any[]

Stack of configured routes

Methods

  • defaultConfiguration(): void
  • Initialize application configuration.

    Returns void

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

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

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

    Parameters

    • setting: string

    Returns boolean

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

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

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

    Parameters

    • setting: string

    Returns boolean

  • 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 library was created to map all of node's popular template engines to follow this convention, thus allowing them to work seamlessly within Express.

    Parameters

    • ext: string
    • fn: (path: string, options: object, callback: (e: any, rendered?: string) => void) => void
        • (path: string, options: object, callback: (e: any, rendered?: string) => void): void
        • Parameters

          • path: string
          • options: object
          • callback: (e: any, rendered?: string) => void
              • (e: any, rendered?: string): void
              • Parameters

                • e: any
                • Optional rendered: string

                Returns void

          Returns void

    Returns "/home/runner/work/forge/forge/node_modules/webpack-dev-server/node_modules/@types/express/index".Application

  • init(): void
  • Initialize the server.

    • setup default configuration
    • setup default middleware
    • setup route reflection methods

    Returns void

  • listen(port: number, hostname: string, backlog: number, callback?: () => void): Server<typeof IncomingMessage, typeof ServerResponse>
  • listen(port: number, hostname: string, callback?: () => void): Server<typeof IncomingMessage, typeof ServerResponse>
  • listen(port: number, callback?: () => void): Server<typeof IncomingMessage, typeof ServerResponse>
  • listen(callback?: () => void): Server<typeof IncomingMessage, typeof ServerResponse>
  • listen(path: string, callback?: () => void): Server<typeof IncomingMessage, typeof ServerResponse>
  • listen(handle: any, listeningListener?: () => void): Server<typeof IncomingMessage, typeof ServerResponse>
  • 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);

    Parameters

    • port: number
    • hostname: string
    • backlog: number
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • Parameters

    • port: number
    • hostname: string
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • Parameters

    • port: number
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • Parameters

    • Optional callback: () => void
        • (): void
        • Returns void

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • Parameters

    • path: string
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • Parameters

    • handle: any
    • Optional listeningListener: () => void
        • (): void
        • Returns void

    Returns Server<typeof IncomingMessage, typeof ServerResponse>

  • 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".

    Returns string

  • render(name: string, options?: object, callback?: (err: Error, html: string) => void): void
  • render(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){ // ... })

    Parameters

    • name: string
    • Optional options: object
    • Optional callback: (err: Error, html: string) => void
        • (err: Error, html: string): void
        • Parameters

          • err: Error
          • html: string

          Returns void

    Returns void

  • Parameters

    • name: string
    • callback: (err: Error, html: string) => void
        • (err: Error, html: string): void
        • Parameters

          • err: Error
          • html: string

          Returns void

    Returns void