Simple API Client package based on axios. Types included.
- TypeScript Support: Fully typed with TypeScript for better development experience.
- Types(.d.ts): Provides type definitions for all API methods and responses.
- API Client: A simple and flexible API client based on axios.
- Authorization Service: Handles authorization and token management.
- Storage Service: Provides built-in storage management for web and node environments.
- Redis Service: Provides built-in Redis storage management and basic Redis service.
- Interceptor Service: Handles request and response interceptors for API calls.
- Method Generator: Generates API methods based on the provided configuration.
- Built-in EventBus: Provides a simple event bus for communication between components.
- Error Handling: Provides a consistent way to handle errors across the application.
- Well Documented: Comprehensive documentation with examples and usage instructions.
- The services supports both
browserandnodeenvironments.
npm i moodoimport { moodo } from "moodo";
const instance = new moodo({
authProtocol: {
useAuthProtocol: true,
useOAUTHProtocol: true,
},
baseURL: "https://api.example.com",
headers: {
"Content-Type": "application/json",
},
});
// Make API calls
instance.methods
.post("/endpoint", { data: "example" })
.then((response) => {
console.log("Response:", response.data);
})
.catch((error) => {
console.error("Error:", error);
});The API Client instance provides access to several powerful features:
- API Client: HTTP methods and request/response interceptors
- Method Generator: Dynamic API method creation from configuration
- Authorization Service: Token management and authentication workflows
- Storage Service: Cross-platform storage solutions (localStorage, Redis, File, etc.)
- Redis Service: High-level Redis operations (caching, rate limiting, queuing)
- EventBus: Event-driven communication with priority and dependency support
- Quick Start Guide - Get up and running in minutes
- Advanced Usage - Complex patterns and use cases
- API Client - HTTP methods, interceptors, and request handling
- Authorization - Authentication, token management, and security
- Storage - Data persistence across web and Node.js environments
- Redis Service - High-level Redis operations for caching, rate limiting, and queuing
- EventBus - Event-driven architecture and component communication
- Method Generator - Dynamic API method generation
Note
The authProtocol property is optional. This property essentially determines whether the Authorization Service will process access and refresh tokens.
By default, the useAuthProtocol property is set to true, and useOAUTHProtocol is set to false. If a refresh token needs to be stored, the useOAUTHProtocol property should be set to true.
Warning
If authProtocol property is not configured correctly, tokens will not be stored and used properly!
For detailed configuration options and advanced usage patterns, please refer to the specific documentation files linked above.
Contributions are welcome! Please read our contributing guidelines and submit pull requests to the develop branch.
This project is licensed under the MIT License - see the LICENSE file for details.
