This is a CRUD (Create, Read, Update, Delete) application built using Node.js, TypeScript, and MongoDB. It provides a RESTful API for managing resources and serves as a structured approach for building TypeScript + Node.js applications.
- CRUD Operations: Supports all CRUD operations for managing resources.
- RESTful API: Provides a RESTful API for interacting with the application.
- TypeScript: Written in TypeScript for improved code maintainability and scalability.
- Zod: Utilizes Zod for schema validation, ensuring data integrity and security.
- MongoDB: Utilizes MongoDB as the database for storing and retrieving data.
- Dockerized: Containerized using Docker for easy deployment and scalability.
Before running the application, ensure you have the following installed:
- Node.js and npm: Install Node.js and npm
- Docker: Install Docker
- MongoDB: Install MongoDB
-
Clone the repository:
git clone https://github.com/yourusername/nodejs-typescript-zod-mongodb-crud.git
-
Navigate to the project directory:
cd nodejs-typescript-zod-mongodb-crud
-
Install dependencies:
npm install
-
Start MongoDB:
If MongoDB is not already running, start it using the following command:
docker run -d -p 27017:27017 --name mongodb mongo
-
Build and run the application:
npm run build npm start
-
Access the API:
The API is now running and can be accessed at http://localhost:PORT. You can use tools like Postman or cURL to interact with the endpoints.
all Api - endpoints are mentioned in the postman-collection.json
-
Running in Development Mode:
npm run dev
-
Build Docker Image:
docker build -t nodejs-app .
-
Run Docker Container:
docker run -d -p <machine_port>:<docker_port> --name nodejs-app nodejs-app
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.