This repository contains the backend code for a RESTful API basic crud options using Express.js and MongoDB. This API allows you to perform CRUD operations (Create, Read, Update, Delete) providing a simple way to interact with content.
Technology Used- ExpressJs, MongoDB, RestAPI
- Create new todo items with titles, description, and other details.
- Retrieve a list of all todoitems or specific todo details.
- Update todo item information.
- Delete todo item from the database.
- Node.js and npm should be installed on your machine
- MongoDB should be installed and running
- Mongoose should be installed and running
- Express.js should be installed and running
- Nodemon should be installed and runnig
-
Clone the repository:
https://github.com/robertostepic/NodeExpressCrudRestAPI.git
-
Navigate to the project directory:
cd CRUDNOAUTH
-
Install dependencies:
npm install express dotenv mongoose nodemon
-
Create a
.env
file and set the following environment variables:PORT=5000 MONGODB_URI=your_mongodb_connection_uri
-
Start the server:
npm run server nodemon index.js
-
The API will be accessible at
http://localhost:5000
.
- `GET /api/all-todos`: Get a list of all posts.
- `GET /api/todo/:id`: Get details of a specific post by ID.
- `POST /api/new-todo`: Create a new post.
- `PUT /api/update-todo/:id`: Update details of a specific post by ID.
- `DELETE /api/delete-todo/:id`: Delete a post by ID.
.
โโโ controllers # Main controller folder
โ โ
โ โโโ todoController.js # function controller - brain of routes
โ
โโโ db # Main database folder
โ โ
โ โโโ connect.js # Database connection
โ
โโโ models # User - Database Schema
โ โ
โ โโโ todoRoutes # MongoDb database schema for todo
โ
โโโ routes # Context - Global State Manager
โ โ
โ โโโ todoRoutes # Todo routes - create, read, update, delete
โ
โโโ .env. # Hidden config files for mongodb, port
โ
โ
โโโ index.js # Startpoint of the Entire Application
Contributions are welcome! If you find any issues or want to enhance the project, feel free to create a pull request.
- Fork the repository.
- Create a new branch for your feature:
git checkout -b feature-name
. - Commit your changes:
git commit -am 'Add feature'
. - Push to the branch:
git push origin feature-name
. - Submit a pull request.
I'm an amateur developer from Croatia.
For support, email [email protected]