Skip to content

Commit

Permalink
Merge pull request #76 from fiit-tp7-2023/download-documents-through-api
Browse files Browse the repository at this point in the history
Fix puppeteer issues and remove unnecessary files
  • Loading branch information
steboee authored Dec 11, 2023
2 parents a272ea0 + 5463d44 commit 87f3452
Show file tree
Hide file tree
Showing 16 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:20.10.0

RUN apt-get update && apt-get --no-install-recommends install -y ca-certificates fonts-liberation fonts-noto-color-emoji libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils && rm -rf /var/lib/apt/lists/*

RUN npm install -g pnpm

RUN mkdir -p /usr/local/team07/presentation-web/frontend
Expand Down
Binary file removed public/minute-books/minute-book-1.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-2.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-3.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-4.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-6.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-7.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-8.pdf
Binary file not shown.
Binary file removed public/minute-books/minute-book-summary.pdf
Binary file not shown.
Binary file removed public/retrospectives/retrospective-1.pdf
Binary file not shown.
Binary file removed public/retrospectives/retrospective-2.pdf
Binary file not shown.
Binary file removed public/retrospectives/retrospective-3.pdf
Binary file not shown.
Binary file removed public/retrospectives/retrospective-4.pdf
Binary file not shown.
Binary file removed public/retrospectives/retrospective-summary.pdf
Binary file not shown.
4 changes: 1 addition & 3 deletions server/api/document/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default defineEventHandler(async (event) => {
});

const { getDocument } = useDocumentService();
return await getDocument(query).catch((e) => {
console.error('Download document error:', String(e));

return await getDocument(query).catch(() => {
throw createError({
statusCode: 404,
statusMessage: 'Not Found',
Expand Down
5 changes: 4 additions & 1 deletion server/services/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type { DocumentRequestDTO } from '~/types/dtos';

export const useDocumentService = () => {
const getDocument = async (query: DocumentRequestDTO) => {
const pdf = await mdToPdf({ path: `${process.cwd()}/content/${query.contentRelativePath}` });
const pdf = await mdToPdf(
{ path: `${process.cwd()}/content/${query.contentRelativePath}` },
{ launch_options: { headless: 'new', args: ['--no-sandbox'] }, basedir: 'public' },
);
return new Blob([pdf.content]);
};

Expand Down

0 comments on commit 87f3452

Please sign in to comment.