Skip to content

ewnd9/express-router-tcomb-test

Repository files navigation

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 = require('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

About

Test agent for express-router-tcomb

Resources

License

Stars

Watchers

Forks

Packages

No packages published