@axl-dev/school-sdk
v0.0.1
Published
School SDK
Readme
AXL School SDK
Overview
The AXL School SDK is a modular, type-safe library designed to facilitate interaction with educational APIs. It provides a structured way to access various school-related functionalities, such as authentication, announcements, content management, and more. Built on modern JavaScript principles, this SDK leverages TypeScript for type safety and MobX for state management.
Features
- Modular Architecture: The SDK is divided into various modules, making it easy to import only what you need.
- Type Safety: All API requests and responses are strongly typed, reducing the risk of runtime errors.
- Support for Async Operations: Methods are async, allowing for smooth integration within modern applications.
- Event Management: An event dispatcher is available to facilitate communication between different parts of the application.
Installation
To install the AXL School SDK, use npm:
npm install @axl/school-sdkUsage
Importing the SDK
You can import the SDK modules as needed:
import { Api, ApiRequest, ApiResponse } from '@axl/school-sdk/api/api';Creating an API Client
To interact with the SDK, you will need to create an API client that implements IApiClient:
class MyApiClient implements IApiClient {
async execute<TBody>(request: ApiRequest, api: Api): Promise<ApiResponse<TBody>> {
// Implementation here
}
}Making API Requests
You can use the Api class to perform various API requests:
const apiClient = new MyApiClient();
const api = new Api(apiClient);
// Example of a GET request
const response = await api.get('/path/to/endpoint');Using EventDispatcher
The SDK includes an EventDispatcher.ts class that allows you to manage events:
const dispatcher = new EventDispatcher();
dispatcher.on('eventName', (data) => {
console.log(data);
});
dispatcher.emit('eventName', { message: 'Hello World' });Directory Structure
src/: Contains all source code for the SDK.api/: API-related classes and types.methods/: Specific modules for different functionalities (e.g., authentication, announcements).models/: Data models used throughout the SDK.dispatcher/: Event management system.store/: State management using MobX.utils/: Utility functions and extensions.
Scripts
In the root directory, the following npm scripts are available:
npm run build: Build the SDK using Vite.npm run clean: Remove the dist directory.npm run lint: Run ESLint on the source code.npm run test: Execute tests using Vitest.
How to test school locally with SDK?
- Install
yalc:npm i -g yalc - Build SDK:
yarn build - Up version of package in package.json
- Publish locally version
yalc publish - Add locally package in school repo:
yalc add @axl/school-sdk - Run
yarn installin school repo
Contributing
Contributions are welcome! Please follow standard practices for code contributions, including creating issues for discussion and reviewing pull requests.
License
This project is licensed under the MIT License.
Further Reading
For additional information and usage examples, please refer to the individual files within the api.ts, src/methods/, and EventDispatcher.ts directories, as well as the official documentation for each library used (e.g., Axios, MobX, Vitest).
