Skip to content

Commit

Permalink
feat: move to node18 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
rqbazan authored Feb 14, 2024
1 parent 2252239 commit 436804e
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 36 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
44 changes: 22 additions & 22 deletions api/resume.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import type { VercelRequest, VercelResponse } from '@vercel/node'
import type { Lang } from '../src/types'
import { getTechProfile, getTechResume } from '../src/lib/airtable'
import type { VercelRequest, VercelResponse } from "@vercel/node";
import type { Lang } from "../src/types";
import { getTechProfile, getTechResume } from "../src/lib/airtable.js";

// @ts-ignore
import { renderAppToStream } from '../.lib/server'
import { renderAppToStream } from "../.lib/server.cjs";

type Query = {
id: string
lang: Lang
}
id: string;
lang: Lang;
};

export default async (req: VercelRequest, res: VercelResponse) => {
const { id, lang = 'en' } = req.query as Query
const { id, lang = "en" } = req.query as Query;

const [techProfile, techResume] = await Promise.all([
getTechProfile(),
getTechResume({ id, lang }),
])
]);

if (!techResume) {
return res.redirect(techProfile.website)
return res.redirect(techProfile.website);
}

const appProps = {
lang,
techProfile,
techResume,
};

if (process.env.NODE_ENV !== "production") {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET,OPTIONS");
res.setHeader("Cache-Control", "max-age=60");
res.json(appProps);
return;
}

if (process.env.NODE_ENV !== 'production') {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Methods', 'GET,OPTIONS')
res.setHeader('Cache-Control', 'max-age=60')
res.json(appProps)
return
}

