Download Reactive-Resume/apps/server/src/main.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Reactive-Resume/apps/server/src/main.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/Reactive-Resume/apps/server/src/main.ts
-
curl -L -o main.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Reactive-Resume/apps/server/src/main.ts
2.41 kB
| import { Logger } from "@nestjs/common"; | |
| import { ConfigService } from "@nestjs/config"; | |
| import { NestFactory } from "@nestjs/core"; | |
| import type { NestExpressApplication } from "@nestjs/platform-express"; | |
| import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"; | |
| import cookieParser from "cookie-parser"; | |
| import session from "express-session"; | |
| import helmet from "helmet"; | |
| import { patchNestJsSwagger } from "nestjs-zod"; | |
| import { AppModule } from "./app.module"; | |
| import type { Config } from "./config/schema"; | |
| patchNestJsSwagger(); | |
| async function bootstrap() { | |
| const app = await NestFactory.create<NestExpressApplication>(AppModule, { | |
| logger: process.env.NODE_ENV === "development" ? ["debug"] : ["error", "warn", "log"], | |
| }); | |
| const configService = app.get(ConfigService<Config>); | |
| const accessTokenSecret = configService.getOrThrow("ACCESS_TOKEN_SECRET"); | |
| const publicUrl = configService.getOrThrow("PUBLIC_URL"); | |
| const isHTTPS = publicUrl.startsWith("https://") ?? false; | |
| // Cookie Parser | |
| app.use(cookieParser()); | |
| // Session | |
| app.use( | |
| session({ | |
| resave: false, | |
| saveUninitialized: false, | |
| secret: accessTokenSecret, | |
| cookie: { httpOnly: true, secure: isHTTPS }, | |
| }), | |
| ); | |
| // CORS | |
| app.enableCors({ credentials: true, origin: isHTTPS }); | |
| // Helmet - enabled only in production | |
| if (isHTTPS) app.use(helmet({ contentSecurityPolicy: false })); | |
| // Global Prefix | |
| const globalPrefix = "api"; | |
| app.setGlobalPrefix(globalPrefix); | |
| // Enable Shutdown Hooks | |
| app.enableShutdownHooks(); | |
| // Swagger (OpenAPI Docs) | |
| // This can be accessed by visiting {SERVER_URL}/api/docs | |
| const config = new DocumentBuilder() | |
| .setTitle("Reactive Resume") | |
| .setDescription( | |
| "Reactive Resume is a free and open source resume builder that's built to make the mundane tasks of creating, updating and sharing your resume as easy as 1, 2, 3.", | |
| ) | |
| .addCookieAuth("Authentication", { type: "http", in: "cookie", scheme: "Bearer" }) | |
| .setVersion("4.0.0") | |
| .build(); | |
| const document = SwaggerModule.createDocument(app, config); | |
| SwaggerModule.setup("docs", app, document); | |
| // Port | |
| const port = configService.get<number>("PORT") ?? 3000; | |
| await app.listen(port); | |
| Logger.log(`🚀 Server is up and running on port ${port}`, "Bootstrap"); | |
| } | |
| // eslint-disable-next-line unicorn/prefer-top-level-await | |
| void bootstrap(); | |