Repository navigation
Home
_david edited this page Oct 26, 2026
·
5 revisions
Node.js/TypeScript REST API for managing candidate CVs/resumes: JWT auth (cookie + Bearer, CSRF-protected, refresh-token reuse detection), CRUD for 7 CV sections plus a job-application tracker and named CV profiles, PDF/DOCX export (classic/modern/ATS templates + ATS self-check), public profile search, Redis-backed rate limiting/token blacklist, LinkedIn-export and PDF-CV import, visit analytics, and i18n (vi/en).
Version: 2.2.2 · Author: DatVT · License: ISC · Live: nodejs-resume-api-ts.onrender.com
- Getting Started — clone, env setup, run locally (or via Docker), all npm scripts
- Architecture — project structure, request/middleware flow, module layout
- API Reference — every endpoint, grouped by area
- API Response & Error Standard — response envelope, status codes, error-code catalog, backend + client rules, rollout
- Authentication — JWT (cookie + Bearer) flow, CSRF, token blacklist, session revocation, i18n messages
- Data Models — Candidate + CV sections + Application/Profile/Visit, multi-language content shape, soft-delete
- Security — protections in place, invariants, past incidents and fixes
- Deployment — branching model, Render + GitHub Actions pipeline, Docker, known gotchas
- Contributing — branch/PR conventions, testing, issue tracker
| Layer | Tech |
|---|---|
| Runtime | Node.js >=20.19.0 <23.0.0 + TypeScript 5.5 (strict + noUncheckedIndexedAccess, exactOptionalPropertyTypes, … — CommonJS) |
| Framework | Express 4.19 |
| Database | MongoDB + Mongoose 8.4 |
| Cache / Blacklist | Redis 4.6 (in-memory fallback if unset/unreachable) |
| Auth | JWT (access + refresh, httpOnly cookie or Bearer), Bcrypt (12 rounds), double-submit CSRF |
| HTTP hardening | helmet 8, 1 MB body limit, HTTP→HTTPS redirect in prod, graceful shutdown |
| Validation | Joi 17.13 |
| PDF / DOCX | Puppeteer 22.13 (classic/modern/ATS) + pdf-lib (metadata) + pdf-parse (text extraction) + xss / docx 9.7 |
| Uploads / parsing | multer 2.3 (CV/image/LinkedIn-export/PDF-CV uploads), adm-zip + csv-parse (LinkedIn export), pdf-parse (PDF CV import) |
| Logging | Winston 3.19 + daily-rotate-file |
| Testing / lint | Jest 29 + ts-jest · ESLint 9 (flat config, type-aware) |
| i18n | Hand-rolled (Accept-Language, vi default / en opt-in), 100+ message keys across auth/candidate/CV-section/images |
-
Unified response/error envelope (#272–#278, breaking in v2.0.0) — every success is
{ success:true, message, data, meta? }, every list returnsdata: []+metapagination, every error is{ success:false, error:{ code, message, details? } }with a single code→status map. Services throwAppErrorsubclasses; unknown routes on any method return 404. See API Response & Error Standard. -
CV export templates —
?template=classic|modern|atsonGET /download-pdf(#162); the ATS template is single-column with PDF metadata, andPOST /api/v1/cv/ats-checkscores your own CV against 10 ATS checks (+ optional job-description keyword coverage). -
Public surface — keyword search over public profiles (
GET /api/me/search, #163) and an unauthenticated public ATS PDF (GET /api/me/:identifier/download-pdf, #217). -
Import — parse an existing PDF CV into Education/Experience entries (
POST /candidate/parse-cv-pdf, #234), plus best-effort bulk create (POST /education/bulk,/experience/bulk). -
Visit analytics —
GET /candidate/visits/stats(#164): zero-filled time series, country, referrer source (#248) and viewed-CV-profile (#253) breakdowns. - Data — LinkedIn-style career breaks on Experience (#267); each Application can link to the CV Profile that was sent (#256).
- Auth — reuse of a rotated refresh token (after a 10 s grace window) revokes every session of that candidate (#165); rotation is claimed atomically (#262).
-
Hardening — helmet security headers, explicit 1 MB request body limit, HTTP→HTTPS redirect in production, graceful shutdown on SIGTERM/SIGINT, full type-safety pass (#177) + type-aware ESLint 9 (
npm run lint). -
Fixes — public profile no longer shows soft-deleted entries (#261);
POST /{section}/createreturns the created document (not the list);POST /api/me/:identifier/visitaccepts the vanity slug; Puppeteer's Chrome is kept inside the project dir for Render (#298).
-
CSRF + httpOnly cookie auth (#119, #134) — tokens can now travel as httpOnly cookies (needed once the frontend and API became genuinely cross-site), with a real double-submit CSRF check replacing the incidental protection that
SameSite=strictused to provide. -
Soft-delete + restore (#121) across every CV section — deletes are now recoverable (
POST .../restore/:id) instead of permanent. - CV Profiles (#133) — a candidate can define named subsets ("Tổng hợp"/All by default, plus custom ones) of their Education/Experience/Project/Certificate/Award/Reference entries, and share a public link filtered to just one profile.
-
Job Application tracker (#132) — a private
applicationsCV-section (applied/interview/offer/rejected pipeline), separate from the public CV. - LinkedIn export import (#141) — upload a LinkedIn "Data export" ZIP, get back parsed Education/Experience entries for the frontend to review before saving (stateless, nothing persisted server-side).
-
Vanity slug public profiles (#120) —
GET /api/me/:slug-or-email, plus per-visit analytics (IP + geo). - Logout of all devices (#74), pagination/sort on CV-section lists (#73), DOCX export alongside PDF, and Docker support for local/dev/prod parity.
- Two real security incidents were found and fixed via
/code-review: a NoSQL-filter-collapse bug that could leak an arbitrary candidate's profile (#135), and a soft-delete bypass that let an already-deleted document still be mutated via update/patch (#136) — see Security for both.
See Security for incident writeups and Data Models for the current schema shape. Full technical evidence for every change lives in the repo at agent-hub/evidence/.