Vapor SDK Wrapper is a flexible and robust library for interacting with APIs. It provides support for JWT authentication, dynamic routing, response transformation, enhanced logging, and more.
Install the package using NPM:
npm install vapor-sdk
- JWT Authentication: Secure your API requests with JSON Web Token (JWT) authentication.
- Dynamic Routing: Define endpoints dynamically based on your use cases.
- Response Transformation: Handle common data manipulation tasks with built-in transformation functions.
- Enhanced Logging: Get detailed insights into requests and responses, including headers, body, and timing information.
- Session Login: Authenticate and manage sessions with a dedicated login method.
Create a new instance of VaporWrapper:
import VaporWrapper from 'vapor-sdk';
const vapor = new VaporWrapper({
baseURL: 'https://api.example.com',
maxRetries: 5,
logger: console,
timeout: 1000,
});
Authenticate using the session login method:
vapor.login('/login', 'username', 'password');
Fetch data with optional JWT authentication and response transformation:
vapor.fetchData('/data', 'your-jwt-token', (data) => data.map(item => item.value));
Make custom API requests with optional JWT authentication:
vapor.route({
method: 'get',
route: '/users',
token: 'your-jwt-token',
});
See the examples directory for more detailed examples and use cases.
See the changelog for a detailed history of changes and updates.
We welcome contributions! See the contributing guide for details on how to contribute.
This project is licensed under the MIT License - see the LICENSE file for details.