src/
├── auth/ # Login, signup, JWT creation and verification
├── common/
│ └── guards/ # JWT & role guards
├── shift/ # Shift CRUD operations
├── tasks/ # Mission CRUD operations
├── users/ # Soldiers and commanders management
├── app.module.ts # Main module
└── main.ts # Entry point
- JWT-based authentication
- Role-based authorization: commander / soldier
- Three main tables:
users,tasks,shift - Guards to restrict access based on role
- Hashed passwords with
bcrypt - Data managed with TypeORM and MySQL (phpMyAdmin)
- Create soldier/commander: open to all (no auth required)
- Delete, Get All, Get by ID: commander only
- Fields:
id,description - Full CRUD: commander only
- Fields:
start_time,end_time,user_id,task_id - Create, Delete, Get All: commander only
- Get soldier's shifts: accessible by that soldier (via token)
/auth/login: login and receive JWT/auth/signing: validate JWT (used by guards internally)- Passwords hashed with
bcryptusing a secret key - JWT contains role (
soldierorcommander) anduserId
JwtGuard: Validates the presence and integrity of the tokenRolesGuard: Checks whether the user has access to specific routes
⚠️ Public route: onlyPOST /users(register soldier/commander) is available without a token.
- Node.js & npm
- MySQL/phpMyAdmin installed and running
npm install# Development
npm run start
# Watch mode (auto reload)
npm run start:devcurl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "yoel", "password": "1234"}'curl -X GET http://localhost:3000/auth/signing \
-H "Authorization: Bearer YOUR_TOKEN"curl -X POST http://localhost:3000/users \
-H "Content-Type: application/json" \
-d '{"username": "newUser", "password": "pass123", "role": "soldier"}'This project is currently used for local development only.
- Built using NestJS framework
- Organized by modules (feature-based structure)
- Database structure can be found inside your MySQL/phpMyAdmin instance
Project repository: https://github.com/yoel-cmd/nestProject
Yoel Ider A highly motivated full-stack developer passionate about backend security and military tech.
This project is licensed under the MIT License.