diff --git a/nest-ms-pg-auth0/.env.example b/nest-ms-pg-auth0/.env.example index 3e9b1f1..7ebd985 100644 --- a/nest-ms-pg-auth0/.env.example +++ b/nest-ms-pg-auth0/.env.example @@ -28,5 +28,14 @@ AUTH0_CLIENT_ID=CLIENT_ID AUTH0_AUDIENCE=AUDIENCE AUTH0_CLIENT_SECRET=CLIENT_SECRET +# Microservices URLs +AUTH_API_HOST=auth-dev +AUTH_API_PORT=3001 +AUTH_API_URL=http://${AUTH_API_HOST}:${AUTH_API_PORT}/ +TODOS_API_HOST=todos-dev +TODOS_API_PORT=3002 +TODOS_API_URL=http://${TODOS_API_HOST}:${TODOS_API_PORT}/ + +# RabbitMQ URI and queues RABBIT_MQ_URI=amqp://rabbitmq:5672 RABBIT_MQ_AUTH_QUEUE=auth \ No newline at end of file diff --git a/nest-ms-pg-auth0/apps/auth/src/main.ts b/nest-ms-pg-auth0/apps/auth/src/main.ts index 152a98e..1aa03a1 100644 --- a/nest-ms-pg-auth0/apps/auth/src/main.ts +++ b/nest-ms-pg-auth0/apps/auth/src/main.ts @@ -30,10 +30,14 @@ async function bootstrap() { app.enableCors(); // add security HTTP headers - app.register(helmet); + app.register( + helmet as unknown as Parameters[0], + ); // compresses response bodies - app.register(compression); + app.register( + compression as unknown as Parameters[0], + ); // enable validation globally app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true })); @@ -62,8 +66,10 @@ async function bootstrap() { app.useGlobalFilters(new ErrorLoggingFilter(httpAdapterHost)); } - await app.listen(port, configService.HOST, () => { - console.log(`App is running on http://${configService.HOST}:${port}`); + const openPort = process.env.AUTH_API_PORT ?? port; + + await app.listen(openPort, configService.HOST, () => { + console.log(`App is running on http://${configService.HOST}:${openPort}`); }); } bootstrap(); diff --git a/nest-ms-pg-auth0/apps/gateway/src/main.ts b/nest-ms-pg-auth0/apps/gateway/src/main.ts new file mode 100644 index 0000000..57d0d37 --- /dev/null +++ b/nest-ms-pg-auth0/apps/gateway/src/main.ts @@ -0,0 +1,39 @@ +import fastify from 'fastify'; +import fastifyProxy, { FastifyHttpProxyOptions } from '@fastify/http-proxy'; + +interface MicroserviceData { + uri: string; + prefix: string; +} + +async function bootstrap() { + const fastifyServer = fastify({ logger: { level: 'trace' } }); + + const proxyData: FastifyHttpProxyOptions[] = [ + { uri: `${process.env.AUTH_API_URL}`, prefix: 'auth' }, + { uri: `${process.env.TODOS_API_URL}`, prefix: 'todos' }, + ].map( + ({ uri, prefix }: MicroserviceData): FastifyHttpProxyOptions => ({ + upstream: uri, + prefix: `/:version/${prefix}`, + rewritePrefix: `/:version/${prefix}`, + }), + ); + + fastifyServer.get('/', async () => { + return 'Hello Gateway API'; + }); + + for (const proxy of proxyData) { + fastifyServer.register(fastifyProxy, proxy); + } + + fastifyServer.listen( + { port: +`${process.env.PORT ?? 3000}`, host: '0.0.0.0' }, + (err, address) => { + if (err) throw err; + fastifyServer.log.info(`Server listening on ${address}`); + }, + ); +} +bootstrap(); diff --git a/nest-ms-pg-auth0/apps/gateway/test/app.e2e-spec.ts b/nest-ms-pg-auth0/apps/gateway/test/app.e2e-spec.ts new file mode 100644 index 0000000..2493008 --- /dev/null +++ b/nest-ms-pg-auth0/apps/gateway/test/app.e2e-spec.ts @@ -0,0 +1,24 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { INestApplication } from '@nestjs/common'; +import * as request from 'supertest'; +import { GatewayModule } from './../src/gateway.module'; + +describe('GatewayController (e2e)', () => { + let app: INestApplication; + + beforeEach(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [GatewayModule], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + it('/ (GET)', () => { + return request(app.getHttpServer()) + .get('/') + .expect(200) + .expect('Hello World!'); + }); +}); diff --git a/nest-ms-pg-auth0/apps/gateway/test/jest-e2e.json b/nest-ms-pg-auth0/apps/gateway/test/jest-e2e.json new file mode 100644 index 0000000..e9d912f --- /dev/null +++ b/nest-ms-pg-auth0/apps/gateway/test/jest-e2e.json @@ -0,0 +1,9 @@ +{ + "moduleFileExtensions": ["js", "json", "ts"], + "rootDir": ".", + "testEnvironment": "node", + "testRegex": ".e2e-spec.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + } +} diff --git a/nest-ms-pg-auth0/apps/gateway/tsconfig.app.json b/nest-ms-pg-auth0/apps/gateway/tsconfig.app.json new file mode 100644 index 0000000..4955d6a --- /dev/null +++ b/nest-ms-pg-auth0/apps/gateway/tsconfig.app.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": false, + "outDir": "../../dist/apps/gateway" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] +} diff --git a/nest-ms-pg-auth0/apps/todos/src/main.ts b/nest-ms-pg-auth0/apps/todos/src/main.ts index 0682b00..845e35c 100644 --- a/nest-ms-pg-auth0/apps/todos/src/main.ts +++ b/nest-ms-pg-auth0/apps/todos/src/main.ts @@ -31,10 +31,14 @@ async function bootstrap() { app.enableCors(); // add security HTTP headers - app.register(helmet); + app.register( + helmet as unknown as Parameters[0], + ); // compresses response bodies - app.register(compression); + app.register( + compression as unknown as Parameters[0], + ); // enable validation globally app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true })); @@ -63,9 +67,11 @@ async function bootstrap() { app.useGlobalFilters(new ErrorLoggingFilter(httpAdapterHost)); } + const openPort = process.env.TODOS_API_PORT ?? port; + // start server - await app.listen(port, configService.HOST, () => { - console.log(`App is running on http://${configService.HOST}:${port}`); + await app.listen(openPort, configService.HOST, () => { + console.log(`App is running on http://${configService.HOST}:${openPort}`); }); } bootstrap(); diff --git a/nest-ms-pg-auth0/docker-compose.yml b/nest-ms-pg-auth0/docker-compose.yml index efbe2d1..1d260ff 100644 --- a/nest-ms-pg-auth0/docker-compose.yml +++ b/nest-ms-pg-auth0/docker-compose.yml @@ -6,6 +6,8 @@ services: extends: file: ./docker-services/rabbitmq-service.yml service: rabbitmq + networks: + - app-tier db: extends: @@ -13,15 +15,41 @@ services: service: db ports: - '5433:${PGPORT}' + networks: + - app-tier depends_on: - rabbitmq + + gateway: + extends: + file: ./docker-services/gateway-service.yml + service: gateway + ports: + - '3000:${PORT}' + depends_on: + - db + - rabbitmq + + gateway-dev: + extends: + file: ./docker-services/gateway-service.yml + service: gateway-dev + ports: + - '3000:${PORT}' + networks: + - app-tier + depends_on: + - db + - rabbitmq auth: extends: file: ./docker-services/auth-service.yml service: auth ports: - - '3000:${PORT}' + - '${AUTH_API_PORT}:${AUTH_API_PORT}' + expose: + - '${AUTH_API_PORT}' depends_on: - db - rabbitmq @@ -31,7 +59,11 @@ services: file: ./docker-services/auth-service.yml service: auth-dev ports: - - '3000:${PORT}' + - '${AUTH_API_PORT}:${AUTH_API_PORT}' + expose: + - '${AUTH_API_PORT}' + networks: + - app-tier depends_on: - db - rabbitmq @@ -41,7 +73,9 @@ services: file: ./docker-services/todos-service.yml service: todos ports: - - '3001:${PORT}' + - '${TODOS_API_PORT}:${TODOS_API_PORT}' + expose: + - '${TODOS_API_PORT}' depends_on: - db - rabbitmq @@ -51,14 +85,26 @@ services: file: ./docker-services/todos-service.yml service: todos-dev ports: - - '3001:${PORT}' + - '${TODOS_API_PORT}:${TODOS_API_PORT}' + expose: + - '${TODOS_API_PORT}' + networks: + - app-tier depends_on: - db - rabbitmq volumes: - todos: - todos-node_modules: + gateway: + gateway-node_modules: auth: auth-node_modules: + todos: + todos-node_modules: db-data: + +networks: + app-tier: + driver: bridge + ipam: + driver: default \ No newline at end of file diff --git a/nest-ms-pg-auth0/docker-services/gateway-service.yml b/nest-ms-pg-auth0/docker-services/gateway-service.yml new file mode 100644 index 0000000..4395175 --- /dev/null +++ b/nest-ms-pg-auth0/docker-services/gateway-service.yml @@ -0,0 +1,52 @@ +services: + + gateway: + build: + context: ../ + dockerfile: Dockerfile + target: prod + args: + - SERVICE_NAME=gateway + container_name: gateway + image: gateway + env_file: + - ../.env + environment: + # This overrides the .env file + - HOST=0.0.0.0 + # Mount host directory to docker container to support watch mode + volumes: + - gateway + profiles: + - prod + + + + gateway-dev: + build: + context: ../ + dockerfile: Dockerfile + target: dev + args: + - DOCKER_BUILDKIT=1 + - SERVICE_NAME=gateway + container_name: gateway-dev + image: gateway-dev + env_file: + - ../.env + environment: + # This overrides the .env file + - HOST=0.0.0.0 + # Mount host directory to docker container to support watch mode + volumes: + - ../apps/gateway:/usr/src/app/apps/gateway + - ../libs:/usr/src/app/libs + # This ensures that the NestJS container manages the node_modules folder + # rather than synchronizes it with the host machine + - gateway-node_modules:/usr/src/app/node_modules + profiles: + - dev + command: > + sh -c "cd /usr/src/app + && npm run db:migrate:latest + && npm run start:dev -- gateway" \ No newline at end of file diff --git a/nest-ms-pg-auth0/nest-cli.json b/nest-ms-pg-auth0/nest-cli.json index 3f725f0..06600e3 100644 --- a/nest-ms-pg-auth0/nest-cli.json +++ b/nest-ms-pg-auth0/nest-cli.json @@ -43,6 +43,15 @@ "compilerOptions": { "tsConfigPath": "libs/common/tsconfig.lib.json" } + }, + "gateway": { + "type": "application", + "root": "apps/gateway", + "entryFile": "main", + "sourceRoot": "apps/gateway/src", + "compilerOptions": { + "tsConfigPath": "apps/gateway/tsconfig.app.json" + } } } } \ No newline at end of file diff --git a/nest-ms-pg-auth0/package-lock.json b/nest-ms-pg-auth0/package-lock.json index 38e28ce..7541f24 100644 --- a/nest-ms-pg-auth0/package-lock.json +++ b/nest-ms-pg-auth0/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@fastify/compress": "^7.0.3", "@fastify/helmet": "^11.1.1", + "@fastify/http-proxy": "^9.5.0", "@nestjs/axios": "^3.0.2", "@nestjs/common": "^10.3.8", "@nestjs/config": "^3.2.2", @@ -26,6 +27,7 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "cookie-parser": "^1.4.6", + "fastify": "^4.26.2", "jsonwebtoken": "^9.0.2", "jwks-rsa": "^3.1.0", "knex": "^3.1.0", @@ -1309,6 +1311,14 @@ "fast-uri": "^2.0.0" } }, + "node_modules/@fastify/busboy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", + "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", + "engines": { + "node": ">=14" + } + }, "node_modules/@fastify/compress": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/@fastify/compress/-/compress-7.0.3.tgz", @@ -1364,6 +1374,17 @@ "helmet": "^7.0.0" } }, + "node_modules/@fastify/http-proxy": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/@fastify/http-proxy/-/http-proxy-9.5.0.tgz", + "integrity": "sha512-1iqIdV10d5k9YtfHq9ylX5zt1NiM50fG+rIX40qt00R694sqWso3ukyTFZVk33SDoSiBW8roB7n11RUVUoN+Ag==", + "dependencies": { + "@fastify/reply-from": "^9.0.0", + "fast-querystring": "^1.1.2", + "fastify-plugin": "^4.5.0", + "ws": "^8.4.2" + } + }, "node_modules/@fastify/merge-json-schemas": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.1.1.tgz", @@ -1388,6 +1409,20 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.2.tgz", "integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==" }, + "node_modules/@fastify/reply-from": { + "version": "9.8.0", + "resolved": "https://registry.npmjs.org/@fastify/reply-from/-/reply-from-9.8.0.tgz", + "integrity": "sha512-bPNVaFhEeNI0Lyl6404YZaPFokudCplidE3QoOcr78yOy6H9sYw97p5KPYvY/NJNUHfFtvxOaSAHnK+YSiv/Mg==", + "dependencies": { + "@fastify/error": "^3.0.0", + "end-of-stream": "^1.4.4", + "fast-content-type-parse": "^1.1.0", + "fast-querystring": "^1.0.0", + "fastify-plugin": "^4.0.0", + "toad-cache": "^3.7.0", + "undici": "^5.19.1" + } + }, "node_modules/@fastify/send": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@fastify/send/-/send-2.1.0.tgz", @@ -2600,6 +2635,81 @@ } } }, + "node_modules/@nestjs/platform-fastify/node_modules/fastify": { + "version": "4.26.2", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.26.2.tgz", + "integrity": "sha512-90pjTuPGrfVKtdpLeLzND5nyC4woXZN5VadiNQCicj/iJU4viNHKhsAnb7jmv1vu2IzkLXyBiCzdWuzeXgQ5Ug==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "dependencies": { + "@fastify/ajv-compiler": "^3.5.0", + "@fastify/error": "^3.4.0", + "@fastify/fast-json-stringify-compiler": "^4.3.0", + "abstract-logging": "^2.0.1", + "avvio": "^8.3.0", + "fast-content-type-parse": "^1.1.0", + "fast-json-stringify": "^5.8.0", + "find-my-way": "^8.0.0", + "light-my-request": "^5.11.0", + "pino": "^8.17.0", + "process-warning": "^3.0.0", + "proxy-addr": "^2.0.7", + "rfdc": "^1.3.0", + "secure-json-parse": "^2.7.0", + "semver": "^7.5.4", + "toad-cache": "^3.3.0" + } + }, + "node_modules/@nestjs/platform-fastify/node_modules/pino": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-8.21.0.tgz", + "integrity": "sha512-ip4qdzjkAyDDZklUaZkcRFb2iA118H9SgRh8yzTkSQK8HilsOJF7rSY8HoW5+I0M46AZgX/pxbprf2vvzQCE0Q==", + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.1.1", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^1.2.0", + "pino-std-serializers": "^6.0.0", + "process-warning": "^3.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^3.7.0", + "thread-stream": "^2.6.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/@nestjs/platform-fastify/node_modules/pino-std-serializers": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", + "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==" + }, + "node_modules/@nestjs/platform-fastify/node_modules/sonic-boom": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.8.1.tgz", + "integrity": "sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg==", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/@nestjs/platform-fastify/node_modules/thread-stream": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.7.0.tgz", + "integrity": "sha512-qQiRWsU/wvNolI6tbbCKd9iKaTnCXsTwVxhhKM6nctPdujTyztjlbUkUTUymidWcMnZ5pWR0ej4a0tjsW021vw==", + "dependencies": { + "real-require": "^0.2.0" + } + }, "node_modules/@nestjs/schematics": { "version": "10.1.1", "resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-10.1.1.tgz", @@ -6250,9 +6360,9 @@ "integrity": "sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==" }, "node_modules/fastify": { - "version": "4.26.2", - "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.26.2.tgz", - "integrity": "sha512-90pjTuPGrfVKtdpLeLzND5nyC4woXZN5VadiNQCicj/iJU4viNHKhsAnb7jmv1vu2IzkLXyBiCzdWuzeXgQ5Ug==", + "version": "4.28.0", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.28.0.tgz", + "integrity": "sha512-HhW7UHW07YlqH5qpS0af8d2Gl/o98DhJ8ZDQWHRNDnzeOhZvtreWsX8xanjGgXmkYerGbo8ax/n40Dpwqkot8Q==", "funding": [ { "type": "github", @@ -6273,7 +6383,7 @@ "fast-json-stringify": "^5.8.0", "find-my-way": "^8.0.0", "light-my-request": "^5.11.0", - "pino": "^8.17.0", + "pino": "^9.0.0", "process-warning": "^3.0.0", "proxy-addr": "^2.0.7", "rfdc": "^1.3.0", @@ -10476,21 +10586,21 @@ } }, "node_modules/pino": { - "version": "8.21.0", - "resolved": "https://registry.npmjs.org/pino/-/pino-8.21.0.tgz", - "integrity": "sha512-ip4qdzjkAyDDZklUaZkcRFb2iA118H9SgRh8yzTkSQK8HilsOJF7rSY8HoW5+I0M46AZgX/pxbprf2vvzQCE0Q==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-9.2.0.tgz", + "integrity": "sha512-g3/hpwfujK5a4oVbaefoJxezLzsDgLcNJeITvC6yrfwYeT9la+edCK42j5QpEQSQCZgTKapXvnQIdgZwvRaZug==", "dependencies": { "atomic-sleep": "^1.0.0", "fast-redact": "^3.1.1", "on-exit-leak-free": "^2.1.0", "pino-abstract-transport": "^1.2.0", - "pino-std-serializers": "^6.0.0", + "pino-std-serializers": "^7.0.0", "process-warning": "^3.0.0", "quick-format-unescaped": "^4.0.3", "real-require": "^0.2.0", "safe-stable-stringify": "^2.3.1", - "sonic-boom": "^3.7.0", - "thread-stream": "^2.6.0" + "sonic-boom": "^4.0.1", + "thread-stream": "^3.0.0" }, "bin": { "pino": "bin.js" @@ -10506,9 +10616,9 @@ } }, "node_modules/pino-std-serializers": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", - "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz", + "integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==" }, "node_modules/pirates": { "version": "4.0.6", @@ -11602,9 +11712,9 @@ } }, "node_modules/sonic-boom": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.8.1.tgz", - "integrity": "sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.0.1.tgz", + "integrity": "sha512-hTSD/6JMLyT4r9zeof6UtuBDpjJ9sO08/nmS5djaA9eozT9oOlNdpXSnzcgj4FTqpk3nkLrs61l4gip9r1HCrQ==", "dependencies": { "atomic-sleep": "^1.0.0" } @@ -12281,9 +12391,9 @@ "dev": true }, "node_modules/thread-stream": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.7.0.tgz", - "integrity": "sha512-qQiRWsU/wvNolI6tbbCKd9iKaTnCXsTwVxhhKM6nctPdujTyztjlbUkUTUymidWcMnZ5pWR0ej4a0tjsW021vw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz", + "integrity": "sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==", "dependencies": { "real-require": "^0.2.0" } @@ -12690,6 +12800,17 @@ "ieee754": "^1.1.13" } }, + "node_modules/undici": { + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -13050,6 +13171,26 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/ws": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/nest-ms-pg-auth0/package.json b/nest-ms-pg-auth0/package.json index bfc642a..b8871ad 100644 --- a/nest-ms-pg-auth0/package.json +++ b/nest-ms-pg-auth0/package.json @@ -12,7 +12,7 @@ "db:migrate:latest": "ts-node node_modules/knex/bin/cli.js migrate:latest --migrations-directory ./migrations --client pg --migrations-table-name knex_migrations --connection $(ts-node scripts/db-connection)", "db:migrate:rollback": "ts-node node_modules/knex/bin/cli.js migrate:rollback --migrations-directory ./migrations --client pg --migrations-table-name knex_migrations --connection $(ts-node scripts/db-connection)", "db:migrate:up": "ts-node node_modules/knex/bin/cli.js migrate:up --migrations-directory ./migrations --client pg --migrations-table-name knex_migrations --connection $(ts-node scripts/db-connection)", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"", "image:build": "DOCKER_BUILDKIT=1 docker build -t nest-ms-pg-auth0 .", "image:run": "docker run --rm --net host -e NODE_ENV=production --env-file .env nest-ms-pg-auth0", "license:check": "license-checker --summary --excludePrivatePackages --onlyAllow $(node ./licenses-allowed.js ';')", @@ -24,11 +24,11 @@ "start": "node -r dotenv/config ./node_modules/@nestjs/cli/bin/nest.js start", "start:debug": "node -r dotenv/config ./node_modules/@nestjs/cli/bin/nest.js start --debug --watch", "start:dev": "node -r dotenv/config ./node_modules/@nestjs/cli/bin/nest.js start --watch", - "start:prod": "node dist/main", + "start:prod": "node dist/apps/nest-ms-pg-auth0/main", "test": "npm run test:unit && npm run test:e2e", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "npx jest --config ./test/jest-e2e.config.js --runInBand", + "test:e2e": "npx jest --config ./apps/nest-ms-pg-auth0/test/jest-e2e.config.js --runInBand", "test:e2e:cov": "npm run test:e2e -- --coverage", "test:unit": "jest", "test:unit:cov": "jest --coverage", @@ -37,6 +37,7 @@ "dependencies": { "@fastify/compress": "^7.0.3", "@fastify/helmet": "^11.1.1", + "@fastify/http-proxy": "^9.5.0", "@nestjs/axios": "^3.0.2", "@nestjs/common": "^10.3.8", "@nestjs/config": "^3.2.2", @@ -52,6 +53,7 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "cookie-parser": "^1.4.6", + "fastify": "^4.26.2", "jsonwebtoken": "^9.0.2", "jwks-rsa": "^3.1.0", "knex": "^3.1.0", diff --git a/nest-ms-pg-auth0/tsconfig.json b/nest-ms-pg-auth0/tsconfig.json index 5dd53d8..9dc1a1e 100644 --- a/nest-ms-pg-auth0/tsconfig.json +++ b/nest-ms-pg-auth0/tsconfig.json @@ -49,7 +49,7 @@ ], "@healthchecks/*": [ "libs/common/src/healthchecks/*" - ], + ] } }, "ts-node": {