From e444e62d5d02137fd845b43ae56841f14f4acf95 Mon Sep 17 00:00:00 2001 From: Nik Graf Date: Tue, 23 Apr 2024 17:23:13 +0200 Subject: [PATCH 1/2] upgrade prisma --- apps/backend/package.json | 6 +- .../comment/getCommentsByDocumentId.ts | 2 +- .../backend/src/database/device/getDevices.ts | 2 +- .../document/getDocumentShareLinks.ts | 2 +- .../src/database/document/getDocuments.ts | 2 +- .../src/database/folder/getSubfolders.ts | 2 +- .../database/folder/getWorkspaceFolders.ts | 2 +- .../userChain/getUserChainByUsername.ts | 2 +- .../workspace/getWorkspaceInvitations.ts | 2 +- .../getWorkspaceMemberDevicesProofs.ts | 2 +- .../database/workspace/getWorkspaceMembers.ts | 2 +- .../src/database/workspace/getWorkspaces.ts | 2 +- .../getWorkspaceChainByInvitationId.ts | 2 +- yarn.lock | 73 +++++++++++++------ 14 files changed, 66 insertions(+), 37 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index 7aacf3be7..a5f830b13 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -10,7 +10,7 @@ "build:copy-externals": "mkdir node_modules/@serenity-kit && cp -r ../../node_modules/@serenity-kit/opaque ./node_modules/@serenity-kit/opaque", "build": "yarn && yarn clean && yarn prisma:prod:generate && yarn ncc build ./src/index.ts -o build --external @serenity-kit/opaque && yarn build:copy-externals", "deploy": "yarn build && fly launch", - "prisma:prod:migrate": "yarn global add prisma@4 && DATABASE_URL=$DATABASE_URL prisma migrate deploy", + "prisma:prod:migrate": "yarn global add prisma@5 && DATABASE_URL=$DATABASE_URL prisma migrate deploy", "prisma:prod:generate": "DATABASE_URL=$DATABASE_URL prisma generate", "prisma:prod:studio": "DATABASE_URL=$DATABASE_URL prisma studio", "prisma:test:studio": "DATABASE_URL=postgres://prisma:prisma@localhost:5432/serenity_test prisma studio", @@ -26,7 +26,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.477.0", "@aws-sdk/s3-request-presigner": "^3.477.0", - "@prisma/client": "^4.8.0", + "@prisma/client": "^5.13.0", "@serenity-kit/opaque": "^0.8.0", "@serenity-tools/common": "*", "@serenity-tools/secsync": "*", @@ -51,7 +51,7 @@ "eslint": "^8.24.0", "graphql-request": "^6.1.0", "jest": "^29.1.1", - "prisma": "^4.8.0", + "prisma": "^5.13.0", "ts-node": "10.9.2", "ts-node-dev": "^2.0.0" }, diff --git a/apps/backend/src/database/comment/getCommentsByDocumentId.ts b/apps/backend/src/database/comment/getCommentsByDocumentId.ts index 5a5437518..cc6a6a39f 100644 --- a/apps/backend/src/database/comment/getCommentsByDocumentId.ts +++ b/apps/backend/src/database/comment/getCommentsByDocumentId.ts @@ -2,7 +2,7 @@ import { ForbiddenError, UserInputError } from "apollo-server-express"; import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/device/getDevices.ts b/apps/backend/src/database/device/getDevices.ts index c19f99664..2c2ce0cf7 100644 --- a/apps/backend/src/database/device/getDevices.ts +++ b/apps/backend/src/database/device/getDevices.ts @@ -2,7 +2,7 @@ import { isDeviceWithUserId } from "../../utils/device/isDeviceWithUserId"; import { prisma } from "../prisma"; type Cursor = { - signingPublicKey?: string; + signingPublicKey: string; }; type Params = { diff --git a/apps/backend/src/database/document/getDocumentShareLinks.ts b/apps/backend/src/database/document/getDocumentShareLinks.ts index ce2090625..be7299e1d 100644 --- a/apps/backend/src/database/document/getDocumentShareLinks.ts +++ b/apps/backend/src/database/document/getDocumentShareLinks.ts @@ -3,7 +3,7 @@ import { Prisma } from "../../../prisma/generated/output"; import { prisma } from "../prisma"; type Cursor = { - token?: string; + token: string; }; type Params = { diff --git a/apps/backend/src/database/document/getDocuments.ts b/apps/backend/src/database/document/getDocuments.ts index 86c55b8ad..c828528ef 100644 --- a/apps/backend/src/database/document/getDocuments.ts +++ b/apps/backend/src/database/document/getDocuments.ts @@ -3,7 +3,7 @@ import { Prisma } from "../../../prisma/generated/output"; import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/folder/getSubfolders.ts b/apps/backend/src/database/folder/getSubfolders.ts index 0668ed29b..012d2e427 100644 --- a/apps/backend/src/database/folder/getSubfolders.ts +++ b/apps/backend/src/database/folder/getSubfolders.ts @@ -3,7 +3,7 @@ import { Prisma } from "../../../prisma/generated/output"; import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/folder/getWorkspaceFolders.ts b/apps/backend/src/database/folder/getWorkspaceFolders.ts index bb68e5e13..7448bdab0 100644 --- a/apps/backend/src/database/folder/getWorkspaceFolders.ts +++ b/apps/backend/src/database/folder/getWorkspaceFolders.ts @@ -3,7 +3,7 @@ import { Prisma } from "../../../prisma/generated/output"; import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/userChain/getUserChainByUsername.ts b/apps/backend/src/database/userChain/getUserChainByUsername.ts index 28263aa3e..6171e24a6 100644 --- a/apps/backend/src/database/userChain/getUserChainByUsername.ts +++ b/apps/backend/src/database/userChain/getUserChainByUsername.ts @@ -1,7 +1,7 @@ import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/workspace/getWorkspaceInvitations.ts b/apps/backend/src/database/workspace/getWorkspaceInvitations.ts index a947641fd..15f3ced8f 100644 --- a/apps/backend/src/database/workspace/getWorkspaceInvitations.ts +++ b/apps/backend/src/database/workspace/getWorkspaceInvitations.ts @@ -4,7 +4,7 @@ import { WorkspaceInvitation } from "../../types/workspace"; import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/workspace/getWorkspaceMemberDevicesProofs.ts b/apps/backend/src/database/workspace/getWorkspaceMemberDevicesProofs.ts index 2aaa3e270..29d23faac 100644 --- a/apps/backend/src/database/workspace/getWorkspaceMemberDevicesProofs.ts +++ b/apps/backend/src/database/workspace/getWorkspaceMemberDevicesProofs.ts @@ -2,7 +2,7 @@ import * as workspaceMemberDevicesProofUtil from "@serenity-kit/workspace-member import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/workspace/getWorkspaceMembers.ts b/apps/backend/src/database/workspace/getWorkspaceMembers.ts index d9ad6b944..fb57abc0d 100644 --- a/apps/backend/src/database/workspace/getWorkspaceMembers.ts +++ b/apps/backend/src/database/workspace/getWorkspaceMembers.ts @@ -3,7 +3,7 @@ import { formatWorkspaceMember } from "../../types/workspace"; import { prisma } from "../prisma"; type Cursor = { - userId?: string; + userId: string; }; type Params = { diff --git a/apps/backend/src/database/workspace/getWorkspaces.ts b/apps/backend/src/database/workspace/getWorkspaces.ts index 6f1b7f92b..c1aef0a63 100644 --- a/apps/backend/src/database/workspace/getWorkspaces.ts +++ b/apps/backend/src/database/workspace/getWorkspaces.ts @@ -2,7 +2,7 @@ import { formatWorkspace } from "../../types/workspace"; import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/apps/backend/src/database/workspaceChain/getWorkspaceChainByInvitationId.ts b/apps/backend/src/database/workspaceChain/getWorkspaceChainByInvitationId.ts index 9a198b1ca..0ea1efcf4 100644 --- a/apps/backend/src/database/workspaceChain/getWorkspaceChainByInvitationId.ts +++ b/apps/backend/src/database/workspaceChain/getWorkspaceChainByInvitationId.ts @@ -1,7 +1,7 @@ import { prisma } from "../prisma"; type Cursor = { - id?: string; + id: string; }; type Params = { diff --git a/yarn.lock b/yarn.lock index ea57bfd3c..202b5c5e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4080,22 +4080,46 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.2.tgz#830beaec4b4091a9e9398ac50f865ddea52186b9" integrity sha512-92FRmppjjqz29VMJ2dn+xdyXZBrMlE42AV6Kq6BwjWV7CNUW1hs2FtxSNLQE+gJhaZ6AAmYuO9y8dshhcBl7vA== -"@prisma/client@^4.8.0": - version "4.8.0" - resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.8.0.tgz#6ec7adaca6a2e233d7e41dbe7cc6d0fa6143a407" - integrity sha512-Y1riB0p2W52kh3zgssP/YAhln3RjBFcJy3uwEiyjmU+TQYh6QTZDRFBo3JtBWuq2FyMOl1Rye8jxzUP+n0l5Cg== - dependencies: - "@prisma/engines-version" "4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe" - -"@prisma/engines-version@4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe": - version "4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe" - resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe.tgz#30401aba1029e7d32e3cb717e705a7c92ccc211e" - integrity sha512-MHSOSexomRMom8QN4t7bu87wPPD+pa+hW9+71JnVcF3DqyyO/ycCLhRL1we3EojRpZxKvuyGho2REQsMCvxcJw== - -"@prisma/engines@4.8.0": - version "4.8.0" - resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.8.0.tgz#5123c67dc0d2caa008268fc63081ca2d68b2ed7e" - integrity sha512-A1Asn2rxZMlLAj1HTyfaCv0VQrLUv034jVay05QlqZg1qiHPeA3/pGTfNMijbsMYCsGVxfWEJuaZZuNxXGMCrA== +"@prisma/client@^5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.13.0.tgz#b9f1d0983d714e982675201d8222a9ecb4bdad4a" + integrity sha512-uYdfpPncbZ/syJyiYBwGZS8Gt1PTNoErNYMuqHDa2r30rNSFtgTA/LXsSk55R7pdRTMi5pHkeP9B14K6nHmwkg== + +"@prisma/debug@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@prisma/debug/-/debug-5.13.0.tgz#d88b0f6fafa0c216e20e284ed9fc30f1cbe45786" + integrity sha512-699iqlEvzyCj9ETrXhs8o8wQc/eVW+FigSsHpiskSFydhjVuwTJEfj/nIYqTaWFYuxiWQRfm3r01meuW97SZaQ== + +"@prisma/engines-version@5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b": + version "5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b" + resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b.tgz#a72a4fb83ba1fd01ad45f795aa55168f60d34723" + integrity sha512-AyUuhahTINGn8auyqYdmxsN+qn0mw3eg+uhkp8zwknXYIqoT3bChG4RqNY/nfDkPvzWAPBa9mrDyBeOnWSgO6A== + +"@prisma/engines@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-5.13.0.tgz#8994ebf7b4e35aee7746a8465ec22738379bcab6" + integrity sha512-hIFLm4H1boj6CBZx55P4xKby9jgDTeDG0Jj3iXtwaaHmlD5JmiDkZhh8+DYWkTGchu+rRF36AVROLnk0oaqhHw== + dependencies: + "@prisma/debug" "5.13.0" + "@prisma/engines-version" "5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b" + "@prisma/fetch-engine" "5.13.0" + "@prisma/get-platform" "5.13.0" + +"@prisma/fetch-engine@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@prisma/fetch-engine/-/fetch-engine-5.13.0.tgz#9b6945c7b38bb59e840f8905b20ea7a3d059ca55" + integrity sha512-Yh4W+t6YKyqgcSEB3odBXt7QyVSm0OQlBSldQF2SNXtmOgMX8D7PF/fvH6E6qBCpjB/yeJLy/FfwfFijoHI6sA== + dependencies: + "@prisma/debug" "5.13.0" + "@prisma/engines-version" "5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b" + "@prisma/get-platform" "5.13.0" + +"@prisma/get-platform@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@prisma/get-platform/-/get-platform-5.13.0.tgz#99ef909a52b9d79b64d72d2d3d8210c4892b6572" + integrity sha512-B/WrQwYTzwr7qCLifQzYOmQhZcFmIFhR81xC45gweInSUn2hTEbfKUPd2keAog+y5WI5xLAFNJ3wkXplvSVkSw== + dependencies: + "@prisma/debug" "5.13.0" "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" @@ -11067,7 +11091,12 @@ graphql-ws@^5.14.0: resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.14.2.tgz#7db6f6138717a544d9480f0213f65f2841ed1c52" integrity sha512-LycmCwhZ+Op2GlHz4BZDsUYHKRiiUz+3r9wbhBATMETNlORQJAaFlAgTFoeRh6xQoQegwYwIylVD1Qns9/DA3w== -graphql@15.8.0, graphql@^16.6.0, graphql@^16.8.1: +graphql@15.8.0: + version "15.8.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.8.0.tgz#33410e96b012fa3bdb1091cc99a94769db212b38" + integrity sha512-5gghUc24tP9HRznNpV2+FIoq3xKkj5dTQqf4v0CpdPbFVwFkWoxOM+o+2OC9ZSvjEMTjfmG9QT+gcvggTwW1zw== + +graphql@^16.8.1: version "16.8.1" resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07" integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw== @@ -15035,12 +15064,12 @@ pretty-format@^29.0.0, pretty-format@^29.7.0: ansi-styles "^5.0.0" react-is "^18.0.0" -prisma@^4.8.0: - version "4.8.0" - resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.8.0.tgz#634dbbdc9d3f76c61604880251673d08ccb6f02b" - integrity sha512-DWIhxvxt8f4h6MDd35mz7BJff+fu7HItW3WPDIEpCR3RzcOWyiHBbLQW5/DOgmf+pRLTjwXQob7kuTZVYUAw5w== +prisma@^5.13.0: + version "5.13.0" + resolved "https://registry.yarnpkg.com/prisma/-/prisma-5.13.0.tgz#1f06e20ccfb6038ad68869e6eacd3b346f9d0851" + integrity sha512-kGtcJaElNRAdAGsCNykFSZ7dBKpL14Cbs+VaQ8cECxQlRPDjBlMHNFYeYt0SKovAVy2Y65JXQwB3A5+zIQwnTg== dependencies: - "@prisma/engines" "4.8.0" + "@prisma/engines" "5.13.0" process-nextick-args@~2.0.0: version "2.0.1" From 7382585d69c50ddd4bb5d01ed49a5b409debe5d5 Mon Sep 17 00:00:00 2001 From: Nik Graf Date: Thu, 25 Apr 2024 06:12:43 +0200 Subject: [PATCH 2/2] fix fly deployment --- apps/backend/Dockerfile | 4 +++- apps/backend/fly.production.toml | 2 ++ apps/backend/fly.staging.toml | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/backend/Dockerfile b/apps/backend/Dockerfile index be6c15c98..01431280e 100644 --- a/apps/backend/Dockerfile +++ b/apps/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18-alpine +FROM node:20-alpine # Create app directory WORKDIR /usr/src/app @@ -6,4 +6,6 @@ WORKDIR /usr/src/app COPY . . EXPOSE $PORT +# necessary for small machines on fly.io to avoid crashing during npm install +ENV NODE_OPTIONS=--max_old_space_size=4096 CMD ["npm", "run", "start:prod" ] \ No newline at end of file diff --git a/apps/backend/fly.production.toml b/apps/backend/fly.production.toml index 0fb706b5f..5993068b3 100644 --- a/apps/backend/fly.production.toml +++ b/apps/backend/fly.production.toml @@ -5,6 +5,8 @@ app = "serenity-api-production" primary_region = "ams" +# necessary for small machines on fly.io to avoid running out of memory +swap_size_mb = 2048 [build] diff --git a/apps/backend/fly.staging.toml b/apps/backend/fly.staging.toml index 789eadd09..c8bf43298 100644 --- a/apps/backend/fly.staging.toml +++ b/apps/backend/fly.staging.toml @@ -5,6 +5,8 @@ app = "serenity-api-staging" primary_region = "ams" +# necessary for small machines on fly.io to avoid running out of memory +swap_size_mb = 2048 [build]