mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 09:47:46 +03:00
Refactor and reorganize codebase for better maintainability and clarity
- Rename DTOs to entities and move them to appropriate directories - Remove deprecated controllers and services - Update imports and dependencies - Implement new class transformer decorators for better serialization - Add VK authentication support - Improve error handling and validation - Update ESLint configuration and TypeScript settings - Refactor schedule parsing logic - Enhance user and authentication services - Update Prisma schema and related entities - Improve code organization and structure This commit introduces significant changes to improve the overall structure and maintainability of the codebase, including better organization of DTOs, enhanced authentication features, and updated tooling configurations.
This commit is contained in:
31
src/main.ts
31
src/main.ts
@@ -3,22 +3,30 @@ import { AppModule } from "./app.module";
|
||||
import { ValidatorOptions } from "class-validator";
|
||||
import { PartialValidationPipe } from "./utility/validation/partial-validation.pipe";
|
||||
import { ClassValidatorInterceptor } from "./utility/validation/class-validator.interceptor";
|
||||
import { RedocModule } from "nest-redoc";
|
||||
import { apiConstants, httpsConstants } from "./contants";
|
||||
import * as fs from "node:fs";
|
||||
import { VersioningType } from "@nestjs/common";
|
||||
import {
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication,
|
||||
} from "@nestjs/platform-fastify";
|
||||
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
httpsOptions: {
|
||||
cert: fs.readFileSync(httpsConstants.certPath),
|
||||
key: fs.readFileSync(httpsConstants.keyPath),
|
||||
const app = await NestFactory.create<NestFastifyApplication>(
|
||||
AppModule,
|
||||
new FastifyAdapter(),
|
||||
{
|
||||
httpsOptions: {
|
||||
cert: fs.readFileSync(httpsConstants.certPath),
|
||||
key: fs.readFileSync(httpsConstants.keyPath),
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
const validatorOptions: ValidatorOptions = {
|
||||
enableDebugMessages: true,
|
||||
forbidNonWhitelisted: true,
|
||||
whitelist: true,
|
||||
strictGroups: true,
|
||||
};
|
||||
app.useGlobalPipes(new PartialValidationPipe(validatorOptions));
|
||||
app.useGlobalInterceptors(new ClassValidatorInterceptor(validatorOptions));
|
||||
@@ -29,21 +37,24 @@ async function bootstrap() {
|
||||
type: VersioningType.URI,
|
||||
});
|
||||
|
||||
const swaggerConfig = RedocModule.createDocumentBuilder()
|
||||
const swaggerConfig = new DocumentBuilder()
|
||||
.setTitle("Schedule Parser")
|
||||
.setDescription("Парсер расписания")
|
||||
.setVersion(apiConstants.version)
|
||||
.build();
|
||||
const swaggerDocument = RedocModule.createDocument(app, swaggerConfig, {
|
||||
|
||||
const swaggerDocument = SwaggerModule.createDocument(app, swaggerConfig, {
|
||||
deepScanRoutes: true,
|
||||
});
|
||||
|
||||
swaggerDocument.servers = [
|
||||
{
|
||||
url: `https://localhost:${apiConstants.port}`,
|
||||
description: "Локальный сервер для разработки",
|
||||
},
|
||||
];
|
||||
await RedocModule.setup("api-docs", app, swaggerDocument, {});
|
||||
|
||||
SwaggerModule.setup("api-docs", app, swaggerDocument, {});
|
||||
|
||||
await app.listen(apiConstants.port);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user