From 60c7070256cc393dff7bde045226dda87d426c1e Mon Sep 17 00:00:00 2001 From: hxtree Date: Sat, 14 Oct 2023 22:47:41 +0000 Subject: [PATCH] feat: echange pdf versioning to header Signed-off-by: hxtree --- common/config/rush/pnpm-lock.yaml | 13 ------------- common/config/rush/repo-state.json | 2 +- platform/bundlers/src/profiles/nestjs-bundler.ts | 4 ++++ services/html-to-pdf/package.json | 3 +-- services/html-to-pdf/src/index.ts | 3 ++- services/html-to-pdf/src/main.ts | 3 ++- .../src/module/health/health.controller.ts | 4 ++-- .../html-to-pdf/src/module/pdf/pdf.controller.ts | 9 +++++++-- 8 files changed, 19 insertions(+), 22 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 9aa983675..a7c83ddcd 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -2065,9 +2065,6 @@ importers: '@nestjs/testing': specifier: 9.2.1 version: 9.2.1(@nestjs/common@9.4.0)(@nestjs/core@9.2.1)(@nestjs/platform-express@9.3.9) - '@sparticuz/chromium': - specifier: ~117.0.0 - version: 117.0.0 '@vendia/serverless-express': specifier: 4.10.4 version: 4.10.4 @@ -12692,16 +12689,6 @@ packages: tslib: 2.6.2 optional: true - /@sparticuz/chromium@117.0.0: - resolution: {integrity: sha512-MXvxLgGt7e1bjOu6AwpemRnhrF+wxLxsHpkiOuJOLsfHAtT0VNlsnhAULQZ7hNXGhr37cTM2sCifUHwgrVH+sA==} - engines: {node: '>= 16'} - dependencies: - follow-redirects: 1.15.3 - tar-fs: 3.0.4 - transitivePeerDependencies: - - debug - dev: false - /@storybook/addon-a11y@7.4.5(@types/react-dom@18.2.6)(@types/react@18.2.13)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-7W8fjCdmwX4zlDM4jpzVKNgelWSqbYr3cH834pqOFAkyiyNVIsNRPQBgSwkkljgz0uAsz8nFCRFK3Oo1btl6Yg==} peerDependencies: diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 4a86a7cdb..daf816c9c 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "ebb79fccecf409936dd8366f90b17a26b30e9b81", + "pnpmShrinkwrapHash": "6ac8d44a89914f6b48f857d90784482fdfe527f2", "preferredVersionsHash": "8ae0ba5bd02ec9c5763773a15e27aee08a6567f6" } diff --git a/platform/bundlers/src/profiles/nestjs-bundler.ts b/platform/bundlers/src/profiles/nestjs-bundler.ts index 6cb2fb76f..dad76968b 100644 --- a/platform/bundlers/src/profiles/nestjs-bundler.ts +++ b/platform/bundlers/src/profiles/nestjs-bundler.ts @@ -17,6 +17,7 @@ export async function nestJsBundler(options: NestJsBundlerOptions) { try { const externalModules = [ + // nestjs 'express', 'reflect-metadata', 'rxjs', @@ -32,6 +33,9 @@ export async function nestJsBundler(options: NestJsBundlerOptions) { 'node-cache', 'reflect-metadata', 'rxjs', + // chromium + 'puppeteer', + 'chrome-aws-lambda', ]; await build({ diff --git a/services/html-to-pdf/package.json b/services/html-to-pdf/package.json index 066ffa3c8..ce1d66a0d 100644 --- a/services/html-to-pdf/package.json +++ b/services/html-to-pdf/package.json @@ -48,9 +48,8 @@ "@cats-cradle/validation-schemas": "workspace:*", "@nestjs/testing": "9.2.1", "@nestjs/axios": "~2.0.0", - "@sparticuz/chromium": "~117.0.0", - "puppeteer": "~21.3.8", "@cats-cradle/faker-factory": "workspace:*", + "puppeteer": "~21.3.8", "chrome-aws-lambda": "~10.1.0" }, "devDependencies": { diff --git a/services/html-to-pdf/src/index.ts b/services/html-to-pdf/src/index.ts index 933deb96b..63b79061f 100644 --- a/services/html-to-pdf/src/index.ts +++ b/services/html-to-pdf/src/index.ts @@ -19,7 +19,8 @@ async function bootstrap() { ); nestApp.enableVersioning({ - type: VersioningType.URI, + type: VersioningType.HEADER, + header: 'Accept-Version', defaultVersion: '1', }); diff --git a/services/html-to-pdf/src/main.ts b/services/html-to-pdf/src/main.ts index b0a99abb5..be6c97bee 100644 --- a/services/html-to-pdf/src/main.ts +++ b/services/html-to-pdf/src/main.ts @@ -9,7 +9,8 @@ async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableVersioning({ - type: VersioningType.URI, + type: VersioningType.HEADER, + header: 'Accept-Version', defaultVersion: '1', }); diff --git a/services/html-to-pdf/src/module/health/health.controller.ts b/services/html-to-pdf/src/module/health/health.controller.ts index 273ccf3ca..ff249ae4d 100644 --- a/services/html-to-pdf/src/module/health/health.controller.ts +++ b/services/html-to-pdf/src/module/health/health.controller.ts @@ -1,7 +1,7 @@ -import { Controller, Get } from '@nestjs/common'; +import { Controller, Get, VERSION_NEUTRAL } from '@nestjs/common'; import { HealthCheckService, HealthCheck } from '@nestjs/terminus'; -@Controller('health') +@Controller({ path: 'health', version: ['1', VERSION_NEUTRAL] }) export class HealthController { constructor(private health: HealthCheckService) {} diff --git a/services/html-to-pdf/src/module/pdf/pdf.controller.ts b/services/html-to-pdf/src/module/pdf/pdf.controller.ts index b13ea8fa2..6069d2d19 100644 --- a/services/html-to-pdf/src/module/pdf/pdf.controller.ts +++ b/services/html-to-pdf/src/module/pdf/pdf.controller.ts @@ -1,12 +1,17 @@ import { - Controller, Post, Body, Res, Get, + Controller, + Post, + Body, + Res, + Get, + VERSION_NEUTRAL, } from '@nestjs/common'; import { Response } from 'express'; import { PdfService } from './pdf.service'; import { CreateHtmlToPdfDto } from './create-html-to-pdf.dto'; import { CreateUrlToPdfDto } from './create-url-to-pdf.dto'; -@Controller({ path: 'pdf', version: ['1'] }) +@Controller({ path: 'pdf', version: ['1', VERSION_NEUTRAL] }) export class PdfController { constructor(private readonly pdfService: PdfService) {}