This project is a RESTful API built with Node.js, Express, and TypeScript, using MongoDB as the database. It allows for user management, including creation, retrieval, updating, deletion, and password verification.
- RESTful API for user management.
- MongoDB as the database, initialized via Docker.
- TypeScript for improved robustness and maintainability.
- Password hashing and verification using Argon2.
- Environment variables for flexible configuration.
- API Documentation with Swagger.
src/- Main source code.config/- Database and plugin configuration.domain/- Entities, DTOs, use cases, and repositories.infrastructure/- Implementations of repositories and datasources.presentation/- Routes, controllers, and Express server.shared/- Reusable helpers.
-
Clone the repository
git clone <repository-url> cd Backend-review
-
Install dependencies
npm install
-
Configure environment variables Create a
.envfile in the project root with the following content (adjust if necessary):PORT=3000 MONGO_URL=mongodb://root:root@localhost:27018/chat_app_db?authSource=admin MONGO_DB_NAME=chat_app_db
- Start the server in development mode
The server will start and automatically connect to the database.
npm run dev
Once the server is running, you can access the interactive API documentation at:
http://localhost:3001/api-docs
From this interface, you can view all available endpoints, test them, and see the expected data models.
All user endpoints are under the /user prefix:
GET /user/→ List all usersGET /user/:email→ Get user by emailPOST /user/→ Create user (body: user data)PUT /user/:email→ Update user (body: data to update)DELETE /user/:email→ Delete userPOST /user/:email→ Verify password (body:{ password })
There is also a test endpoint at /api.
- The project uses Argon2 for password hashing.
- The MongoDB container is initialized with the username and password
root. - You can modify ports and credentials in
docker-compose.ymland.env.