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

@centralping/micro-json-api-query

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@centralping/micro-json-api-query

A JSON API compliant query parameter validator for micro.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
2
Weekly downloads
 
Created
Source

@CentralPing/micro-json-api-query

Build Status Coverage Status Dependency Status Greenkeeper Status Known Vulnerabilities

A micro wrapper for parsing and validating querystrings with json-api-query.

Installation

npm i --save @centralping/micro-json-api-query

API Reference

microJsonApiQuery~schema : Object

Module property that generates a new deep copy of the default schema on every import. Apply any extensions and provide as an optional schema for the validate method.

Kind: inner property of microJsonApiQuery

microJsonApiQuery~parse ⇒ function

Kind: inner property of microJsonApiQuery
Returns: function - The configured parser function

ParamTypeDefaultDescription
[options]ObjectAny AJV option.
[options.coerceTypes]Boolean | String'array'Coerces validated values to specified types in the schema.
[options.ownProperties]BooleantrueRestricts validation to own properties of data object.
[schema]ObjectA JSON Schema for a JSON API query. Defaults to the included schema.

Example

const parser = parse();

Examples

For Default Parsing

const {parse} = require('@centralping/micro-json-api-query');

const parser = parse();

// req is the micro request object
const {query} = parser(req);

For AJV Options

const {parse} = require('@centralping/micro-json-api-query');

const parser = parse({allErrors: true});

// req is the micro request object
const {query} = parser(req);

For Extended Verification

const {parse, schema} = require('@centralping/micro-json-api-query');

// extend schema

const parser = parse(undefined, schema);

// req is the micro request object
const {query} = parser(req);

Test

npm test

With coverage reporting:

npm test -- --coverage

With file watch:

npm run watch

License

MIT

Keywords

FAQs

Package last updated on 22 Nov 2018

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