SGERP Frontend Library Documentation
A TypeScript library for interacting with SGERP backend APIs
Features
- Connection Management - Store and switch between multiple user/environment profiles (e.g., admin@localhost, regular_user@production)
- Collections - Backbone.js-inspired Collections with indexing, pagination, and utility methods
- Basic Authentication - Built-in support for HTTP Basic Auth
- Environment Support - Manage localhost, staging, and production environments
- Type-Safe - Full TypeScript support with type definitions
- Request Timeout - Configurable global and per-request timeouts
Quick Start
Get started by installing the library and setting up your first connection:
import { initializeSGERP } from 'sgerp-frontend-lib';
// Initialize and get API instance
const api = initializeSGERP({
activeConnection: 'admin@staging',
connections: {
'admin@staging': {
id: 'admin@staging',
environment: 'staging',
user: 'admin',
password: 'your-password',
baseUrl: 'https://sgerp-stage.d.gcdev.swatrider.com',
},
},
});
// Use Collections for managing data
const projects = api.collections.project;
await projects.fetch({ limit: 20 });
// Fast lookup by ID
const project = projects.get(1);
console.log('Project:', project?.name);
// Get current user
const users = api.collections.user;
await users.fetch({ limit: 100 });
const currentUser = users.find(u => u.username === 'admin');
console.log('User:', currentUser?.username);
Try It Out
Want to test the library first? Visit the Try It Out page to connect to the SGERP API with your credentials directly in the browser!
Your connections are saved locally and accessible via the connection widget (bottom-right corner), allowing you to test API methods across different documentation pages.