const stream = await renderAppToStream(appProps)
res.setHeader('Content-Type', 'application/pdf')
stream.pipe(res)
}
const stream = await renderAppToStream(appProps);
res.setHeader("Content-Type", "application/pdf");
stream.pipe(res);
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "resume",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"scripts": {
"dev:web": "vite",
"build:browser": "vite build",
"build:server": "node ./scripts/build.js",
"build:server": "node ./scripts/build.cjs",
"vercel-build": "npm run build:server",
"typecheck": "tsc --noEmit"
},
Expand All @@ -24,6 +25,7 @@
"@types/react-dom": "17.0.0",
"@vercel/node": "1.12.1",
"@vitejs/plugin-react": "1.0.0",
"esbuild": "^0.20.0",
"npm-run-all": "4.1.5",
"typescript": "4.3.2",
"vite": "2.6.4"
Expand Down
12 changes: 12 additions & 0 deletions scripts/build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require("esbuild").build({
entryPoints: ["./src/server/main.tsx"],
inject: ["./src/server/react-shim.ts"],
bundle: true,
minify: true,
platform: "node",
target: "node18",
outfile: ".lib/server.cjs",
loader: {
".ttf": "dataurl",
},
});
12 changes: 0 additions & 12 deletions scripts/build.js

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": ".",
"baseUrl": "./",
"paths": {
"~/*": ["src/*"]
}
Expand Down
144 changes: 144 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,121 @@
"@babel/helper-validator-identifier" "^7.15.7"
to-fast-properties "^2.0.0"

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.20.0.tgz#509621cca4e67caf0d18561a0c56f8b70237472f"
integrity sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.20.0.tgz#109a6fdc4a2783fc26193d2687827045d8fef5ab"
integrity sha512-aVpnM4lURNkp0D3qPoAzSG92VXStYmoVPOgXveAUoQBWRSuQzt51yvSju29J6AHPmwY1BjH49uR29oyfH1ra8Q==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.20.0.tgz#1397a2c54c476c4799f9b9073550ede496c94ba5"
integrity sha512-3bMAfInvByLHfJwYPJRlpTeaQA75n8C/QKpEaiS4HrFWFiJlNI0vzq/zCjBrhAYcPyVPG7Eo9dMrcQXuqmNk5g==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.20.0.tgz#2b615abefb50dc0a70ac313971102f4ce2fdb3ca"
integrity sha512-uK7wAnlRvjkCPzh8jJ+QejFyrP8ObKuR5cBIsQZ+qbMunwR8sbd8krmMbxTLSrDhiPZaJYKQAU5Y3iMDcZPhyQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.20.0.tgz#5c122ed799eb0c35b9d571097f77254964c276a2"
integrity sha512-AjEcivGAlPs3UAcJedMa9qYg9eSfU6FnGHJjT8s346HSKkrcWlYezGE8VaO2xKfvvlZkgAhyvl06OJOxiMgOYQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.20.0.tgz#9561d277002ba8caf1524f209de2b22e93d170c1"
integrity sha512-bsgTPoyYDnPv8ER0HqnJggXK6RyFy4PH4rtsId0V7Efa90u2+EifxytE9pZnsDgExgkARy24WUQGv9irVbTvIw==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.0.tgz#84178986a3138e8500d17cc380044868176dd821"
integrity sha512-kQ7jYdlKS335mpGbMW5tEe3IrQFIok9r84EM3PXB8qBFJPSc6dpWfrtsC/y1pyrz82xfUIn5ZrnSHQQsd6jebQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.20.0.tgz#3f9ce53344af2f08d178551cd475629147324a83"
integrity sha512-uG8B0WSepMRsBNVXAQcHf9+Ko/Tr+XqmK7Ptel9HVmnykupXdS4J7ovSQUIi0tQGIndhbqWLaIL/qO/cWhXKyQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.20.0.tgz#24efa685515689df4ecbc13031fa0a9dda910a11"
integrity sha512-uTtyYAP5veqi2z9b6Gr0NUoNv9F/rOzI8tOD5jKcCvRUn7T60Bb+42NDBCWNhMjkQzI0qqwXkQGo1SY41G52nw==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.20.0.tgz#6b586a488e02e9b073a75a957f2952b3b6e87b4c"
integrity sha512-2ezuhdiZw8vuHf1HKSf4TIk80naTbP9At7sOqZmdVwvvMyuoDiZB49YZKLsLOfKIr77+I40dWpHVeY5JHpIEIg==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.20.0.tgz#84ce7864f762708dcebc1b123898a397dea13624"
integrity sha512-c88wwtfs8tTffPaoJ+SQn3y+lKtgTzyjkD8NgsyCtCmtoIC8RDL7PrJU05an/e9VuAke6eJqGkoMhJK1RY6z4w==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.20.0.tgz#1922f571f4cae1958e3ad29439c563f7d4fd9037"
integrity sha512-lR2rr/128/6svngnVta6JN4gxSXle/yZEZL3o4XZ6esOqhyR4wsKyfu6qXAL04S4S5CgGfG+GYZnjFd4YiG3Aw==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.20.0.tgz#7ca1bd9df3f874d18dbf46af009aebdb881188fe"
integrity sha512-9Sycc+1uUsDnJCelDf6ZNqgZQoK1mJvFtqf2MUz4ujTxGhvCWw+4chYfDLPepMEvVL9PDwn6HrXad5yOrNzIsQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.20.0.tgz#8f95baf05f9486343bceeb683703875d698708a4"
integrity sha512-CoWSaaAXOZd+CjbUTdXIJE/t7Oz+4g90A3VBCHLbfuc5yUQU/nFDLOzQsN0cdxgXd97lYW/psIIBdjzQIwTBGw==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.20.0.tgz#ca63b921d5fe315e28610deb0c195e79b1a262ca"
integrity sha512-mlb1hg/eYRJUpv8h/x+4ShgoNLL8wgZ64SUr26KwglTYnwAWjkhR2GpoKftDbPOCnodA9t4Y/b68H4J9XmmPzA==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.20.0.tgz#cb3d069f47dc202f785c997175f2307531371ef8"
integrity sha512-fgf9ubb53xSnOBqyvWEY6ukBNRl1mVX1srPNu06B6mNsNK20JfH6xV6jECzrQ69/VMiTLvHMicQR/PgTOgqJUQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.20.0.tgz#ac617e0dc14e9758d3d7efd70288c14122557dc7"
integrity sha512-H9Eu6MGse++204XZcYsse1yFHmRXEWgadk2N58O/xd50P9EvFMLJTQLg+lB4E1cF2xhLZU5luSWtGTb0l9UeSg==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.20.0.tgz#6cc778567f1513da6e08060e0aeb41f82eb0f53c"
integrity sha512-lCT675rTN1v8Fo+RGrE5KjSnfY0x9Og4RN7t7lVrN3vMSjy34/+3na0q7RIfWDAj0e0rCh0OL+P88lu3Rt21MQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.20.0.tgz#76848bcf76b4372574fb4d06cd0ed1fb29ec0fbe"
integrity sha512-HKoUGXz/TOVXKQ+67NhxyHv+aDSZf44QpWLa3I1lLvAwGq8x1k0T+e2HHSRvxWhfJrFxaaqre1+YyzQ99KixoA==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.20.0.tgz#ea4cd0639bf294ad51bc08ffbb2dac297e9b4706"
integrity sha512-GDwAqgHQm1mVoPppGsoq4WJwT3vhnz/2N62CzhvApFD1eJyTroob30FPpOZabN+FgCjhG+AgcZyOPIkR8dfD7g==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.20.0.tgz#a5c171e4a7f7e4e8be0e9947a65812c1535a7cf0"
integrity sha512-0vYsP8aC4TvMlOQYozoksiaxjlvUcQrac+muDqj1Fxy6jh9l9CZJzj7zmh8JGfiV49cYLTorFLxg7593pGldwQ==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.20.0.tgz#f8ac5650c412d33ea62d7551e0caf82da52b7f85"
integrity sha512-p98u4rIgfh4gdpV00IqknBD5pC84LCub+4a3MO+zjqvU5MVXOc3hqR2UgT2jI2nh3h8s9EQxmOsVI3tyzv1iFg==

