mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-26 17:48:30 -04:00
migrate to prisma accelerate
https://prismaio.notion.site/Migration-Guide-For-Data-Proxy-Users-Moving-to-Prisma-Accelerate-5df9
This commit is contained in:
parent
bc77e502b9
commit
14cd879207
@ -43,7 +43,7 @@ const Link = ({ href, rel, target, prefetch = false, underline = true, openInNew
|
|||||||
// links) or a new tab (the default for external links). Defaults can be overridden with `openInNewTab={true}`.
|
// links) or a new tab (the default for external links). Defaults can be overridden with `openInNewTab={true}`.
|
||||||
const isExternal =
|
const isExternal =
|
||||||
typeof href === "string" &&
|
typeof href === "string" &&
|
||||||
!(href.startsWith("/") || href.startsWith("#") || (process.env.BASE_URL && href.startsWith(process.env.BASE_URL)));
|
!(href[0] === "/" || href[0] === "#" || (process.env.BASE_URL && href.startsWith(process.env.BASE_URL)));
|
||||||
|
|
||||||
if (openInNewTab || isExternal) {
|
if (openInNewTab || isExternal) {
|
||||||
return (
|
return (
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
export const restoreTheme = () => {
|
export const restoreTheme = () => {
|
||||||
// `try/catch` in case I messed something up here bigly... (will default to light theme)
|
// `try/catch` in case I messed something up here bigly... (will default to light theme)
|
||||||
try {
|
try {
|
||||||
// map of themes -> classnames ([0]=light, [1]=dark)
|
// help minifier minify
|
||||||
const classNames = ["__CLASS_NAMES__"];
|
const htmlRoot = document.documentElement;
|
||||||
// the list of <html>'s current class(es)...
|
// the list of <html>'s current class(es)...
|
||||||
// eslint-disable-next-line prefer-destructuring
|
// eslint-disable-next-line prefer-destructuring
|
||||||
const classList = document.documentElement.classList;
|
const classList = htmlRoot.classList;
|
||||||
|
// map of themes -> classnames ([0]=light, [1]=dark)
|
||||||
|
const classNames = ["__CLASS_NAMES__"];
|
||||||
// user's saved preference
|
// user's saved preference
|
||||||
const pref = typeof Storage !== "undefined" ? window.localStorage.getItem("__STORAGE_KEY__") : null;
|
const pref = typeof Storage !== "undefined" ? window.localStorage.getItem("__STORAGE_KEY__") : null;
|
||||||
|
|
||||||
@ -21,6 +23,9 @@ export const restoreTheme = () => {
|
|||||||
classList.remove(...classNames);
|
classList.remove(...classNames);
|
||||||
|
|
||||||
// ...and then FINALLY set the root class
|
// ...and then FINALLY set the root class
|
||||||
classList.add(classNames[newTheme]);
|
classList.add(classNames[newTheme] || "");
|
||||||
|
|
||||||
|
// set "color-scheme" inline css property
|
||||||
|
htmlRoot.style.colorScheme = newTheme === 1 ? "dark" : "light";
|
||||||
} catch (error) {} // eslint-disable-line no-empty
|
} catch (error) {} // eslint-disable-line no-empty
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { PrismaClient } from "@prisma/client/edge";
|
import { PrismaClient } from "@prisma/client/edge";
|
||||||
|
import { withAccelerate } from "@prisma/extension-accelerate";
|
||||||
|
|
||||||
// creating PrismaClient here prevents next.js from starting too many concurrent prisma instances and exhausting the
|
// creating PrismaClient here prevents next.js from starting too many concurrent prisma instances and exhausting the
|
||||||
// number of connection pools available (especially when hot reloading from `next dev`).
|
// number of connection pools available (especially when hot reloading from `next dev`).
|
||||||
// https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices
|
// https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices
|
||||||
|
|
||||||
const prismaClientSingleton = () => {
|
const prismaClientSingleton = () => {
|
||||||
return new PrismaClient();
|
return new PrismaClient().$extends(withAccelerate());
|
||||||
};
|
};
|
||||||
|
|
||||||
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;
|
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;
|
||||||
|
@ -15,15 +15,16 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint . --ext js,jsx,ts,tsx,md,mdx",
|
"lint": "eslint . --ext js,jsx,ts,tsx,md,mdx",
|
||||||
"postinstall": "prisma generate --data-proxy"
|
"postinstall": "prisma generate --no-engine"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@giscus/react": "^2.3.0",
|
"@giscus/react": "^2.3.0",
|
||||||
"@hcaptcha/react-hcaptcha": "^1.8.1",
|
"@hcaptcha/react-hcaptcha": "^1.8.1",
|
||||||
"@novnc/novnc": "1.4.0",
|
"@novnc/novnc": "1.4.0",
|
||||||
"@octokit/graphql": "^7.0.2",
|
"@octokit/graphql": "^7.0.2",
|
||||||
"@octokit/graphql-schema": "^14.33.0",
|
"@octokit/graphql-schema": "^14.33.1",
|
||||||
"@prisma/client": "^5.3.1",
|
"@prisma/client": "^5.3.1",
|
||||||
|
"@prisma/extension-accelerate": "^0.6.2",
|
||||||
"@react-spring/web": "^9.7.3",
|
"@react-spring/web": "^9.7.3",
|
||||||
"@stitches/react": "1.3.1-1",
|
"@stitches/react": "1.3.1-1",
|
||||||
"@vercel/postgres": "^0.5.0",
|
"@vercel/postgres": "^0.5.0",
|
||||||
@ -77,7 +78,7 @@
|
|||||||
"@types/novnc__novnc": "^1.3.2",
|
"@types/novnc__novnc": "^1.3.2",
|
||||||
"@types/prop-types": "^15.7.8",
|
"@types/prop-types": "^15.7.8",
|
||||||
"@types/react": "^18.2.24",
|
"@types/react": "^18.2.24",
|
||||||
"@types/react-dom": "^18.2.8",
|
"@types/react-dom": "^18.2.9",
|
||||||
"@types/react-is": "^18.2.2",
|
"@types/react-is": "^18.2.2",
|
||||||
"@types/remove-markdown": "^0.3.2",
|
"@types/remove-markdown": "^0.3.2",
|
||||||
"@types/uglify-js": "^3.17.2",
|
"@types/uglify-js": "^3.17.2",
|
||||||
|
@ -15,6 +15,9 @@ export default async () => {
|
|||||||
hits: "desc",
|
hits: "desc",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
// cache db results for 5 minutes. prisma accelerate only:
|
||||||
|
// https://www.prisma.io/docs/data-platform/accelerate/concepts#cache-strategies
|
||||||
|
cacheStrategy: { swr: 300, ttl: 60 },
|
||||||
});
|
});
|
||||||
|
|
||||||
const total = { hits: 0 };
|
const total = { hits: 0 };
|
||||||
|
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
@ -18,11 +18,14 @@ dependencies:
|
|||||||
specifier: ^7.0.2
|
specifier: ^7.0.2
|
||||||
version: 7.0.2
|
version: 7.0.2
|
||||||
'@octokit/graphql-schema':
|
'@octokit/graphql-schema':
|
||||||
specifier: ^14.33.0
|
specifier: ^14.33.1
|
||||||
version: 14.33.0
|
version: 14.33.1
|
||||||
'@prisma/client':
|
'@prisma/client':
|
||||||
specifier: ^5.3.1
|
specifier: ^5.3.1
|
||||||
version: 5.3.1(prisma@5.3.1)
|
version: 5.3.1(prisma@5.3.1)
|
||||||
|
'@prisma/extension-accelerate':
|
||||||
|
specifier: ^0.6.2
|
||||||
|
version: 0.6.2(@prisma/client@5.3.1)
|
||||||
'@react-spring/web':
|
'@react-spring/web':
|
||||||
specifier: ^9.7.3
|
specifier: ^9.7.3
|
||||||
version: 9.7.3(react-dom@18.2.0)(react@18.2.0)
|
version: 9.7.3(react-dom@18.2.0)(react@18.2.0)
|
||||||
@ -184,8 +187,8 @@ devDependencies:
|
|||||||
specifier: ^18.2.24
|
specifier: ^18.2.24
|
||||||
version: 18.2.24
|
version: 18.2.24
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
specifier: ^18.2.8
|
specifier: ^18.2.9
|
||||||
version: 18.2.8
|
version: 18.2.9
|
||||||
'@types/react-is':
|
'@types/react-is':
|
||||||
specifier: ^18.2.2
|
specifier: ^18.2.2
|
||||||
version: 18.2.2
|
version: 18.2.2
|
||||||
@ -573,8 +576,8 @@ packages:
|
|||||||
universal-user-agent: 6.0.0
|
universal-user-agent: 6.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@octokit/graphql-schema@14.33.0:
|
/@octokit/graphql-schema@14.33.1:
|
||||||
resolution: {integrity: sha512-CGQABVHs5hm7lpeqjcGOVc+115EYHfiYUttauHx03Q/Qj13h2dJgyi4U3Eh5g5Y9J6dDyjyWkU9iiwUiGbn3Og==}
|
resolution: {integrity: sha512-PPWDlxT5UUtmy0cTfVEsLXhyX/EQZh6ve+5j3oJQSZ5klhJMDl1ZtVrB6v163bbkdLsoDZBdHeBJKvDBvFXadQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
graphql: 16.8.1
|
graphql: 16.8.1
|
||||||
graphql-tag: 2.12.6(graphql@16.8.1)
|
graphql-tag: 2.12.6(graphql@16.8.1)
|
||||||
@ -660,6 +663,15 @@ packages:
|
|||||||
resolution: {integrity: sha512-6QkILNyfeeN67BNEPEtkgh3Xo2tm6D7V+UhrkBbRHqKw9CTaz/vvTP/ROwYSP/3JT2MtIutZm/EnhxUiuOPVDA==}
|
resolution: {integrity: sha512-6QkILNyfeeN67BNEPEtkgh3Xo2tm6D7V+UhrkBbRHqKw9CTaz/vvTP/ROwYSP/3JT2MtIutZm/EnhxUiuOPVDA==}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
|
|
||||||
|
/@prisma/extension-accelerate@0.6.2(@prisma/client@5.3.1):
|
||||||
|
resolution: {integrity: sha512-KIBVPeWt8qaSg7wQ+TXmCVeUDoW75whtXcdS9dbHxRoO2OWFH5I9+qbkHBhx5Wj/h1wQpS8usuxGnsZqiBjUpQ==}
|
||||||
|
engines: {node: '>=16'}
|
||||||
|
peerDependencies:
|
||||||
|
'@prisma/client': '>=4.16.1'
|
||||||
|
dependencies:
|
||||||
|
'@prisma/client': 5.3.1(prisma@5.3.1)
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@react-spring/animated@9.7.3(react@18.2.0):
|
/@react-spring/animated@9.7.3(react@18.2.0):
|
||||||
resolution: {integrity: sha512-5CWeNJt9pNgyvuSzQH+uy2pvTg8Y4/OisoscZIR8/ZNLIOI+CatFBhGZpDGTF/OzdNFsAoGk3wiUYTwoJ0YIvw==}
|
resolution: {integrity: sha512-5CWeNJt9pNgyvuSzQH+uy2pvTg8Y4/OisoscZIR8/ZNLIOI+CatFBhGZpDGTF/OzdNFsAoGk3wiUYTwoJ0YIvw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -830,8 +842,8 @@ packages:
|
|||||||
/@types/prop-types@15.7.8:
|
/@types/prop-types@15.7.8:
|
||||||
resolution: {integrity: sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ==}
|
resolution: {integrity: sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ==}
|
||||||
|
|
||||||
/@types/react-dom@18.2.8:
|
/@types/react-dom@18.2.9:
|
||||||
resolution: {integrity: sha512-bAIvO5lN/U8sPGvs1Xm61rlRHHaq5rp5N3kp9C+NJ/Q41P8iqjkXSu0+/qu8POsjH9pNWb0OYabFez7taP7omw==}
|
resolution: {integrity: sha512-6nNhVzZ9joQ6F7lozrASuQKC0Kf6ArYMU+DqA2ZrUbB+d+9lC6ZLn1GxiEBI1edmAwvTULtuJ6uPZpv3XudwUg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/react': 18.2.24
|
'@types/react': 18.2.24
|
||||||
dev: true
|
dev: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user