- Functionality: Provides a simple REST API for managing articles in a wiki-like database.
- Tech Stack:
Nodejs
Expressjs
Ejs
Postman
robo3t
mongoose
mongodb
- Author: @shreyamalogi
- Year of Project: 2022
- Introduction
- Challenges and Solutions
- How to Run?
- API Endpoints
- Easy Explanation
- Project Structure
- How to Use
- How You Can Make?
- Contribution - Show Your Support
- License
A simple REST API built from scratch by Shreya Malogi with Express.js, MongoDB, and Mongoose for handling articles in a wiki-like database.
- Challenge: Implementing dynamic content rendering in HTML templates.
- Solution: Integrated EJS (Embedded JavaScript) as the templating engine, allowing server-side rendering and dynamic content display. ππ
- Challenge: Creating a robust routing system for handling CRUD operations.
- Solution: Implemented RESTful routes using Express.js, providing a clean and organized structure for handling different types of requests. ππ
- Challenge: Testing API endpoints and interacting with the database during development.
- Solution: Leveraged Postman for API testing, ensuring the correct functionality of routes. Utilized Robo3T for database visualization and management, streamlining the development and debugging process. π§ͺπ οΈ
-
Clone the repository:
git clone https://github.com/shreyamalogi/WikiDB-REST-API.git
-
Navigate to the project directory:
cd <project-directory>
-
Install dependencies:
npm install
-
Set up MongoDB:
- Ensure that MongoDB is running on your local machine.
- Update the connection string in
mongoose.connect
to match your MongoDB configuration.
-
Run the application:
node app.js
-
Open your web browser and visit http://localhost:3000 to interact with the API.
- Retrieves all articles in the database.
- Creates a new article.
- Requires
title
andcontent
in the request body.
- Deletes all articles in the database.
- Retrieves a specific article by title.
- Updates the content of a specific article.
- Requires
newContent
in the request body.
- Updates the content of a specific article (overwrite).
- Requires
newContent
in the request body.
- Deletes a specific article by title.
Think of this application as a magical toy box, and it has special routes or paths to perform these actions:
- Create (POST): You tell the box, "Hey, I have a new toy!" and the box adds it.
- Read (GET): You ask the box, "What toys do I have?" and the box shows you all of them.
- Update (PATCH and PUT): You say, "I want to change something about this toy," and the box does it.
- Delete (DELETE): You say, "I don't want this toy anymore," and the box removes it.
So, the application helps you manage your magical toy box by creating, reading, updating, and deleting toys using these special paths or routes. It's like having a wizard friend who listens to what you want to do with your toys and makes it happen! π§ββοΈπ¦πͺ
public
: Contains static files.views
: EJS templates for rendering pages.models
: Defines MongoDB schema and model for articles.app.js
: Main application file.
- Open http://localhost:3000 in your web browser.
- Interact with the API using tools like Postman.
- Explore the different routes mentioned above.
Feel free to customize and enhance the API based on your requirements!
Feeling inspired by the world of web development? Contribute to this project and be part of the magic.
Don't forget to star the repository! βπ
This project is released under the MIT License, allowing you to share the magic responsibly!
MIT License
Copyright (c) 2022 Shreya Malogi
Stay Enchanted! ππ