@vnodes/boot-fastify 0.0.23

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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ ![Npm version](https://img.shields.io/npm/v/@vnodes/boot-fastify)
2
+ ![Npm downloads](https://img.shields.io/npm/dm/@vnodes/boot-fastify)
3
+ ![Build Status](https://img.shields.io/github/actions/workflow/status/vnodes/vnodes/ci.yml)
4
+ ![Doc Status](https://img.shields.io/github/actions/workflow/status/vnodes/vnodes/doc.yml)
5
+ ![Bundle size](https://img.shields.io/bundlephobia/min/@vnodes/boot-fastify)
6
+
7
+ <p align="center">
8
+ <img srcset="./assets/favicon.png, https://vnodes.github.io/vnodes/libs/boot-fastify/assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
9
+ </p>
10
+
11
+ ## @vnodes/boot-fastify
12
+
13
+ @vnodes/boot-fastify
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add @vnodes/boot-fastify
19
+ ```
20
+
21
+ ## 💖 Support My Work
22
+
23
+ If you find my open-source contributions or the **@vnodes/boot-fastify** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
24
+
25
+ [![CashApp](https://img.shields.io/badge/Sponsor%20me-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](https://cash.app/$puqlib)
26
+
27
+ ---
28
+
29
+ ## 🤝 Connect with Me
30
+
31
+ <p align="left">
32
+ <a href="mailto:robert.brightline+vnodes-boot-fastify@gmail.com">
33
+ <img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
34
+ </a>
35
+ </p>
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync } from 'node:fs';
4
+ import { dirname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ const packageJsonPath = join(__dirname, '..', 'package.json');
10
+ const packageJson = readFileSync(packageJsonPath, { encoding: 'utf-8' });
11
+ const version = JSON.parse(packageJson).version;
12
+ console.log(version);
@@ -0,0 +1,2 @@
1
+ export * from './lib/boot.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)
2
+ export * from './lib/boot.js';
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)\nexport * from './lib/boot.js';\n"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,cAAc,gBAAgB"}
@@ -0,0 +1,6 @@
1
+ import { type NestApplicationOptions, type Type } from '@vnodes/nestjs/common';
2
+ export type BootOptions = {
3
+ module: Type;
4
+ };
5
+ export declare function boot(options: BootOptions, appOptions?: NestApplicationOptions): Promise<void>;
6
+ //# sourceMappingURL=boot.d.ts.map
@@ -0,0 +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;AAQnH,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,sBAAsB,iBA0DnF"}
@@ -0,0 +1,65 @@
1
+ import { Env } from '@vnodes/env';
2
+ import { ClassSerializerInterceptor, Logger } from '@vnodes/nestjs/common';
3
+ import { ConfigService } from '@vnodes/nestjs/config';
4
+ import { NestFactory, Reflector } from '@vnodes/nestjs/core';
5
+ import { apiReference } from '@vnodes/nestjs/scalar-nestjs-api-reference';
6
+ import { DocumentBuilder, SwaggerModule } from '@vnodes/nestjs/swagger';
7
+ import { getPort } from '@vnodes/net';
8
+ import { CommonValidationPipe } from '@vnodes/prop';
9
+ export async function boot(options, appOptions) {
10
+ const DEFAULT_PORT = await getPort(3000, 3099);
11
+ const NODE_ENV = process.env[Env.NODE_ENV];
12
+ const IS_PROD = NODE_ENV === 'production';
13
+ const DEFAULT_API_PREFIX = 'api';
14
+ const SWAGGER_PATH = 'docs';
15
+ const SCALAR_PATH = 'refs';
16
+ const app = await NestFactory.create(options.module, {
17
+ ...appOptions,
18
+ logger: IS_PROD ? [
19
+ 'fatal',
20
+ 'error'
21
+ ] : undefined,
22
+ bufferLogs: true
23
+ });
24
+ const config = app.get(ConfigService);
25
+ const APP_ID = config.getOrThrow(Env.APP_ID);
26
+ const APP_DESC = config.get(Env.APP_DESC, APP_ID);
27
+ const ALLOWED_ORIGINS = config.getOrThrow(Env.ALLOWED_ORIGINS, '*');
28
+ const API_PREFIX = config.get(Env.API_PREFIX, DEFAULT_API_PREFIX);
29
+ const PORT = config.getOrThrow(Env.PORT, IS_PROD ? undefined : DEFAULT_PORT);
30
+ const logger = new Logger(APP_ID);
31
+ app.enableCors({
32
+ origin: IS_PROD ? ALLOWED_ORIGINS.split(/[\s,]{1,}/) : true,
33
+ methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
34
+ preflightContinue: false,
35
+ optionsSuccessStatus: 204,
36
+ credentials: true,
37
+ allowedHeaders: 'Content-Type, Accept, Authorization'
38
+ });
39
+ app.enableShutdownHooks();
40
+ app.setGlobalPrefix(API_PREFIX);
41
+ app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
42
+ app.useGlobalPipes(CommonValidationPipe);
43
+ if (!IS_PROD) {
44
+ const swaggerConfig = new DocumentBuilder().setTitle(APP_ID).setDescription(APP_DESC).addBearerAuth({
45
+ type: 'http',
46
+ name: 'jwt'
47
+ }).addSecurityRequirements('jwt').build();
48
+ const swaggerDoc = SwaggerModule.createDocument(app, swaggerConfig, {
49
+ autoTagControllers: true
50
+ });
51
+ app.use(`/${SCALAR_PATH}`, apiReference({
52
+ content: swaggerDoc,
53
+ withFastify: true
54
+ }));
55
+ SwaggerModule.setup(SWAGGER_PATH, app, swaggerDoc);
56
+ }
57
+ await app.listen(PORT);
58
+ const url = await app.getUrl();
59
+ logger.log(`${NODE_ENV} | Running at ${url}}`);
60
+ logger.log(`Swagger: ${url}/${SWAGGER_PATH} `);
61
+ logger.log(`Swagger: ${url}/${SCALAR_PATH} `);
62
+ logger.log(`Allowed origins: ${ALLOWED_ORIGINS}`);
63
+ }
64
+
65
+ //# sourceMappingURL=boot.js.map
@@ -0,0 +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}}`);\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","apiReference","DocumentBuilder","SwaggerModule","getPort","CommonValidationPipe","boot","options","appOptions","DEFAULT_PORT","NODE_ENV","process","env","IS_PROD","DEFAULT_API_PREFIX","SWAGGER_PATH","SCALAR_PATH","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,0BAA0B,EAAEC,MAAM,QAAgD,wBAAwB;AACnH,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,WAAW,EAAEC,SAAS,QAAQ,sBAAsB;AAC7D,SAASC,YAAY,QAAQ,6CAA6C;AAC1E,SAASC,eAAe,EAAEC,aAAa,QAAQ,yBAAyB;AACxE,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,oBAAoB,QAAQ,eAAe;AAMpD,OAAO,eAAeC,KAAKC,OAAoB,EAAEC,UAAmC;IAChF,MAAMC,eAAe,MAAML,QAAQ,MAAM;IACzC,MAAMM,WAAWC,QAAQC,GAAG,CAACjB,IAAIe,QAAQ,CAAC;IAC1C,MAAMG,UAAUH,aAAa;IAC7B,MAAMI,qBAAqB;IAC3B,MAAMC,eAAe;IACrB,MAAMC,cAAc;IACpB,MAAMC,MAAM,MAAMlB,YAAYmB,MAAM,CAACX,QAAQY,MAAM,EAAE;QACjD,GAAGX,UAAU;QACbY,QAAQP,UAAU;YAAC;YAAS;SAAQ,GAAGQ;QACvCC,YAAY;IAChB;IAEA,MAAMC,SAASN,IAAIO,GAAG,CAAC1B;IAEvB,MAAM2B,SAASF,OAAOG,UAAU,CAAC/B,IAAI8B,MAAM;IAC3C,MAAME,WAAWJ,OAAOC,GAAG,CAAC7B,IAAIgC,QAAQ,EAAEF;IAC1C,MAAMG,kBAAkBL,OAAOG,UAAU,CAA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EF,IAAI,CAAC,EAAE3C,YAAY,CAAC,CAAC;IAE5CI,OAAOyC,GAAG,CAAC,CAAC,iBAAiB,EAAEjC,iBAAiB;AACpD"}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@vnodes/boot-fastify",
3
+ "version": "0.0.23",
4
+ "description": "@vnodes/boot-fastify",
5
+ "keywords": [
6
+ "boot-fastify"
7
+ ],
8
+ "author": {
9
+ "name": "Robert Brightline",
10
+ "email": "robert.brightline+vnodes-boot-fastify@gmail.com",
11
+ "url": "https://vnodes.github.io/vnodes"
12
+ },
13
+ "homepage": "https://vnodes.github.io/vnodes/libs/boot-fastify",
14
+ "icon": "https://vnodes.github.io/vnodes/libs/boot-fastify/assets/favicon.png",
15
+ "funding": [
16
+ "https://cash.app/$puqlib"
17
+ ],
18
+ "bin": {
19
+ "version": "./bin/version.mjs"
20
+ },
21
+ "type": "module",
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ "./package.json": "./package.json",
27
+ ".": {
28
+ "@vnodes/source": "./src/index.ts",
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "default": "./dist/index.js"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "bin",
37
+ "!**/*.tsbuildinfo"
38
+ ],
39
+ "nx": {
40
+ "sourceRoot": "libs/boot-fastify/src",
41
+ "tags": [
42
+ "lib"
43
+ ],
44
+ "targets": {
45
+ "build": {},
46
+ "doc": {},
47
+ "lint": {}
48
+ }
49
+ },
50
+ "dependencies": {
51
+ "@swc/helpers": "~0.5.18"
52
+ },
53
+ "peerDependencies": {
54
+ "@vnodes/env": "0.0.23",
55
+ "@vnodes/nestjs": "0.0.23",
56
+ "@vnodes/net": "0.0.23",
57
+ "@vnodes/prop": "0.0.23"
58
+ },
59
+ "devDependencies": {
60
+ "@vnodes/env": "0.0.23",
61
+ "@vnodes/nestjs": "0.0.23",
62
+ "@vnodes/net": "0.0.23",
63
+ "@vnodes/prop": "0.0.23"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public",
67
+ "tag": "latest"
68
+ }
69
+ }