express-router-tcomb-test
v0.2.0
Published
Test agent for express-router-tcomb
Downloads
6
Readme
express-router-tcomb-test
Test agent for express-router-tcomb
Install
$ npm install express-router-tcomb-test --save-dev
Usage
'use strict';
const express = reuqire('express');
const t = require('tcomb');
const Router = require('express-router-tcomb');
const Agent = require('express-router-tcomb-test');
const app = express();
const router = Router();
router.route({
method: 'GET',
path: '/api/v1/items/:id',
schema: {
response: t.struct({
status: t.String,
id: t.String
})
},
handler: (req, res) => {
res.json({ status: 'ok', id: req.params.id });
}
});
app.use('/', router.getRoutes(app));
app.listen(3000);
const agent = Agent(app);
const id = 'test';
const { body } = await agent.get('/api/v1/items/:id', { params: { id } });
License
MIT © ewnd9