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

@centralping/json-api-query

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@centralping/json-api-query - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

lib/parse.js

16

CHANGELOG.md

@@ -0,1 +1,17 @@

#### v0.1.0 (2018-10-09)
##### Documentation Changes
* **readme:**
* include documentation for parse method ([319508b3](https://github.com/CentralPing/json-api-query/commit/319508b3b47615e98da91ada0829b44dea2a69ae))
* correct array value in example code ([e0009659](https://github.com/CentralPing/json-api-query/commit/e00096597f51ae0ce639bb307fa10998a2501fd3))
##### New Features
* **main, parse:** export method to parse URL strings for JSON API query validation ([07240b3f](https://github.com/CentralPing/json-api-query/commit/07240b3f28d4a0fd73083830c3b2c1b188da9aa3))
##### Tests
* **index, main, parse:** ensure parse method satisfies API contract and is exported ([f469194b](https://github.com/CentralPing/json-api-query/commit/f469194b7d6a4d79e8dff992b5f239433b634485))
#### v0.0.3 (2018-10-06)

@@ -2,0 +18,0 @@

8

lib/index.spec.unit.js

@@ -1,4 +0,10 @@

const {schema, validate} = require('./index');
const {parse, schema, validate} = require('./index');
describe('[Unit] `index`', () => {
describe('with `parse`', () => {
it('should be a function', () => {
expect(parse).toBeInstanceOf(Function);
});
});
describe('with `schema`', () => {

@@ -5,0 +11,0 @@ it('should be a function', () => {

@@ -10,2 +10,3 @@ // ESM syntax is supported.

exports.parse = require('./parse');
exports.validate = require('./validate');

@@ -12,0 +13,0 @@

@@ -1,4 +0,10 @@

const {schema, validate} = require('./main');
const {parse, schema, validate} = require('./main');
describe('[Unit] `main`', () => {
describe('with `parse`', () => {
it('should be a function', () => {
expect(parse).toBeInstanceOf(Function);
});
});
describe('with `schema`', () => {

@@ -5,0 +11,0 @@ it('should be an object', () => {

2

package.json
{
"name": "@centralping/json-api-query",
"version": "0.0.3",
"version": "0.1.0",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -22,3 +22,3 @@ # @CentralPing/json-api-query

fields: {
articles: 'title,body'
articles: ['title', 'body']
},

@@ -47,2 +47,27 @@ fields: {

**Kind**: inner property of [<code>jsonApiQuery</code>](#module_jsonApiQuery)
<a name="module_jsonApiQuery..parse"></a>
### jsonApiQuery~parse ⇒ <code>Object</code>
**Kind**: inner property of [<code>jsonApiQuery</code>](#module_jsonApiQuery)
**Returns**: <code>Object</code> - A url parse object.
| Param | Type | Description |
| --- | --- | --- |
| url | <code>String</code> | Any URL string. |
**Example**
```js
const url = '/foo/bar?include=author&fields%5Barticles%5D=title%2Cbody&fields%5Bpeople%5D=name';
const {query, pathname, ...extra} = parse(url);
// query
// {
// include: [ 'author' ],
// fields: {
// articles: ['title', 'body'],
// people: ['name']
// }
// }
// pathname
// '/foo/bar'
```
<a name="module_jsonApiQuery..validate"></a>

@@ -122,3 +147,20 @@

}
```
### For Parsing & Verification
```js
const {parse, validate} = require('json-api-query');
const validator = validate();
const {query} = parse(url); // url is a string
const valid = validator(query);
if (!valid) {
// Log errors
console.log(validator.errors);
}
```
## Test

@@ -125,0 +167,0 @@

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