/**
 * This is not a production server yet!
 * This is only a minimal backend to get started.
 */

import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import {DocumentBuilder, SwaggerModule} from "@nestjs/swagger";

import { AppModule } from './app/app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const globalPrefix = 'api/v1';
  app.setGlobalPrefix(globalPrefix);

  const config = new DocumentBuilder()
    .setTitle('CyberGarden Weather AGW')
    .setDescription('This api need for control weather processing store platform')
    .setVersion('1.0')
    .addTag('AGW Agregators Sensors')
    .build();
  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api', app, document);

  const port = process.env.AGW_PORT || 3000;
  app.enableCors();
  await app.listen(port);
  Logger.log(
    `🚀 AGW is running on: http://localhost:${port}/${globalPrefix}`
  );
}

bootstrap();
