This repository contains a simple Express.js application that serves as a Wikipedia-like API. It allows you to perform CRUD operations (Create, Read, Update, Delete) on articles stored in a MongoDB database.
-
Clone the repository to your local machine:
git clone https://github.com/mercyano/wiki-api.git
-
Install the required dependencies using npm or yarn:
npm install
or
yarn install
-
Make sure you have MongoDB installed and running on your machine.
-
Start the server:
npm start
or
yarn start
-
Access the API using your preferred HTTP client (e.g., cURL, Postman, etc.) at
http://localhost:3000
.
GET /articles
- Retrieves all articles from the database.POST /articles
- Creates a new article.DELETE /articles
- Deletes all articles.
GET /articles/:articleTitle
- Retrieves a specific article by its title.PUT /articles/:articleTitle
- Replaces a specific article with updated content.PATCH /articles/:articleTitle
- Updates a specific article with new content.DELETE /articles/:articleTitle
- Deletes a specific article.
-
Endpoint:
POST /articles
-
Request body:
{ "title": "Introduction to Express", "content": "Express is a fast, unopinionated, and minimalist web framework for Node.js." }
-
Response:
New article added
-
Endpoint:
GET /articles
-
Response:
[ { "_id": "611ff41de0fe670012345678", "title": "Introduction to Express", "content": "Express is a fast, unopinionated, and minimalist web framework for Node.js." }, { "_id": "611ff41de0fe670012345679", "title": "Node.js Basics", "content": "Node.js is an open-source, cross-platform JavaScript runtime environment." } ]
-
Endpoint:
PATCH /articles/Introduction%20to%20Express
-
Request body:
{ "content": "Express is a fast, unopinionated, and minimalist web framework for building web applications." }
-
Response:
Article updated
-
Endpoint:
DELETE /articles/Introduction%20to%20Express
-
Response:
Article deleted
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.