Open In App

Express.js Application Complete Reference

Improve
Improve
Like Article
Like
Save
Share
Report

Express.js is a small framework that works on top of Node.js web server functionality to simplify its APIs and add helpful new features. It makes it easier to organize your application’s functionality with middleware and routing.

Express.js Application Properties:

Properties

Description

Express.js app.locals  Property

The app.locals object has properties that are local variables within the application. These variables are local to the application and are very useful.

Express.js app.mountpath Property

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

Express.js Application Events:

Event

Description

Express.js mount Event

The mount event is fired on a sub-app when it is mounted on a parent app and the parent app is basically passed to the callback function

Express.js Application Methods:

Methods

Description

Express.js app.all() Function

The app.all() function is used to route all types of HTTP requests. Like if we have POST, GET, PUT, DELETE, etc.

Express.js app.delete() Function

The app.delete() function is used to route the HTTP DELETE requests to the path which is specified as a parameter with the callback functions being passed as a parameter.

Express.js app.disable() Function

The app.disable() function is used to set the boolean setting name to false. It is basically the shorthand for the app.set(name, false).

Express.js app.disabled() Function

The app.disabled() function is used to return the bool values of the setting name. It returns true if the setting name is disabled and returns false if the setting name is not disabled.

Express.js app.enable() Function

The app.enable() function is used to set the boolean value i.e. name to true. It is basically the shorthand for the app.set(name, true) or app.set(name, false).

Express.js app.enabled() Function

The app.enabled() function is used to return the bool values of the setting name. It returns true if the setting name is enabled and returns false if the setting name is not enabled.

Express.js app.engine() Function

The app.engine() function is used to register the given template engine callback as ext. By default the Express itself will require() the engine based on the file extension.

Express.js app.get() Function

The app.get() function routes the HTTP GET Requests to the path which is being specified with the specified callback functions. Basically, it is intended for binding the middleware to your application.

Express.js app.get() request Function

The app.get() function routes the HTTP GET Requests to the path which is being specified with the specified callback functions. Basically, it is intended for binding the middleware to your application.

Express.js app.listen() Function

The app.listen() function is used to bind and listen to the connections on the specified host and port. This method is identical to Node’s http.Server.listen() method.

Express.js app.METHOD() Function

The app.METHOD() function is used to route an HTTP request, where METHOD is the HTTP method of the request, such as GET, PUT, POST, and so on, in lowercase

Express.js app.param() Function

The app.param() function is used to add the callback triggers to route parameters. It is commonly used to check for the existence of the data requested related to the route parameter.

Express.js app.path() Function

The app.path() function returns the canonical path of the app as a string. When mounting advanced apps, the behavior of this approach can become extremely complicated.

Express.js app.post() Function

The app.post() function routes the HTTP POST requests to the specified path with the specified callback functions.

Express.js app.put() Function

The app.put() function routes the HTTP PUT requests to the specified path with the specified callback functions.

Express.js app.render() Function

The app.render() function is used to render the HTML of a view via the callback function. This function returns the HTML in the callback function.

Express.js app.route() Function

The app.route() function returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware. Use app.route() to avoid duplicate route names (and thus typo errors).

Express.js app.set() Function

The app.set() function is used to assign the setting name to value. You may store any value that you want, but certain names can be used to configure the behavior of the server.

Express.js app.use() Function

The app.use() function is used to mount the specified middleware function(s) at the path which is being specified. It is mostly used to set up middleware for your application.



Last Updated : 01 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads