-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsimple-doc.js
29 lines (24 loc) · 1010 Bytes
/
simple-doc.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
/* eslint-disable import/no-unresolved, node/no-missing-import, node/no-unpublished-import, eslint-comments/disable-enable-pair */
/* eslint-disable import/no-extraneous-dependencies, node/no-extraneous-import */
import bodyParser from '@nanoexpress/middleware-body-parser';
import schemator from '@nanoexpress/middleware-schemator';
import nanoexpress from 'nanoexpress';
const app = nanoexpress({
jsonSpaces: 2
});
const schematorInstance = schemator({ swaggerPath: './swagger.json' });
app.define(schematorInstance.define);
app.use(bodyParser());
app.get(
'/',
// Here any body-parser, form-data logic (all preprocess middlewares)
schematorInstance.load({ method: 'get', attach: '/', path: './docs.yml' }),
async () => ({ status: 'success' })
);
app.post(
'/',
// Here any body-parser, form-data logic (all preprocess middlewares)
schematorInstance.load({ method: 'post', attach: '/', path: './docs.yml' }),
async (req) => ({ status: 'success', data: req.body })
);
app.listen(4000);