import { Module } from "@nestjs/common";
import { ProjectsController } from "./controllers/projects.controller.js";
import { FunctionsController } from "./controllers/functions.controller.js";
import { MongooseModule } from "@nestjs/mongoose";
import { AuthService } from "./services/auth.service.js";
import { UsersService } from "./services/users.service.js";
import { User, UserSchema } from "./schemas/user.schema.js";
import { Project, ProjectSchema } from "./schemas/project.schema.js";
import { Function, FunctionSchema } from "./schemas/function.schema.js";
import { JwtModule } from "@nestjs/jwt";
import { BcryptService } from "./services/bcrypt.service.js";
import { JWT_SECRET, MONGO_URL } from "./auth/const.js";
import { AuthController } from "./controllers/auth.controller.js";
import { JwtStrategy } from "./auth/jwt.strategy.js";
import { LocalStrategy } from "./auth/local.strategy.js";
import { ProjectsService } from "./services/projects.service.js";
import { ProjectFunctionsService } from "./services/project-functions.service.js";
import { UsersController } from "./controllers/users.controller.js";
import { FunctionsModule } from "./functions/functions.module.js";
import { HealthService } from "./services/health.service.js";
import { HealthController } from "./controllers/health.controller.js";

@Module({
  controllers: [
    AuthController,
    UsersController,
    ProjectsController,
    FunctionsController,
    HealthController,
  ],
  imports: [
    JwtModule.register({
      secret: JWT_SECRET,
      signOptions: { expiresIn: "3600s" },
    }),
    MongooseModule.forRoot(MONGO_URL),
    MongooseModule.forFeature([
      {
        name: User.name,
        schema: UserSchema,
      },
      {
        name: Project.name,
        schema: ProjectSchema,
      },
      {
        name: Function.name,
        schema: FunctionSchema,
      },
    ]),
    FunctionsModule,
  ],
  providers: [
    AuthService,
    UsersService,
    ProjectsService,
    ProjectFunctionsService,
    HealthService,
    BcryptService,
    LocalStrategy,
    JwtStrategy,
  ],
})
export class AppModule {}
