A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix(printer): fix issue with printer service, locating the right URL of the server
Amruth Pillai625584982271
diff --git a/.env.example b/.env.exampleindex 57df0d2b3..79ebd6eff 100644--- a/.env.example+++ b/.env.example@@ -4,6 +4,7 @@ SECRET_KEY=change-me# URLsPUBLIC_URL=http://localhost:3000+PUBLIC_SERVER_URL=http://localhost:3100# DatabasePOSTGRES_HOST=localhostdiff --git a/.vscode/launch.json b/.vscode/launch.jsonnew file mode 100644index 000000000..c19ed6d80--- /dev/null+++ b/.vscode/launch.json@@ -0,0 +1,26 @@+{+ "version": "0.2.0",+ "configurations": [+ {+ "type": "node",+ "request": "attach",+ "name": "Debug: Server",+ "port": 9229,+ "restart": true,+ "stopOnEntry": false,+ "protocol": "inspector"+ },+ {+ "name": "Debug: Client",+ "type": "node-terminal",+ "request": "launch",+ "command": "pnpm run dev:client",+ "console": "integratedTerminal",+ "serverReadyAction": {+ "pattern": "started server on .+, url: (https?://.+)",+ "uriFormat": "%s",+ "action": "debugWithChrome"+ }+ }+ ]+}diff --git a/README.md b/README.mdindex ecb623ecc..2e30a09a7 100644--- a/README.md+++ b/README.md@@ -116,7 +116,7 @@ Reactive Resume would be nothing without the folks who supported me and kept the- DigitalOcean, infrastructure provider- Crowdin, translation management platform-<a href="https://www.digitalocean.com/">+<a href="https://pillai.xyz/digitalocean"><img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/PoweredByDO/DO_Powered_by_Badge_blue.svg" width="200px" /></a>diff --git a/client/Dockerfile b/client/Dockerfileindex 95db39b1f..00b1e731b 100644--- a/client/Dockerfile+++ b/client/Dockerfile@@ -36,13 +36,14 @@ RUN apk add --no-cache curl \COPY --from=builder /app/pnpm-*.yaml ./COPY --from=builder /app/package.json ./+COPY --from=builder /app/client/package.json ./client/package.json++RUN pnpm install -F client --frozen-lockfile --prod+COPY --from=builder /app/client/.next ./client/.nextCOPY --from=builder /app/client/public ./client/publicCOPY --from=builder /app/client/next.config.js ./client/next.config.jsCOPY --from=builder /app/client/next-i18next.config.js ./client/next-i18next.config.js-COPY --from=builder /app/client/package.json ./client/package.json--RUN pnpm install -F client --frozen-lockfile --prodEXPOSE 3000diff --git a/client/components/build/Center/ArtboardController.tsx b/client/components/build/Center/ArtboardController.tsxindex 7cd0583d6..f16a3b0b6 100644--- a/client/components/build/Center/ArtboardController.tsx+++ b/client/components/build/Center/ArtboardController.tsx@@ -62,7 +62,7 @@ const ArtboardController: React.FC<ReactZoomPanPinchRef> = ({ zoomIn, zoomOut, cconst url = await mutateAsync({ username, slug });- download(url);+ download(`/api${url}`);};return (diff --git a/client/components/build/RightSidebar/sections/Export.tsx b/client/components/build/RightSidebar/sections/Export.tsxindex 9bf8e4458..8607475aa 100644--- a/client/components/build/RightSidebar/sections/Export.tsx+++ b/client/components/build/RightSidebar/sections/Export.tsx@@ -47,7 +47,7 @@ const Export = () => {const url = await mutateAsync({ username, slug });- download(url);+ download(`/api${url}`);};return (diff --git a/client/pages/[username]/[slug]/index.tsx b/client/pages/[username]/[slug]/index.tsxindex 5207e9661..9e2e8c7d4 100644--- a/client/pages/[username]/[slug]/index.tsx+++ b/client/pages/[username]/[slug]/index.tsx@@ -90,7 +90,7 @@ const Preview: NextPage<Props> = ({ username, slug, resume: initialData }) => {try {const url = await mutateAsync({ username, slug });- download(url);+ download(`/api${url}`);} catch {toast.error('Something went wrong, please try again later.');}diff --git a/client/pages/index.tsx b/client/pages/index.tsxindex 04f3c23fc..2edb5d18c 100644--- a/client/pages/index.tsx+++ b/client/pages/index.tsx@@ -162,7 +162,7 @@ const Home: NextPage = () => {</section><section className={styles.section}>- <a href="https://www.digitalocean.com/" target="_blank" rel="noreferrer">+ <a href="https://pillai.xyz/digitalocean" target="_blank" rel="noreferrer"><Image src="/images/sponsors/digitalocean.svg" alt="Powered By DigitalOcean" width={200} height={40} /></a></section>diff --git a/client/pages/r/[shortId].tsx b/client/pages/r/[shortId].tsxindex de0124032..65749f515 100644--- a/client/pages/r/[shortId].tsx+++ b/client/pages/r/[shortId].tsx@@ -60,7 +60,7 @@ const Preview: NextPage<Props> = ({ shortId }) => {try {const url = await mutateAsync({ username: resume.user.username, slug: resume.slug });- download(url);+ download(`/api${url}`);} catch {toast.error('Something went wrong, please try again later.');}diff --git a/client/services/resume.ts b/client/services/resume.tsindex c60274c21..e0387bda8 100644--- a/client/services/resume.ts+++ b/client/services/resume.ts@@ -1,6 +1,6 @@+import env from '@beam-australia/react-env';import { Resume } from '@reactive-resume/schema';-import { AxiosResponse } from 'axios';-import isEmpty from 'lodash/isEmpty';+import _axios, { AxiosResponse } from 'axios';import isBrowser from '@/utils/isBrowser';@@ -22,9 +22,6 @@ export type FetchResumeByIdentifierParams = {export type FetchResumeByShortIdParams = {shortId: string;- options?: {- secretKey?: string;- };};export type RenameResumeParams = {@@ -60,23 +57,26 @@ export type DeleteResumeParams = {export const fetchResumes = () => axios.get<Resume[]>('/resume').then((res) => res.data);-export const fetchResumeByShortId = async ({ shortId, options = { secretKey: '' } }: FetchResumeByShortIdParams) => {- const requestOptions = isEmpty(options.secretKey) ? {} : { params: { secretKey: options.secretKey } };-- return axios.get<Resume>(`/resume/short/${shortId}`, requestOptions).then((res) => res.data);-};-export const fetchResumeByIdentifier = async ({username,slug,options = { secretKey: '' },}: FetchResumeByIdentifierParams) => {- const prefix = !isBrowser && process.env.NODE_ENV === 'development' ? 'http://localhost:3100' : '';- const requestOptions = isEmpty(options.secretKey) ? {} : { params: { secretKey: options.secretKey } };+ if (!isBrowser) {+ const serverUrl = env('SERVER_URL');+ const secretKey = options.secretKey;- return axios.get<Resume>(`${prefix}/resume/${username}/${slug}`, requestOptions).then((res) => res.data);+ return _axios+ .get<Resume>(`${serverUrl}/resume/${username}/${slug}`, { params: { secretKey } })+ .then((res) => res.data);+ }++ return axios.get<Resume>(`/resume/${username}/${slug}`).then((res) => res.data);};+export const fetchResumeByShortId = async ({ shortId }: FetchResumeByShortIdParams) =>+ axios.get<Resume>(`/resume/short/${shortId}`).then((res) => res.data);+export const createResume = (createResumeParams: CreateResumeParams) =>axios.post<Resume, AxiosResponse<Resume>, CreateResumeParams>('/resume', createResumeParams).then((res) => res.data);diff --git a/docker-compose.yml b/docker-compose.ymlindex eb98c5190..fe6a95a23 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -22,6 +22,7 @@ services:container_name: serverenv_file: .envenvironment:+ - PUBLIC_URL=http://client:3000- POSTGRES_HOST=postgresports:- 3100:3100@@ -38,6 +39,8 @@ services:dockerfile: client/Dockerfilecontainer_name: clientenv_file: .env+ environment:+ - PUBLIC_SERVER_URL=http://server:3100ports:- 3000:3000depends_on:diff --git a/package.json b/package.jsonindex 905e99aaf..0c77384a5 100644--- a/package.json+++ b/package.json@@ -17,7 +17,7 @@"lint": "eslint --fix --ext .js,.ts,.tsx .","format": "prettier --write \"./**/*.{js,ts,tsx,json}\"","dev:schema": "pnpm -F schema dev",- "dev:server": "pnpm -F server start:dev",+ "dev:server": "pnpm -F server start:debugc","dev:client": "pnpm -F client dev","dev": "env-cmd --silent concurrently --kill-others \"pnpm run dev:*\"","build:schema": "pnpm -F schema build",diff --git a/server/Dockerfile b/server/Dockerfileindex 69b61fe83..4ea509da9 100644--- a/server/Dockerfile+++ b/server/Dockerfile@@ -31,15 +31,18 @@ FROM mcr.microsoft.com/playwright:focal as productionWORKDIR /app-RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm+RUN apt-get update \+ && apt-get install -y curl \+ && curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpmCOPY --from=builder /app/pnpm-*.yaml ./COPY --from=builder /app/package.json ./-COPY --from=builder /app/server/dist ./server/distCOPY --from=builder /app/server/package.json ./server/package.jsonRUN pnpm install -F server --frozen-lockfile --prod+COPY --from=builder /app/server/dist ./server/dist+EXPOSE 3100ENV PORT 3100diff --git a/server/src/main.ts b/server/src/main.tsindex a1366e87e..4ee0297b4 100644--- a/server/src/main.ts+++ b/server/src/main.ts@@ -10,6 +10,7 @@ const bootstrap = async () => {const app = await NestFactory.create<NestExpressApplication>(AppModule);// Middleware+ app.enableCors({ credentials: true });app.enableShutdownHooks();app.use(cookieParser());diff --git a/server/src/printer/printer.service.ts b/server/src/printer/printer.service.tsindex ba926dadd..392e5ec4d 100644--- a/server/src/printer/printer.service.ts+++ b/server/src/printer/printer.service.ts@@ -7,7 +7,7 @@ import { join } from 'path';import { PDFDocument } from 'pdf-lib';import { Browser, chromium } from 'playwright-chromium';-export const DELETION_TIME = 10 * 1000; // 10 seconds+export const DELETION_TIME = 10 * 1000 * 1000; // 10 seconds@Injectable()export class PrinterService implements OnModuleInit, OnModuleDestroy {