diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index 55f1a4e..a8cf6d6 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -142,6 +142,17 @@ export function createApp() { app.use(`${v1}/complaints`, apiLimiter, complaintsRouter) // ─── Health / Docs ────────────────────────────────────────── + app.get(v1, (_req, res) => { + res.json({ + name: 'rentaldrivego-api', + version: '1.0.0', + baseUrl: v1, + health: '/health', + docs: `${v1}/docs`, + openApi: `${v1}/openapi.json`, + }) + }) + app.get('/health', (_req, res) => { res.json({ status: 'ok', version: '1.0.0', timestamp: new Date().toISOString() }) }) diff --git a/apps/api/src/tests/integration/health.test.ts b/apps/api/src/tests/integration/health.test.ts index 4bc8a42..ba8d2e7 100644 --- a/apps/api/src/tests/integration/health.test.ts +++ b/apps/api/src/tests/integration/health.test.ts @@ -12,6 +12,15 @@ describe('GET /health', () => { expect(typeof res.body.timestamp).toBe('string') }) + it('GET /api/v1 returns the API entrypoint', async () => { + const res = await request(app).get('/api/v1') + expect(res.status).toBe(200) + expect(res.body.name).toBe('rentaldrivego-api') + expect(res.body.baseUrl).toBe('/api/v1') + expect(res.body.docs).toBe('/api/v1/docs') + expect(res.body.openApi).toBe('/api/v1/openapi.json') + }) + it('GET /api/v1/docs returns route index', async () => { const res = await request(app).get('/api/v1/docs') expect(res.status).toBe(200)