RESTful API for Wikipedia-like articles using Node.js and Express.
Hosted Example Endpoint: https://wikiapi-nodejs.herokuapp.com/
$ npm install
Create a .env file in the main folder, containing the connection string for your MongoDB. For example, use the following for local connections:
MONGODB_SRV_ADDRESS=mongodb://localhost:27017/blogDB
$ npm start
| Method | Route | Description |
|---|---|---|
| GET | /articles | Get all of the articles in the collection. |
| POST | /articles | Add a new article to the collection. |
| DELETE | /articles | Deletes all articles in the collection. |
| GET | /articles/:articleTitle | Get the article with the specific title from the collection. |
| PUT | /articles/:articleTitle | Replaces the entire document with the specific title. |
| PATCH | /articles/:articleTitle | Updates the document with the specific title, but only those fields that are sent in request. |
| DELETE | /articles/:articleTitle | Deletes article with the specific title. |
NOTE: All articleTitle params are case-sensitive.
[
{
"_id":"5f795439cfcf52abb5694943",
"title":"REST",
"content":"REST is short for REpresentational State Transfer. It's an architectural style for designing APIs."
},
{
"_id":"5c139771d79ac8eac11e754a",
"title":"API",
"content":"API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
}
]
Request body must be x-www-form-urlencoded, with key-value pairs for title and content fields.