Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://gitlab.com/xsellier/lout4express
https://gitlab.com/xsellier/lout4express
Last synced: 2 months ago
JSON representation
- Host: gitlab.com
- URL: https://gitlab.com/xsellier/lout4express
- Owner: xsellier
- License: mit
- Created: 2018-06-05T13:19:46.158Z (over 6 years ago)
- Default Branch: master
- Last Synced: 2024-09-30T12:23:46.512Z (3 months ago)
- Stars: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lout4express
Its [lout](https://github.com/hapijs/lout) for express
## Usage
```js
#!/usr/bin/env nodeconst express = require('express')
const os = require('os')
const Joi = require('joi')
const app = express()
const port = Number(process.env.PORT || 3000)const lout4express = require('lout4express')
const routes = [{
url: '/v1/complexArray',
method: 'post',
validate: {
query: Joi.object({
param1: Joi.string().insensitive().required()
})
},
tags: ['admin', 'api'],
description: 'Test GET',
notes: 'test note',
description: 'Example of a fetch route'
},{
url: '/v1/example/fetch',
method: 'post',
validate: {
query: Joi.object({
param1: Joi.string().required()
}),
params: Joi.object({
param1: Joi.string().required()
}),
body: {
param1: Joi.array().items({
param2: Joi.string()
})
}
},
response: {
schema: Joi.object({
param1: Joi.string()
}),
status: {
204: Joi.object({
param2: Joi.string()
}),
404: Joi.object({
error: 'Failure'
})
}
},
description: 'Example of a fetch route'
}, {
url: '/v1/example/fetch',
method: 'get',
validate: {
query: Joi.object({
param1: Joi.string().required()
}),
params: Joi.object({
param1: Joi.string().required()
})
},
response: {
schema: Joi.object({
param1: Joi.string()
}),
status: {
204: Joi.object({
param2: Joi.string()
}),
404: Joi.object({
error: 'Failure'
})
}
},
description: 'Example of a fetch route'
}]app.all('/', lout4express(routes, os.hostname()))
app.listen(port, function () {
console.log(`Example app listening on port ${port} !`)
})```
## Installation
### Installing lout4express
```
npm install lout4express --save
```