@vnodes/boot-fastify 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/boot.d.ts.map +1 -1
- package/dist/lib/boot.js +10 -2
- package/dist/lib/boot.js.map +1 -1
- package/package.json +9 -9
package/dist/lib/boot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../src/lib/boot.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,sBAAsB,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../src/lib/boot.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,sBAAsB,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AASnH,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,sBAAsB,iBAmEnF"}
|
package/dist/lib/boot.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Env } from '@vnodes/env';
|
|
|
2
2
|
import { ClassSerializerInterceptor, Logger } from '@vnodes/nestjs/common';
|
|
3
3
|
import { ConfigService } from '@vnodes/nestjs/config';
|
|
4
4
|
import { NestFactory, Reflector } from '@vnodes/nestjs/core';
|
|
5
|
+
import { FastifyAdapter } from '@vnodes/nestjs/platform-fastify';
|
|
5
6
|
import { apiReference } from '@vnodes/nestjs/scalar-nestjs-api-reference';
|
|
6
7
|
import { DocumentBuilder, SwaggerModule } from '@vnodes/nestjs/swagger';
|
|
7
8
|
import { getPort } from '@vnodes/net';
|
|
@@ -13,7 +14,14 @@ export async function boot(options, appOptions) {
|
|
|
13
14
|
const DEFAULT_API_PREFIX = 'api';
|
|
14
15
|
const SWAGGER_PATH = 'docs';
|
|
15
16
|
const SCALAR_PATH = 'refs';
|
|
16
|
-
|
|
17
|
+
// 1. Initialize the Fastify Adapter
|
|
18
|
+
const adapter = new FastifyAdapter({
|
|
19
|
+
// Enabling trustProxy ensures req.ip is correctly populated when behind Nginx/Cloudflare
|
|
20
|
+
trustProxy: true,
|
|
21
|
+
// Increase body limit if you plan to handle large GraphQL uploads
|
|
22
|
+
bodyLimit: 10485760
|
|
23
|
+
});
|
|
24
|
+
const app = await NestFactory.create(options.module, adapter, {
|
|
17
25
|
...appOptions,
|
|
18
26
|
logger: IS_PROD ? [
|
|
19
27
|
'fatal',
|
|
@@ -56,7 +64,7 @@ export async function boot(options, appOptions) {
|
|
|
56
64
|
}
|
|
57
65
|
await app.listen(PORT);
|
|
58
66
|
const url = await app.getUrl();
|
|
59
|
-
logger.log(`${NODE_ENV} | Running at ${url}
|
|
67
|
+
logger.log(`${NODE_ENV} | Running at ${url}`);
|
|
60
68
|
logger.log(`Swagger: ${url}/${SWAGGER_PATH} `);
|
|
61
69
|
logger.log(`Swagger: ${url}/${SCALAR_PATH} `);
|
|
62
70
|
logger.log(`Allowed origins: ${ALLOWED_ORIGINS}`);
|
package/dist/lib/boot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/boot.ts"],"sourcesContent":["import { Env } from '@vnodes/env';\nimport { ClassSerializerInterceptor, Logger, type NestApplicationOptions, type Type } from '@vnodes/nestjs/common';\nimport { ConfigService } from '@vnodes/nestjs/config';\nimport { NestFactory, Reflector } from '@vnodes/nestjs/core';\nimport { apiReference } from '@vnodes/nestjs/scalar-nestjs-api-reference';\nimport { DocumentBuilder, SwaggerModule } from '@vnodes/nestjs/swagger';\nimport { getPort } from '@vnodes/net';\nimport { CommonValidationPipe } from '@vnodes/prop';\n\nexport type BootOptions = {\n module: Type;\n};\n\nexport async function boot(options: BootOptions, appOptions?: NestApplicationOptions) {\n const DEFAULT_PORT = await getPort(3000, 3099);\n const NODE_ENV = process.env[Env.NODE_ENV];\n const IS_PROD = NODE_ENV === 'production';\n const DEFAULT_API_PREFIX = 'api';\n const SWAGGER_PATH = 'docs';\n const SCALAR_PATH = 'refs';\n const app = await NestFactory.create(options.module, {\n ...appOptions,\n logger: IS_PROD ? ['fatal', 'error'] : undefined,\n bufferLogs: true,\n });\n\n const config = app.get(ConfigService);\n\n const APP_ID = config.getOrThrow(Env.APP_ID);\n const APP_DESC = config.get(Env.APP_DESC, APP_ID);\n const ALLOWED_ORIGINS = config.getOrThrow(Env.ALLOWED_ORIGINS, '*');\n const API_PREFIX = config.get(Env.API_PREFIX, DEFAULT_API_PREFIX);\n const PORT = config.getOrThrow(Env.PORT, IS_PROD ? undefined : DEFAULT_PORT);\n\n const logger = new Logger(APP_ID);\n\n app.enableCors({\n origin: IS_PROD ? ALLOWED_ORIGINS.split(/[\\s,]{1,}/) : true, // 'true' reflects the request origin (useful for dev)\n methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',\n preflightContinue: false,\n optionsSuccessStatus: 204,\n credentials: true,\n allowedHeaders: 'Content-Type, Accept, Authorization',\n });\n app.enableShutdownHooks();\n app.setGlobalPrefix(API_PREFIX);\n app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));\n app.useGlobalPipes(CommonValidationPipe);\n\n if (!IS_PROD) {\n const swaggerConfig = new DocumentBuilder()\n .setTitle(APP_ID)\n .setDescription(APP_DESC)\n .addBearerAuth({ type: 'http', name: 'jwt' })\n .addSecurityRequirements('jwt')\n .build();\n\n const swaggerDoc = SwaggerModule.createDocument(app, swaggerConfig, { autoTagControllers: true });\n\n app.use(`/${SCALAR_PATH}`, apiReference({ content: swaggerDoc, withFastify: true }));\n SwaggerModule.setup(SWAGGER_PATH, app, swaggerDoc);\n }\n\n await app.listen(PORT);\n\n const url = await app.getUrl();\n logger.log(`${NODE_ENV} | Running at ${url}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/boot.ts"],"sourcesContent":["import { Env } from '@vnodes/env';\nimport { ClassSerializerInterceptor, Logger, type NestApplicationOptions, type Type } from '@vnodes/nestjs/common';\nimport { ConfigService } from '@vnodes/nestjs/config';\nimport { NestFactory, Reflector } from '@vnodes/nestjs/core';\nimport { FastifyAdapter } from '@vnodes/nestjs/platform-fastify';\nimport { apiReference } from '@vnodes/nestjs/scalar-nestjs-api-reference';\nimport { DocumentBuilder, SwaggerModule } from '@vnodes/nestjs/swagger';\nimport { getPort } from '@vnodes/net';\nimport { CommonValidationPipe } from '@vnodes/prop';\n\nexport type BootOptions = {\n module: Type;\n};\n\nexport async function boot(options: BootOptions, appOptions?: NestApplicationOptions) {\n const DEFAULT_PORT = await getPort(3000, 3099);\n const NODE_ENV = process.env[Env.NODE_ENV];\n const IS_PROD = NODE_ENV === 'production';\n const DEFAULT_API_PREFIX = 'api';\n const SWAGGER_PATH = 'docs';\n const SCALAR_PATH = 'refs';\n\n // 1. Initialize the Fastify Adapter\n const adapter = new FastifyAdapter({\n // Enabling trustProxy ensures req.ip is correctly populated when behind Nginx/Cloudflare\n trustProxy: true,\n // Increase body limit if you plan to handle large GraphQL uploads\n bodyLimit: 10485760, // 10MB\n });\n\n const app = await NestFactory.create(options.module, adapter, {\n ...appOptions,\n logger: IS_PROD ? ['fatal', 'error'] : undefined,\n bufferLogs: true,\n });\n\n const config = app.get(ConfigService);\n\n const APP_ID = config.getOrThrow(Env.APP_ID);\n const APP_DESC = config.get(Env.APP_DESC, APP_ID);\n const ALLOWED_ORIGINS = config.getOrThrow(Env.ALLOWED_ORIGINS, '*');\n const API_PREFIX = config.get(Env.API_PREFIX, DEFAULT_API_PREFIX);\n const PORT = config.getOrThrow(Env.PORT, IS_PROD ? undefined : DEFAULT_PORT);\n\n const logger = new Logger(APP_ID);\n\n app.enableCors({\n origin: IS_PROD ? ALLOWED_ORIGINS.split(/[\\s,]{1,}/) : true, // 'true' reflects the request origin (useful for dev)\n methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',\n preflightContinue: false,\n optionsSuccessStatus: 204,\n credentials: true,\n allowedHeaders: 'Content-Type, Accept, Authorization',\n });\n app.enableShutdownHooks();\n app.setGlobalPrefix(API_PREFIX);\n app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));\n app.useGlobalPipes(CommonValidationPipe);\n\n if (!IS_PROD) {\n const swaggerConfig = new DocumentBuilder()\n .setTitle(APP_ID)\n .setDescription(APP_DESC)\n .addBearerAuth({ type: 'http', name: 'jwt' })\n .addSecurityRequirements('jwt')\n .build();\n\n const swaggerDoc = SwaggerModule.createDocument(app, swaggerConfig, { autoTagControllers: true });\n\n app.use(`/${SCALAR_PATH}`, apiReference({ content: swaggerDoc, withFastify: true }));\n SwaggerModule.setup(SWAGGER_PATH, app, swaggerDoc);\n }\n\n await app.listen(PORT);\n\n const url = await app.getUrl();\n logger.log(`${NODE_ENV} | Running at ${url}`);\n logger.log(`Swagger: ${url}/${SWAGGER_PATH} `);\n logger.log(`Swagger: ${url}/${SCALAR_PATH} `);\n\n logger.log(`Allowed origins: ${ALLOWED_ORIGINS}`);\n}\n"],"names":["Env","ClassSerializerInterceptor","Logger","ConfigService","NestFactory","Reflector","FastifyAdapter","apiReference","DocumentBuilder","SwaggerModule","getPort","CommonValidationPipe","boot","options","appOptions","DEFAULT_PORT","NODE_ENV","process","env","IS_PROD","DEFAULT_API_PREFIX","SWAGGER_PATH","SCALAR_PATH","adapter","trustProxy","bodyLimit","app","create","module","logger","undefined","bufferLogs","config","get","APP_ID","getOrThrow","APP_DESC","ALLOWED_ORIGINS","API_PREFIX","PORT","enableCors","origin","split","methods","preflightContinue","optionsSuccessStatus","credentials","allowedHeaders","enableShutdownHooks","setGlobalPrefix","useGlobalInterceptors","useGlobalPipes","swaggerConfig","setTitle","setDescription","addBearerAuth","type","name","addSecurityRequirements","build","swaggerDoc","createDocument","autoTagControllers","use","content","withFastify","setup","listen","url","getUrl","log"],"mappings":"AAAA,SAASA,GAAG,QAAQ,cAAc;AAClC,SAASC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3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "@vnodes/boot-fastify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"boot-fastify"
|
|
@@ -51,16 +51,16 @@
|
|
|
51
51
|
"@swc/helpers": "~0.5.18"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@vnodes/
|
|
55
|
-
"@vnodes/
|
|
56
|
-
"@vnodes/
|
|
57
|
-
"@vnodes/
|
|
54
|
+
"@vnodes/nestjs": "0.0.25",
|
|
55
|
+
"@vnodes/net": "0.0.25",
|
|
56
|
+
"@vnodes/prop": "0.0.25",
|
|
57
|
+
"@vnodes/env": "0.0.25"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@vnodes/env": "0.0.
|
|
61
|
-
"@vnodes/
|
|
62
|
-
"@vnodes/
|
|
63
|
-
"@vnodes/
|
|
60
|
+
"@vnodes/env": "0.0.25",
|
|
61
|
+
"@vnodes/net": "0.0.25",
|
|
62
|
+
"@vnodes/prop": "0.0.25",
|
|
63
|
+
"@vnodes/nestjs": "0.0.25"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public",
|