Skip to content

Commit

Permalink
feat: ready to deploy nestjs to vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwa committed Jan 29, 2024
0 parents commit 44b3d4d
Show file tree
Hide file tree
Showing 14 changed files with 3,919 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"env": {
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["prettier"],
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"rules": {
"prettier/prettier": "error",
"no-unused-vars":"warn"
},
"ignorePatterns": ["tests","out", "dist", "**/*.d.ts","tsconfig.json"]
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.log
.debug
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"endOfLine": "lf"
}
Empty file added CHANGELOG.md
Empty file.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Vercel-nest

Vercel builder for Nestjs

Help you to deploy [Nestjs](https://docs.nestjs.com/) application on [Vercel](https://vercel.com) in SSR mode

# Usage

## 2. Configure `vercel-nest` as builder in `vercel.json`

### Add a `vercel.json` file to your project root path

```json
{
"version": 2,
"builds": [
{
"src": "package.json",
"use": "vercel-nest"
}
]
}
```
16 changes: 16 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { join } from 'node:path';
import { readFileSync } from 'node:fs';
import { build } from 'esbuild';

const pkgPath = join(process.cwd(), 'package.json');
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
const externals = Object.keys(pkg.dependencies || {});

await build({
entryPoints: ['src/index.ts'],
format: 'cjs',
outdir: 'dist',
platform: 'node',
bundle: true,
external: ['@vercel/build-utils', ...externals],
});
75 changes: 75 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "vercel-nest",
"version": "0.0.1",
"description": "",
"main": "dist/index.js",
"files": [
"dist"
],
"exports": {
".": "./dist/index.js"
},
"repository": {
"url": "https://github.com/dongwa/vercel-nest"
},
"scripts": {
"build": "node build.mjs",
"prepublishOnly": "npm run release",
"release": "npm run build",
"lint": "eslint --ext .js,.ts,.json ./",
"fix": "eslint --ext .js,.ts,.json ./ --fix",
"format": "prettier --config ./.prettierrc --write \"./**/*.{ts,js,json}\" ",
"test": "jest",
"ver": "standard-version",
"vermi": "standard-version -r minor",
"verma": "standard-version -r major",
"verp": "standard-version -p beat"
},
"author": "dongwa",
"license": "MIT",
"jest": {
"transform": {
"^.+\\.(t|j)sx?$": "ts-jest"
},
"testRegex": "(/test/.*|(\\.|/)(test|spec))\\.(ts)$",
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
]
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"@vercel/build-utils": "7.5.1",
"build": "^0.1.4",
"esbuild": "^0.20.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.0.3",
"prettier": "^2.6.2",
"ts-jest": "^28.0.0",
"typescript": "^4.6.4"
},
"dependencies": {
"@types/glob": "^7.2.0",
"@vercel/node-bridge": "^2.2.1",
"@vercel/routing-utils": "^1.13.2",
"consola": "^2.15.3",
"execa": "5.1.1",
"fs-extra": "^10.1.0",
"jiti": "^1.19.1",
"path-to-regexp": "^6.2.1"
},
"standard-version": {
"skip": {
"commit": true,
"tag": true
}
}
}
Loading

0 comments on commit 44b3d4d

Please sign in to comment.