This is a Node.js + Express.js application written in TypeScript that demonstrates:
- A CRUD API for blog articles
- Authentication (user registration and login)
- DynamoDB Local integration
- Redis caching
- Jest unit tests
- A multi-layered architecture (controller, service, model) with best practices
-
User Authentication
- Register new users with hashed passwords
- Login returns a JWT
- Middleware to restrict certain routes to logged-in users only
-
Article CRUD
- Create, read, update, and delete blog articles
- Uses DynamoDB Local for data storage
- Integrates with Redis for caching
-
Error Handling
- Custom
AppErrorclass for structured error messages and HTTP status codes - Logs errors using a custom logger
- Custom
-
Testing
- Jest-based unit tests for
authandarticleservices
- Jest-based unit tests for
-
Docker & Docker Compose
- Dockerfile for Node application
- Compose services for local DynamoDB, Redis, and the Node backend
- Node.js (16.x or later recommended)
- npm or yarn
- Docker (for local development with containers)
- (Optional) AWS CLI for interacting with DynamoDB Local
-
Clone the repository:
git clone https://github.com/your-username/blog-app-backend.git cd blog-app-backend -
Running with Docker
docker compose up -d
-
Run Migration
npm run migrate
- .env
- Run in multi thread of CPU.
- The postman collection for the API's are inside
postmanfolder in root directory