import swaggerJsdoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import { swaggerConfig, swaggerUiOptions } from './config.js';
import { type Express } from 'express';

import loginEndpoint from './endpoints/auth/login.js';

const allPaths = {
  ...loginEndpoint,
  // When you add more endpoints, add them here:
  // ...registerEndpoint,
  // ...logoutEndpoint,
};


const swaggerSpec = {
  ...swaggerConfig.definition,
  paths: allPaths  
};

const specs = swaggerJsdoc({
  ...swaggerConfig,
  definition: swaggerSpec
});

export function setupSwagger(app: Express, basePath: string): void {
  // Swagger UI at /api-docs
  app.use(basePath + "/api/docs", swaggerUi.serve, swaggerUi.setup(specs, swaggerUiOptions));
  
  //console.log('📚 Swagger docs at http://localhost:3000/api-docs');
}