https://github.com/datvt243/nodejs-resume-api-ts
Learning Node.js Express, Project create resume API
https://github.com/datvt243/nodejs-resume-api-ts
api crud-application express joi-validation mongoose nodejs router typescript
Last synced: about 2 months ago
JSON representation
Learning Node.js Express, Project create resume API
- Host: GitHub
- URL: https://github.com/datvt243/nodejs-resume-api-ts
- Owner: datvt243
- Created: 2024-08-06T11:39:42.000Z (almost 2 years ago)
- Default Branch: develop
- Last Pushed: 2026-04-04T11:30:51.000Z (about 2 months ago)
- Last Synced: 2026-04-04T11:35:29.788Z (about 2 months ago)
- Topics: api, crud-application, express, joi-validation, mongoose, nodejs, router, typescript
- Language: TypeScript
- Homepage: https://datvt243.github.io/vue-resume-web/
- Size: 998 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Resume API - Backend (Updated)
Mα»t α»©ng dα»₯ng API backend **hoΓ n chα»nh** Δα» **quαΊ£n lΓ½ hα» sΖ‘ α»©ng viΓͺn (CV/Resume)** vα»i **Redis rate limiting**, **token blacklist**, **PDF export**, **Winston logging**, vΓ **Jest testing**.
**Version**: 1.0.0 | **Author**: DatVT | **License**: ISC
---
## π― Features
- π **Authentication**: JWT (access/refresh), Bcrypt, Token Blacklist (Redis)
- π€ **Profile**: Candidate info + General (skills, languages, career)
- π **Education** / πΌ **Experience** / π **Awards** / π **Certificates** / π **Projects** / π₯ **References**
- π **PDF Export** (Pug + PDFKit/Puppeteer)
- π‘οΈ **Rate Limiting** (Redis/mem fallback)
- π **Logging** (Winston daily)
- π§ͺ **Tests** (Jest: auth/middlewares/utils/DB)
- β
**Health**: `/health` endpoint
## π οΈ Tech Stack
### Core
| Category | Tech |
| --------- | ---------------- |
| Runtime | Node.js |
| Framework | Express 4.19.2 |
| Language | TypeScript 5.5.4 |
### Database & Cache
| Tech | Version | Purpose |
| ------------------ | ------- | ---------------------- |
| MongoDB + Mongoose | 8.4.0 | Data |
| Redis | 4.6.0 | Rate limit / Blacklist |
### Auth & Security
| Tech | Version | Purpose |
| ------------------ | ------- | ---------- |
| JWT | 9.0.2 | Tokens |
| Bcrypt | 5.1.1 | Passwords |
| express-rate-limit | 8.3.0 | Protection |
### Utils
| Tech | Version | Purpose |
| -------------------- | -------------- | ---------- |
| Joi | 17.13.1 | Validation |
| PDFKit/Puppeteer/Pug | 0.15/22.13/3.0 | PDF |
| Winston | 3.19.0 | Logging |
---
## π Project Structure
```
backend/
βββ src/
β βββ server.ts (health/Redis)
β βββ config/ (env/Joi/CORS)
β βββ database/ (Mongo)
β βββ middlewares/ (rateLimit/logger)
β βββ models/ (schemas)
β βββ routers/api/v1/ (CRUD routes)
β βββ candidate_profile/ (controllers/services per section)
β βββ services/ (PDF/Redis)
β βββ utils/ (JWT/bcrypt/blacklist)
β βββ views/ (Pug)
β βββ public/ (assets/pdf)
β βββ __tests__/ (Jest)
β βββ types/
βββ scripts/ (GitHub automation)
βββ TODO.md (progress)
βββ package.json
βββ README.md β Updated
```
---
## π Quick Start
1. **Install**: `npm install`
2. **Env**: `npm run env:setup` + edit `.env`:
```
NODE_ENV=development
LOCAL_PORT=3001
MONGO_URI=... or MONGOBD_USER/PASSWORD
TOKEN_SECRET=... (32+ chars)
TOKEN_REFRESH=...
SESSION_SECRET=...
REDIS_URL=redis://localhost:6379 # Optional
```
3. **Redis** (rec.): `brew install redis && redis-server`
4. **Dev**: `npm run dev` β http://localhost:3001/health
5. **Build/Test**: `npm run build` / `npm test`
**Prod**: `npm run start`
---
## π API Endpoints (v1 - JWT required except auth)
### Auth `/api/v1/auth`
| Method | Path | Desc |
| ------ | ----------- | --------------- |
| POST | `/register` | Create user |
| POST | `/login` | Get tokens |
| POST | `/logout` | Blacklist token |
| POST | `/refresh` | Renew access |
### Candidate `/api/v1/candidate`
| Method | Path | Desc |
| --------- | --------- | ----------- |
| GET | `/:email` | Get profile |
| PUT/PATCH | `/` | Update |
### CRUD Pattern (all sections)
**Paths**: `/api/v1/{education,experience,award,certificate,project,reference,generalInformation}`
| Method | Path | Desc |
|--------|------|------|
| GET | `/` | List |
| POST | `/create` | Create |
| PUT | `/update` | Update |
| DELETE | `/delete/:id` | Delete |
**Header**: `Authorization: Bearer `
---
## π Auth Flow
1. **Login** β `{token, tokenRefresh}`
2. **API Calls**: `Authorization: Bearer ${token}`
3. **Refresh**: POST `/auth/refresh`
4. **Logout**: Blacklist (Redis/utils/tokenBlacklist.ts)
5. **Invalid**: Checked via Redis/mem store
---
## π§ͺ Scripts & Testing
**Scripts**:
- `npm run dev` - Hot reload
- `npm run build` - Compile + copy assets
- `npm run test` - Jest
**Tests (~20 files)**: auth.service/controller, middlewares (rateLimit/logger/verify), utils (bcrypt/valid), database/mongo
---
---
## π‘οΈ Production Notes
- **Rate Limit**: Redis (fallback mem), exempt `/health`
- **Blacklist**: Redis/utils/tokenBlacklist.ts
- **Logs**: Winston daily rotation
- **Static**: public/ (CSS/JS/fonts/img/PDFs)
- **PDF**: services/createPDF.ts + views/
---
## π Troubleshooting
| Issue | Fix |
| ------------ | ------------------------------------ |
| Mongo fail | MONGO*URI or MONGOBD*\* vars |
| Redis fail | `brew install redis` or mem fallback |
| JWT invalid | Token expired/blacklisted |
| Rate limited | Wait / check Redis |
| Build fail | `npm run copy` |
| Logs | Check `logs/` (Winston) |
---
## π Support
Δα» bΓ‘o cΓ‘o bug hoαΊ·c Δα» xuαΊ₯t tΓnh nΔng, vui lΓ²ng tαΊ‘o issue trΓͺn repository.
---
## π¨βπ» Author
**ΔαΊ‘t VΓ΅** - [github.com/datvt243](https://github.com/datvt243)