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.
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
/**
|
|
* Growth Service — Fastify server entry point.
|
|
*
|
|
* Modules: invitations, referrals, promo codes.
|
|
* Port: 4001 (configurable via PORT env var).
|
|
*/
|
|
|
|
import { createServiceApp, startService } from '@bytelyst/fastify-core';
|
|
import { invitationRoutes } from './modules/invitations/routes.js';
|
|
import { referralRoutes } from './modules/referrals/routes.js';
|
|
import { promoRoutes } from './modules/promos/routes.js';
|
|
import { config } from './lib/config.js';
|
|
|
|
const app = await createServiceApp({
|
|
name: 'growth-service',
|
|
version: '0.1.0',
|
|
description: 'Invitations, referrals, promo codes',
|
|
corsOrigin: config.CORS_ORIGIN,
|
|
swagger: {
|
|
title: 'Growth Service',
|
|
description: 'Invitations, referrals, promo codes',
|
|
port: config.PORT,
|
|
},
|
|
metrics: true,
|
|
});
|
|
|
|
// Register route modules
|
|
await app.register(invitationRoutes, { prefix: '/api' });
|
|
await app.register(referralRoutes, { prefix: '/api' });
|
|
await app.register(promoRoutes, { prefix: '/api' });
|
|
|
|
await startService(app, { port: config.PORT, host: config.HOST });
|