提交 nestjs 代码后自动部署到 vercel 和 koyeb 平台,prisma 数据库用 neon
GET:
- https://sufficient-marianna-nnnnnn-e6e8714a.koyeb.app/users
- https://nest-vercel-ten.vercel.app/users
POST:
{
"name": "zz",
"email": "zz@zz.zz"
}
- https://sufficient-marianna-nnnnnn-e6e8714a.koyeb.app/users
- https://nest-vercel-ten.vercel.app/users
-
根目录需要添加
vercel.json
{ "version": 2, "builds": [ { "src": "src/main.ts", "use": "@vercel/node" } ], "routes": [ { "src": "/(.*)", "dest": "src/main.ts", "methods": [ "GET", "POST", "PUT", "PATCH", "OPTIONS", "DELETE", "HEAD", "CONNECT", "TRACE" ] } ] }
-
需要在postinstall的时候执行 prisma generate 脚本
"scripts": { ... "postinstall": "pnpm dlx prisma generate" },
-
start 命令改成对应的 start:prod
"scripts": { "start": "node dist/main", ... },
-
package.json 中指明 pnpm 版本号
{ "name": "nest-vercel-koyeb", "version": "0.0.1", "packageManager": "pnpm@9.7.1" ... }