Express Framework support for Node.js
Introduction
Express is a back-end web application framework for building RESTful APIs with Node.js.
Objects
This extension, when ExpressJS library is found in the source code, may create the following objects:
Icon | Object |
---|---|
NodeJS Get Operation | |
NodeJS Post Operation | |
NodeJS Put Operation | |
NodeJS Delete Operation | |
NodeJS Use Operation | |
NodeJS Any Operation |
API methods
The supported Express API methods 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.all(path, callback) | NodeJS Any 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 Router object. The same methods mentioned above are also supported in this context.
Example
var express = require('express')
const app = express()
const 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.all('/allPath', function (req, res) {
res.send('Response for ANY requests')
})
app.use('/home', router)
The code above will create the links and objects below: