express-router-tcomb-test

0.2.0 • Public • Published

express-router-tcomb-test

Build Status

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

Package Sidebar

Install

npm i express-router-tcomb-test

Weekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • ewnd9