https://github.com/nshen/nest-vercel-koyeb
https://github.com/nshen/nest-vercel-koyeb
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nshen/nest-vercel-koyeb
- Owner: nshen
- Created: 2024-11-28T16:45:19.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-11-29T04:05:22.000Z (10 months ago)
- Last Synced: 2024-11-29T04:28:17.527Z (10 months ago)
- Language: TypeScript
- Homepage: https://nest-vercel-ten.vercel.app
- Size: 86.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Deploy nest.js to vercel and koyeb
提交 nestjs 代码后自动部署到 vercel 和 koyeb 平台,prisma 数据库用 neon
### 测试地址
GET:
- https://sufficient-marianna-nnnnnn-e6e8714a.koyeb.app/users
- https://nest-vercel-ten.vercel.app/usersPOST:
```json
{
"name": "zz",
"email": "zz@zz.zz"
}
```- https://sufficient-marianna-nnnnnn-e6e8714a.koyeb.app/users
- https://nest-vercel-ten.vercel.app/users### 部署到 vercel
1. 根目录需要添加 `vercel.json`
```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"
]
}
]
}
```2. 需要在postinstall的时候执行 prisma generate 脚本
```json
"scripts": {
...
"postinstall": "pnpm dlx prisma generate"
},
```### 部署到 koyeb
1. start 命令改成对应的 start:prod
```json
"scripts": {
"start": "node dist/main",
...
},
```2. package.json 中指明 pnpm 版本号
```json
{
"name": "nest-vercel-koyeb",
"version": "0.0.1",
"packageManager": "pnpm@9.7.1"
...
}
```### 使用的服务
- Web:
- https://www.koyeb.com/
- https://vercel.com/
- 数据库
- https://neon.tech/