1.0.0 • Published 4 years ago

axios-safely v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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);