🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

typedot

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typedot

Elegant type checking middleware for Express.js

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

A Proof of Concept

I've been playing around with JS to try and find the most elegant way to do type checking through Express middleware.

I like this format, but its farrr from something that you should use.

An Example

Take this route in Express:

app.get('/:id',function(req,res){
  return res.sendStatus(200)
})

If you want to assert that req.params.id should be an integer, you'd add type.int('params.id') as middleware.

Here's what the resulting route would look like:

app.get('/:id',type.int('params.something.id'),function(req,res){
  return res.sendStatus(200)
})

Moving Forward

Here's what I'd like to add soon-ish:

  • More types to check
  • Tests
  • Support for custom types
  • Documentation
  • Published examples

FAQs

Package last updated on 12 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts