Overview
The T1 Component Library API is a RESTful API built with Express.js that provides endpoints for user authentication and component interaction tracking. The API enables you to register users, authenticate them with JWT tokens, and track how users interact with UI components in your library.Base URL
All API requests should be made to:In production, replace
localhost:3001 with your deployed server URL.Technology Stack
The API is built using modern, reliable technologies:Core Technologies
- Node.js (18.x+) - JavaScript runtime
- Express.js (4.18.2) - Minimalist web framework
- TypeScript (5.3.3) - Type-safe JavaScript
Database
- MongoDB Atlas - NoSQL cloud database
- Mongoose (8.0.3) - MongoDB ODM for data modeling
Authentication & Security
- JWT (jsonwebtoken) (9.0.2) - Token-based authentication
- bcryptjs (2.4.3) - Password hashing
Additional Tools
- CORS - Cross-origin resource sharing
- Morgan - HTTP request logger
- express-validator - Request validation
API Architecture
The API follows a clean, layered architecture:Key Features
- RESTful Design - Standard HTTP methods (GET, POST) and status codes
- JWT Authentication - Secure, stateless authentication
- Request Validation - Input validation using express-validator
- Error Handling - Centralized error handling with meaningful messages
- Public & Protected Endpoints - Mixed access levels for different use cases
API Endpoint Categories
Authentication
Register users and obtain JWT tokens for protected endpoints
Component Tracking
Track component interactions and retrieve usage statistics
Data Export
Export tracking data for analysis (requires authentication)
Health Check
Monitor API and database health status
Response Format
All API responses follow a consistent JSON structure:Success Response
Error Response
HTTP Status Codes
The API uses standard HTTP status codes:| Code | Description |
|---|---|
200 | Success - Request completed successfully |
201 | Created - Resource created successfully |
400 | Bad Request - Invalid data or validation error |
401 | Unauthorized - Missing or invalid authentication |
404 | Not Found - Resource doesn’t exist |
500 | Internal Server Error - Server-side error |
503 | Service Unavailable - Database connection issue |
Quick Start Example
Here’s a quick example of registering a user and making an authenticated request:Next Steps
Learn Authentication
Read the Authentication guide to understand how to obtain and use JWT tokens.
Explore Endpoints
Browse the endpoint documentation to see available operations and request/response formats.