Node.js - Express support


Introduction

Expressexternal link is a back-end web application framework for building RESTful APIs with Node.js.

Objects

This extension, when Express library is found in the source code, may create the following objects:

Icon Description
NodeJS Get Operation
NodeJS Post Operation
NodeJS Put Operation
NodeJS Delete Operation
NodeJS Patch Operation
NodeJS Use Operation

API methods

The supported Express API methodsexternal link for handling routes and middleware are:

API method Object created Link type
app.get(path, callback) NodeJS Get Operation callLink
app.post(path, callback) NodeJS Post Operation callLink
app.put(path, callback) NodeJS Put Operation callLink
app.delete(path, callback) NodeJS Delete Operation callLink
app.patch(path, callback) NodeJS Patch Operation callLink
app.all(path, callback) NodeJS Get Operation callLink
app.use(path, callback) NodeJS Use Operation callLink

When one of the supported API methods is found with a resolved handler function (callback), a callLink is created from the operation object to the handler.

Router object

The methods provided by Express for handling routes and middleware can also be used with a Routerexternal link object. The same methods mentioned above are also supported in this context.

Example

API methods

import express from 'express';

var app = express()

app.get('/getPath', function (req, res) {
  res.send('Response for GET requests with path toto')
})

app.post('/postPath', function (req, res) {
  res.send('Response for POST requests')
})

app.put('/putPath', function (req, res) {
  res.send('Response for PUT requests')
})

app.delete('/deletePath', function (req, res) {
  res.send('Response for DELETE requests')
})

app.patch('/patchPath', function (req, res) {
  res.send('Response for PATCH requests')
})

app.all('/allPath', function (req, res) {
  res.send('Response for ALL requests')
})

app.use('/home', router)

The code above will create the links and objects below:

Router

import express from 'express';

var app = express()
var router = express.Router()

router.get('/getPath', function (req, res) {
  res.send('Response for GET requests with path toto')
})

router.post('/postPath', function (req, res) {
  res.send('Response for POST requests')
})

router.put('/putPath', function (req, res) {
  res.send('Response for PUT requests')
})

router.delete('/deletePath', function (req, res) {
  res.send('Response for DELETE requests')
})

router.patch('/patchPath', function (req, res) {
  res.send('Response for PATCH requests')
})

router.all('/allPath', function (req, res) {
  res.send('Response for ALL requests')
})

app.use('/home', router)

The code also creates the links and objects shown in the image in the API methods section.