Skip to content

Getting Started

_david edited this page Aug 21, 2026 · 1 revision

Getting Started

Requirements

  • Node.js >=20.19.0 <23.0.0 (Node 24+ breaks jsonwebtoken's dependency chain — see Deployment)
  • npm (uses package-lock.json)
  • A MongoDB instance (Atlas or self-hosted)
  • Redis (optional — falls back to an in-memory store for rate limiting and token blacklist if REDIS_URL is unset or unreachable)

Setup

git clone https://github.com/datvt243/nodejs-resume-api-ts.git
cd nodejs-resume-api-ts
npm install
npm run env:setup   # cp .env.example .env, then fill in real values

Environment variables

NODE_ENV=development
LOCAL_PORT=3001              # prod uses 3008
MONGO_URI=...                # full URI, or use MONGOBD_USER + MONGOBD_PASSWORD
MONGOBD_USER=...
MONGOBD_PASSWORD=...
TOKEN_SECRET=...             # 32+ chars, signs access tokens
TOKEN_REFRESH=...            # signs refresh tokens
TOKEN_EXP_IN=...             # access token expiry (e.g. 3h)
TOKEN_REFRESH_EXP_IN=...     # optional, defaults to 7d — refresh token expiry
SESSION_SECRET=...
REDIS_URL=redis://localhost:6379   # optional; fallback to in-memory if absent/unreachable
MONGO_MAX_POOL_SIZE=10       # optional
MONGO_MIN_POOL_SIZE=2        # optional

Commands

npm run dev                  # ts-node + nodemon hot reload (port 3001)
npm run build                # tsc + copy views/public → dist/
npm start                    # build + NODE_ENV=production node dist/server.js
npm test                     # jest --passWithNoTests

npm run env:setup            # cp .env.example .env
npm run env:dev              # cp .env.development .env
npm run env:prod             # cp .env.production .env
npm run copy                 # copy views + public to dist/ (post-build fix, runs automatically as part of build)

npm run migrate:localize-text  # one-off migration: wraps existing plain-string CV content
                                # into { vi, en } — see Data Models. Idempotent, safe to re-run.

There is no npm run lint script despite .eslintrc.cjs existing in the repo — don't assume it works.

Verifying it's running

curl http://localhost:3001/health
# {"status":"ok","timestamp":"...","uptime":...}

Swagger UI is available at http://localhost:3001/api-docs (raw spec at /api-docs.json).

A note on Node version managers (nvm)

If you use nvm and also have Node installed via Homebrew, make sure your shell's nvm sourcing happens after any Homebrew PATH export in your shell rc file — otherwise nvm use silently has no effect and you'll run whatever Homebrew's node resolves to, which can be newer than this project's supported range.

Clone this wiki locally