Skip to content

Commit

Permalink
feat: add s3 bucket for pdf storage (#796)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: hxtree <[email protected]>
  • Loading branch information
hxtree authored Jan 25, 2024
1 parent d90c5d5 commit bf3a53a
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 61 deletions.
61 changes: 37 additions & 24 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/config/rush/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "ccec2f270b02bf293d50edfd0195997ed4b3a241",
"pnpmShrinkwrapHash": "b209a35e98f12fa88d1188d3c62ad9ce898dc1e2",
"preferredVersionsHash": "a48003cf229dd47d077bcf6301ac15a6f90e1c34"
}
2 changes: 1 addition & 1 deletion services/authentication-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"typescript": "5.3.3",
"@cats-cradle/create-bundle": "1.0.9",
"@cats-cradle/create-bundle": "1.0.12",
"@shelf/jest-mongodb": "~4.1.7",
"@types/passport": "~1.0.13"
}
Expand Down
2 changes: 1 addition & 1 deletion services/billing-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@types/lodash": "~4.14.202",
"supertest": "~6.3.3",
"@types/supertest": "~2.0.16",
"@cats-cradle/create-bundle": "1.0.9",
"@cats-cradle/create-bundle": "1.0.12",
"@cats-cradle/create-artifact": "2.0.6"
}
}
2 changes: 1 addition & 1 deletion services/character-sheet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"typescript": "5.3.3",
"@cats-cradle/create-bundle": "1.0.9",
"@cats-cradle/create-bundle": "1.0.12",
"@shelf/jest-mongodb": "~4.1.7",
"mongodb-memory-server-global": "8.13.0",
"mongoose": "6.11.3"
Expand Down
2 changes: 1 addition & 1 deletion services/email-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@types/html-to-text": "~9.0.0",
"@types/lodash": "~4.14.202",
"@cats-cradle/create-artifact": "2.0.6",
"@cats-cradle/create-bundle": "1.0.9",
"@cats-cradle/create-bundle": "1.0.12",
"@shelf/jest-mongodb": "~4.1.7",
"mongodb": "6.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion services/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@types/lodash": "~4.14.202",
"supertest": "~6.3.3",
"@types/supertest": "~2.0.16",
"@cats-cradle/create-bundle": "1.0.9",
"@cats-cradle/create-bundle": "1.0.12",
"@cats-cradle/create-artifact": "2.0.6"
}
}
3 changes: 2 additions & 1 deletion services/html-to-pdf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@nestjs/axios": "~2.0.0",
"@cats-cradle/faker-factory": "workspace:*",
"@sparticuz/chromium-min": "112.0.0",
"@sparticuz/chromium": "112.0.0",
"puppeteer-core": "19.8.0",
"uuid": "~9.0.1",
"axios": "^0.21.1"
Expand All @@ -82,7 +83,7 @@
"@types/lodash": "~4.14.202",
"supertest": "~6.3.3",
"@types/supertest": "~2.0.16",
"@cats-cradle/create-bundle": "1.0.9",
"@cats-cradle/create-bundle": "1.0.12",
"@cats-cradle/create-artifact": "2.0.6",
"axios": "^0.21.1"
}
Expand Down
11 changes: 8 additions & 3 deletions services/html-to-pdf/src/module/pdf/pdf.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import { Injectable } from '@nestjs/common';
import { Readable } from 'stream';
import puppeteer, { PDFOptions } from 'puppeteer-core';

// TOGGLE for local development
// import chromium from '@sparticuz/chromium';
import chromium from '@sparticuz/chromium-min';

@Injectable()
Expand Down Expand Up @@ -68,9 +71,11 @@ export class PdfService {
}

private async getBrowser() {
const CHROMIUM_EXECUTABLE_PATH = process.env.AWS_EXECUTION_ENV
? '/opt/nodejs/node_modules/@sparticuz/chromium/bin'
: undefined;
let CHROMIUM_EXECUTABLE_PATH: string | undefined;

if (process.env.AWS_EXECUTION_ENV) {
CHROMIUM_EXECUTABLE_PATH = '/opt/nodejs/node_modules/@sparticuz/chromium/bin';
}

await chromium.font(
'http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf',
Expand Down
Loading

0 comments on commit bf3a53a

Please sign in to comment.