Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@mixcore/base

Mixcore SDK base abstractions. Provides core TypeScript classes and interfaces for all SDK packages.

Features

  • 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

Installation

npm install @mixcore/base
# or
pnpm add @mixcore/base

Usage

Extending BaseService

import { BaseService } from '@mixcore/base';

class MyService extends BaseService {
  constructor(config: MyConfig) {
    super(config);
  }

  async getData() {
    return this.execute(() => {
      // Your implementation
    });
  }
}

Security Note

  • Never hardcode secrets in configuration
  • Always inject configuration at runtime
  • Use environment variables for sensitive values

API Reference

BaseService Methods

Method Parameters Returns Description
execute fn: () => Promise<T> Promise<T> Wraps operations with error handling
getConfig None ConfigType Returns current configuration

BaseRestService Methods

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

Testing

Test coverage reports are generated in coverage/ directory when running:

pnpm test

See test files in tests/ directory for implementation details.

Related Packages

Framework Integration

This package works with all JavaScript frameworks. See the main README for framework-specific integration examples.

Package-specific Usage

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

Related Packages

License

Mixcore Community License (MCL). See LICENSE for details.