"@esbuild/[email protected]":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.20.0.tgz#2efddf82828aac85e64cef62482af61c29561bee"
integrity sha512-NgJnesu1RtWihtTtXGFMU5YSE6JyyHPMxCwBZK7a6/8d31GuSo9l0Ss7w1Jw5QnKUawG6UEehs883kcXf5fYwg==

"@react-pdf/font@^2.0.13":
version "2.0.13"
resolved "https://registry.yarnpkg.com/@react-pdf/font/-/font-2.0.13.tgz#0bfbff3db23dc8aff10498f5b5ddad46b02d30d8"
Expand Down Expand Up @@ -973,6 +1088,35 @@ esbuild@^0.13.2:
esbuild-windows-64 "0.13.12"
esbuild-windows-arm64 "0.13.12"

esbuild@^0.20.0:
version "0.20.0"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.20.0.tgz#a7170b63447286cd2ff1f01579f09970e6965da4"
integrity sha512-6iwE3Y2RVYCME1jLpBqq7LQWK3MW6vjV2bZy6gt/WrqkY+WE74Spyc0ThAOYpMtITvnjX09CrC6ym7A/m9mebA==
optionalDependencies:
"@esbuild/aix-ppc64" "0.20.0"
"@esbuild/android-arm" "0.20.0"
"@esbuild/android-arm64" "0.20.0"
"@esbuild/android-x64" "0.20.0"
"@esbuild/darwin-arm64" "0.20.0"
"@esbuild/darwin-x64" "0.20.0"
"@esbuild/freebsd-arm64" "0.20.0"
"@esbuild/freebsd-x64" "0.20.0"
"@esbuild/linux-arm" "0.20.0"
"@esbuild/linux-arm64" "0.20.0"
"@esbuild/linux-ia32" "0.20.0"
"@esbuild/linux-loong64" "0.20.0"
"@esbuild/linux-mips64el" "0.20.0"
"@esbuild/linux-ppc64" "0.20.0"
"@esbuild/linux-riscv64" "0.20.0"
"@esbuild/linux-s390x" "0.20.0"
"@esbuild/linux-x64" "0.20.0"
"@esbuild/netbsd-x64" "0.20.0"
"@esbuild/openbsd-x64" "0.20.0"
"@esbuild/sunos-x64" "0.20.0"
"@esbuild/win32-arm64" "0.20.0"
"@esbuild/win32-ia32" "0.20.0"
"@esbuild/win32-x64" "0.20.0"

escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
Expand Down

0 comments on commit 436804e

Please sign in to comment.