@invovles/express-router-tool
Install
npm install @involves/express-router-tool --save
Example usage
Router tool:
const express = require('express')
const { routerTool } = require('@involves/express-router-tool')
async function _controller(_req, res) {
res.end()
}
(() => {
const app = express()
const router = express.Router()
const ROUTE = '/'
routerTool.create(router, 'GET', ROUTE, _controller)
})()
Default errors:
const { UnauthorizedError } = require('@involves/express-router-tool')
async function _controller(_req, res) {
throw new UnauthorizedError()
}
List of Errors
Error | Status Code |
---|---|
BadRequestError | 400 |
ServiceUnavailableError | 503 |
UnauthorizedError | 401 |
ValidationError | 400 |
How to run the tests
At the terminal, just type the command:
npm run test