axios-safely

1.0.0 • Public • Published

API Request & Response Runtime Validation

Runtime data validation of HTTP requests.

For those who put too much trust in TypeScript

Examples

Path based validation

import axiosSafely from 'axios-safely';

export const paths = {
  `/api/user`: checkUserSchema,
  `/api/repos/`: checkRepoSchema,
  `GET /api/notes`: data => schema_id_and_note.parse(data),
  `POST /api/notes`: {
    request: (data) => schema_note.parse(data),
    response: (data) => schema_id_and_note.parse(data),
  }
};

export default axiosSafely(paths);

Readme

Keywords

none

Package Sidebar

Install

npm i axios-safely

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

1.54 kB

Total Files

2

Last publish

Collaborators

  • justsml