refactor(fase1c): routing S3 fixes + auth/swagger/index/env

- routes: GET / teruskan headers ke shouldHandleS3; OPTIONS jawab
  204 CORS generik bila bukan S3, handleS3Direct bila S3; komentar
  bypass rate-limit S3 dipertahankan (registry abort pada 429)
- auth-controller: readLoginBody via LoginBodySchema; handleMe sederhanakan
  (getAuthSession sudah cek bearer); import AuthSession dari dto
- swagger: pindah src/routes -> src/interfaces/http/swagger; tambah path
  auth, /api/v1, /{bucket}, /{bucket}/{key}; version dari config.appVersion
- index: unref ketiga setInterval agar tak menahan process
- env: PORT fail-fast via PositiveIntSchema (default 4000 bila tak diset);
  log config turun ke debug
- metrics: dokumentasikan uploadThroughput/queueSize/botUtilization
- test baru test/s3-routing.test.ts (GET / S3 vs home, OPTIONS 204 CORS)
This commit is contained in:
asepharyana
2026-09-14 17:26:03 +07:00
parent 5d01a9405f
commit b164b8826f
9 changed files with 443 additions and 47 deletions
+18 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'bun:test';
import { handleSwaggerHtml, handleSwaggerJson } from '../src/routes/swagger';
import { handleSwaggerHtml, handleSwaggerJson } from '../src/interfaces/http/swagger';
describe('Swagger Documentation Endpoints', () => {
it('returns OpenAPI specification JSON', async () => {
@@ -36,6 +36,23 @@ describe('Swagger Documentation Endpoints', () => {
expect(downloadResponses['302'].description).toContain('Redirect');
});
it('documents auth, web API, and S3 endpoints with the app version', async () => {
const res = await handleSwaggerJson();
const body = (await res.json()) as {
info: { version: string };
paths: Record<string, object>;
};
expect(body.paths).toHaveProperty('/api/v1/auth/login');
expect(body.paths).toHaveProperty('/api/v1/auth/logout');
expect(body.paths).toHaveProperty('/api/v1/auth/me');
expect(body.paths).toHaveProperty('/api/v1/{path}');
expect(body.paths).toHaveProperty('/{bucket}');
expect(body.paths).toHaveProperty('/{bucket}/{key}');
expect(typeof body.info.version).toBe('string');
expect(body.info.version.length).toBeGreaterThan(0);
});
it('returns Swagger UI HTML page', async () => {
const res = await handleSwaggerHtml();