Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@praxent/praxent-validate-route

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@praxent/praxent-validate-route

Validate token and required params

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Praxent Validate Route Package

This package is to assist in validating a NodEJS route for params and authentication. Specifically, this method is expected be invoked as the function argument for an app route in Express.

How to Use

const validateRoute = require('@praxent/praxent-validate-route')
const validate = validateRoute(gatewayToken)

app.post('/path/to/route', validate({
  action: (req, res) => res.json({ requestedData: req.body.data }),
  requireAuth: true,
  requiredParams: ['data'],
  type: 'body',
});

Parameters

  • action
    • Required
    • Type: Function
    • Receives: 'req' and 'res' from express router
  • requireAuth
    • Not required, defaults to false
    • Type: Bool
    • Validates req.headers.token against the instantiated gatewayToken
  • requiredParams
    • Not required, default to empty array
    • Type: Array of strings
    • Name of parameters which are required for the request
  • type
    • Required if requiredParams is not an empty array
    • Type: string
    • Available strings:
      • body
      • query
    • Determines whether to validate required params against the body or query object in express' router (body for posts, query for gets)

Keywords

FAQs

Package last updated on 13 Oct 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc