New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

jsonapi-check

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonapi-check

Easy to check type for json api response.

latest
Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

jsonapi-check

Easy to check type for json api response. Auto generate TypeScript schema file by request info ( path, method and response ) at first time, then check json response according to the associated TypeScript schema next request. Of course, the TypeScript schema files can be rewritten.

Install

npm install jsonapi-check -D

Usage

axios[node]

See example/node for more details.

import { jsonapiCheck } from 'jsonapi-check'

axios.interceptors.response.use((response) => {
  const { request, data } = response
  const { path, method } = requset
  const options = {
    schemaDir: 'schema',
    hasSubdirs: false
  }

  // dev-mode check
  jsonapiCheck(path, method, data, options)
  return response
})

fetch[brower]

See example/brower for more details.

RESTful API

  • GET /authors --> schema/authors-GET.ts --> interface Author
  • GET /authors/12 --> schema/author-GET.ts --> interface Author

Options

schemaDir

  • Type: string
  • Default: schema

The name of directory for generate json schema type.

hasSubdirs

  • Type: boolean
  • Default: false

The schema directory has subdirectory or not. If true, will mkdir like next directory.

  • GET /authors --> schema/authors/authors-GET.ts --> interface Author
  • GET /web/…/authors --> schema/web/author-GET.ts --> interface Author

License

MIT License © 2023-Present Efrice.

Keywords

json

FAQs

Package last updated on 01 Sep 2023

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