Overview
The Timeback SDK provides an Express middleware adapter.Installation
Server Setup
Create a Timeback instance:lib/timeback.ts
Middleware
Add the Timeback middleware to your Express app:server.ts
Alternative: Mount on Router
For more control, you can mount routes on an Express Router:server.ts
Routes
The middleware handles these routes under/api/timeback:
| Route | Method | Purpose |
|---|---|---|
/identity/signin | GET | Initiates SSO flow |
/identity/callback | GET | Handles SSO callback |
/identity/signout | GET/POST | Signs out user |
/user/verify | GET | Verifies user session |
/user/me | GET | Fetches user profile |
/activity/heartbeat | POST | Time-spent heartbeat |
/activity/submit | POST | Activity completion submit |
Usage
Beyond the HTTP routes, you can use the Timeback instance directly for server-side operations like verifying users, fetching profiles, or recording activity completions:server.ts
See user profile for full documentation on
verify() and getProfile().With Frontend Framework
When using Express with a frontend framework like React:server.ts
Next Steps
React Client
Client-side React integration
Identity
Authentication options
Custom Activities
Track learning sessions