learning_ai_common_plat/services/tracker-service/src/server.ts
saravanakumardb1 63c08dbb0a refactor(services): integrate @bytelyst/fastify-core into all 4 services
Replaced duplicated server setup code with createServiceApp() factory:
- platform-service: 91 → 39 lines
- billing-service: 105 → 51 lines (keeps service-specific internal key auth)
- growth-service: 83 → 33 lines
- tracker-service: 88 → 36 lines

Enhanced fastify-core with optional Swagger + Prometheus metrics support.
Total reduction: ~208 lines of duplicated boilerplate eliminated.
All 246 tests pass.
2026-02-12 22:53:22 -08:00

36 lines
1.2 KiB
TypeScript

/**
* Tracker Service — Fastify server entry point.
*
* Modules: items, comments, votes.
* Port: 4004 (configurable via PORT env var).
* Product-agnostic: all data scoped by productId.
*/
import { createServiceApp, startService } from '@bytelyst/fastify-core';
import { itemRoutes } from './modules/items/routes.js';
import { commentRoutes } from './modules/comments/routes.js';
import { voteRoutes } from './modules/votes/routes.js';
import { publicRoutes } from './modules/public/routes.js';
import { config } from './lib/config.js';
const app = await createServiceApp({
name: 'tracker-service',
version: '0.1.0',
description: 'Feature requests, bugs, tasks — product-agnostic',
corsOrigin: config.CORS_ORIGIN,
swagger: {
title: 'Tracker Service',
description: 'Feature requests, bugs, tasks — product-agnostic',
port: config.PORT,
},
metrics: true,
});
// Register route modules
await app.register(itemRoutes, { prefix: '/api' });
await app.register(commentRoutes, { prefix: '/api' });
await app.register(voteRoutes, { prefix: '/api' });
await app.register(publicRoutes, { prefix: '/api' });
await startService(app, { port: config.PORT, host: config.HOST });