API Package
Package: @hereby/api | Fastify 5 + tRPC 11
Type-safe API server with HTTP and WebSocket tRPC endpoints, file serving for uploads, JWT auth, and organization-scoped business routers.
Runtime
- Fastify server
- tRPC HTTP endpoint at
/trpc - tRPC WebSocket endpoint at
/trpc-ws - Static uploads served from
/uploads/ - Health check at
/health
The server initializes the database before boot and creates the upload directory if needed.
Middleware and Server Settings
@fastify/helmet@fastify/cors@fastify/jwt@fastify/rate-limit@fastify/static
Current notable settings:
- 10 MB request body limit
- rate limit of 100 requests per minute
- JWT auth
Routers
The current app router (packages/api/src/router.ts) exposes 57 top-level routers:
accountplatformaiauthinviteinquirysignuporganizationorganizationHolidayorganizationParameterteamteamDriveteamManageremployeeeSignpayrollpayrollCellMemoattendanceattendanceRateworkTimeClosingsalaryGradegradePromotionovertimeoffsiteWorkallowancedeductiondeductionImportresignationyearEndSettlementfixedIncentiveitemCodeeducationSubsidyroleleaveRequestannualLeavePromotionconversationmessagedocumentnotificationpermissionRequestnurseSchedulergeneralAffairsmanagementDashboardmoduleRegistryshiftshiftGroupdeviceTokenstorageemployeeCertificationcertificationTypeinventorysecomEventsheetViewsheetRowsheetCellsheetTemplatedocumentTemplate
Notable Capabilities
- JWT auth with refresh-token flow
- Organization-scoped protected procedures
- Team-leader-scoped procedures
- Payroll generation, validation, confirmation, and eCount export
- AI-assisted payroll rate updates
- Async nurse schedule generation
- General affairs notices, trainings, tasks, and acknowledgments
- Push-notification device registration
- WebSocket subscriptions for messaging
Development
bash
pnpm --filter @hereby/api dev
pnpm --filter @hereby/api build
pnpm --filter @hereby/api start
pnpm --filter @hereby/api type-check