Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

type-safety

1.0.1 • Public • Published

WAT

Add type safety to any route you have in your express.js

Auto Generate API docs, that would be in sync with current project version.

Installation

npm install --save type-safety

Usage

const hasShape = require('type-safety')
const router = express.Router()
 
//.. later
router
    .post('/api/route', hasShape({
        text: String,
        sentiment: String
    }), routeHandler)
    .post('/api/route2', hasShape({
        text: String,
        lang: String
    }), route2Handler)
 
//.. where  routeHandler, and route2Handler are plain express routes
 
function routeHandler(req, res, next) {
    // its safe to use
    console.log(req.body.text)
}

Keywords

none

Install

npm i type-safety

DownloadsWeekly Downloads

1

Version

1.0.1

License

ISC

Last publish

Collaborators

  • avatar