@sens-tools/api-service
v0.0.17
Published
A TypeScript-based API service library for SENS
Readme
@sens-tools/api-service
A TypeScript-based API service library that provides a flexible and modular way to interact with various API services. The library is designed to be extensible and can be used with or without tRPC integration.
Features
- Modular service architecture
- Type-safe API interactions
- Optional tRPC integration
- Support for multiple service types (common, timeseries, etc.)
- Built with TypeScript for better developer experience
Installation
npm install @sens-tools/api-service
# or
yarn add @sens-tools/api-service
# or
pnpm add @sens-tools/api-serviceOptional Dependencies
If you plan to use the tRPC functionality, you'll need to install the following peer dependencies:
npm install @trpc/client @trpc/server @trpc/react-query @tanstack/react-query
# or
yarn add @trpc/client @trpc/server @trpc/react-query @tanstack/react-query
# or
pnpm add @trpc/client @trpc/server @trpc/react-query @tanstack/react-queryUsage
Basic Usage
import { IotaApiServiceFactory } from '@sens-tools/api-service';
const apiConfig = {
// Your configuration here
};
const apiService = new IotaApiServiceFactory(apiConfig);
// Access different services
const deviceService = apiService.device;
const deviceTypeService = apiService.deviceType;
const tenantService = apiService.tenant;
const timeseriesService = apiService.timeseries;With tRPC
import { IotaApiServiceFactory } from '@sens-tools/api-service';
const apiConfig = {
// Your configuration here
};
const apiService = new IotaApiServiceFactory(apiConfig);
const router = apiService.createRouter();
// Use the router with your tRPC setupConfiguration
The package accepts configuration through the ConfigInputIota interface. Detailed configuration options will be documented here.
Development
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Build
pnpm build
# Lint
pnpm lint
# Format
pnpm formatRelease Workflow
This project uses Changesets for versioning and releases. Here's how it works:
Making Changes
Create a feature branch:
git checkout -b feature/new-featureMake your changes and commit them:
git add . git commit -m "feat: new feature"Create a changeset:
pnpm changeset- Select the type of change (patch/minor/major)
- Write a description of your changes
- This creates a markdown file in the
.changesetdirectory
Push your changes:
git push origin feature/new-feature
Release Process
The release process is fully automated:
- When your PR is merged to
main, the GitHub Action checks for changesets - If changesets are found, it creates a "Version Packages" PR
- After reviewing and merging this PR:
- The package version is bumped
- A changelog is generated
- A new release is published to npm
- A GitHub release is created
Manual Release (if needed)
If you need to trigger a release manually:
# Create a changeset
pnpm changeset
# Version packages
pnpm version
# Publish
pnpm releaseCI/CD Pipeline
Our CI/CD pipeline ensures code quality and reliability through the following stages:
Build Stage
- TypeScript compilation
- Linting with ESLint
- Code formatting with Prettier
- Bundle size checks
Test Stage
- Unit tests with Jest
- Integration tests
- Code coverage reports
- Performance benchmarks
Quality Assurance
- Security scanning with Snyk
- Dependency audit
- Documentation generation
- API compatibility checks
Deployment
- Version bumping
- Changelog generation
- NPM package publishing
- GitHub release creation
The pipeline runs automatically on:
- Every push to main branch
- Every pull request
- Every release tag
TODOs
- [ ] Add comprehensive documentation for configuration options
- [ ] Add examples for different use cases
- [ ] Add unit tests
- [ ] Add integration tests
- [ ] Add CI/CD pipeline
- [ ] Add contribution guidelines
- [ ] Add changelog
- [ ] Add license information
- [ ] Add code of conduct
- [ ] Add issue templates
- [ ] Add pull request templates
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is proprietary software. See LICENSE.md for details.
