Mayank Agarwal has Published 373 Articles

Express.js – app.locals Property

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 13:35:14

1K+ Views

The app.locals object defines the properties that are local variables inside an application. Once the value of app.locals property is set, it persists throughout the life of the application. The res.locals property is valid only for the lifetime of the request.Syntaxapp.localsExample 1Create a file "appLocals.js" and copy the following code ... Read More

Express.js – app.listen() Method

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 13:29:13

8K+ Views

The app.listen() method binds itself with the specified host and port to bind and listen for any connections. If the port is not defined or 0, an arbitrary unused port will be assigned by the operating system that is mainly used for automated tasks like testing, etc.The app object returned ... Read More

Express.js – app.engine() Method

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 12:37:41

700 Views

The app.engine() method is used for registering the given template engine callback as "ext". The require() method needs the engine based on the function by default.Use the following methods for engines that do not provide the extensions (or want to map different extensions) or express out of the box.app.engine('html', require('ejs').renderFile)Syntaxapp.engine(ext, ... Read More

Express.js – app.enable() Method

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 12:16:52

561 Views

The app.enable() function sets the Boolean setting ‘name’ to ‘true’, where name defines one of the properties from the app settings table. Using the app.set('foo', true) for a Boolean property is same as calling the app.enable('foo') function.Syntaxapp.enable(name)Example 1Create a file with the name "appEnable.js" and copy the following code snippet. ... Read More

Express.js – app.disable() Method

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 12:13:31

746 Views

The app.disable() method disables the setting name passed in the function. This method sets the setting name to False. We can perform the same function by using the app.set() method too, by passing its value as False.Syntaxapp.disable(name)Example 1Create a file with the name "appDisable.js" and copy the following code snippet. ... Read More

Express.js – app.delete() Method

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 12:09:47

7K+ Views

The app.delete() method routes all the HTTP DELETE requests to the specified path with the specified callback functions.Syntaxapp.delete(path, callback, [callback])Parameterspath − This is the path for which the middleware function is invoked. A path can be a string, path pattern, a regular expression, or an array of all these.callback − ... Read More

Express.js – app.all() Method

Mayank Agarwal

Mayank Agarwal

Updated on 30-Sep-2021 12:01:14

3K+ Views

The app.all() method can be used for all types of routings of a HTTP request, i.e., for POST, GET, PUT, DELETE, etc., requests that are made to any specific route. It can map app types of requests with the only condition that the route should match.Syntaxapp.path(path, callback, [callback])Parameterspath − This ... Read More

Data Chunks in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 18-Aug-2021 09:52:53

4K+ Views

Data chunks in Node.js or any other language can be defined as a fragment of data that is sent to all the servers by the client. The servers make a stream of these chunks and form a buffer stream. This buffer stream is then converted into meaningful data.Syntaxrequest.on('eventName', [callback] )ParametersThe ... Read More

Running Java in Node.js

Mayank Agarwal

Mayank Agarwal

Updated on 18-Aug-2021 09:51:28

3K+ Views

Node.js is an event-driven JavaScript runtime platform that is built using the Chrome’s V8 JavaScript engine. Node is mainly used for building large-scale applications. In this article, we will see how to run a Java code in Node.js.StepsCheck if Node.js is already installed on your system using the following command ... Read More

Giving Input to a Node.js Application

Mayank Agarwal

Mayank Agarwal

Updated on 18-Aug-2021 09:44:44

709 Views

The main aim of a Node.js application is to work as a backend technology and serve requests and return response. But we can also pass inputs directly to a Node.js application.We can use readline-sync, a third-party module to accept user inputs in a synchronous manner.Syntaxnpm install readline-syncThis will install the ... Read More

Advertisements