@5no/router
v1.1.5
Published
Express router with schema
Downloads
52
Maintainers
Readme
Router
Express router with schema
Install
@5no/router requires Node version 8 or above.
npm install --save @5no/router
Examples
import Router from '@5no/router'
const schema = {
id: {
type: Number,
defaultValue: null,
required: true,
},
}
app.use(Router({
path: '/test',
actions: [
{
path: '/:id',
method: 'GET',
schema: schema,
handler: (req, res) => res.action.success(req.action.data.id),
},
],
}))
/**
*
* url: /test
* method: OPTIONS
* response:
*
{
"status": 200,
"success": true,
"message": [
{
"path": "/test/:id",
"method": "GET",
"schema": {
"id": {
"type": "number",
"required": true,
"defaultValue": null
}
}
}
]
}
*
*
*
* /
/**
*
* url: /test/123
* method: GET
* response:
*
{
"status": 200,
"success": true,
"message": 123
}
*
*
*
* /
License
MIT Licensed, Copyright (c) 2020 Aleksandr Sokol