Mixcore SDK base abstractions. Provides core TypeScript classes and interfaces for all SDK packages.
- BaseService: Abstract service class with common functionality
- BaseRestService: REST API client base class
- Injectable configuration: Flexible service configuration
- Framework-agnostic: No UI/SPA dependencies
- Secure by design: Configuration injection prevents hardcoded secrets
npm install @mixcore/base
# or
pnpm add @mixcore/baseimport { BaseService } from '@mixcore/base';
class MyService extends BaseService {
constructor(config: MyConfig) {
super(config);
}
async getData() {
return this.execute(() => {
// Your implementation
});
}
}- Never hardcode secrets in configuration
- Always inject configuration at runtime
- Use environment variables for sensitive values
| Method | Parameters | Returns | Description |
|---|---|---|---|
| execute | fn: () => Promise<T> |
Promise<T> |
Wraps operations with error handling |
| getConfig | None | ConfigType |
Returns current configuration |
| Method | Parameters | Returns | Description |
|---|---|---|---|
| get | path: string, params?: Record<string, any> |
Promise<ApiResult> |
Makes GET request |
| post | path: string, data: any, options?: { isFormData?: boolean } |
Promise<ApiResult> |
Makes POST request |
| put | path: string, data: any |
Promise<ApiResult> |
Makes PUT request |
| delete | path: string |
Promise<ApiResult> |
Makes DELETE request |
Test coverage reports are generated in coverage/ directory when running:
pnpm testSee test files in tests/ directory for implementation details.
This package works with all JavaScript frameworks. See the main README for framework-specific integration examples.
// Example: Using with Angular
import { Injectable } from '@angular/core';
import { BaseRestService } from '@mixcore/base';
@Injectable({ providedIn: 'root' })
export class MyRestService extends BaseRestService {
constructor() {
super({
apiBaseUrl: environment.apiUrl,
apiKey: environment.apiKey
});
}
}- @mixcore/api: API client implementation
- @mixcore/database: Database services extending these base classes
Mixcore Community License (MCL). See LICENSE for details.