forked from johnhof/fleek-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.js
34 lines (28 loc) · 747 Bytes
/
basic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict'
let koa = require('koa');
let validator = require('../lib/validator');
let router = require('fleek-router');
let parser = require('koa-bodyparser');
let app = module.exports = koa();
const PORT = 7000;
app.use(parser());
let config = {
swagger: './swagger.json',
controllers : '.',
validate: validator({
swagger: './swagger.json',
success: function *(next) {
this.set('X-fleek-validation', 'OK');
},
error: function *(err, next) {
this.set('X-fleek-validation', 'KO');
this.body = err;
this.status = 400;
}
})
}
router(app, config);
if (!module.parent) {
app.listen(PORT);
console.log('Listening on port ' + PORT)
}