Skip to content

erinkelsey/wikiapi-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Wiki-API

RESTful API for Wikipedia-like articles using Node.js and Express.

Hosted Example Endpoint: https://wikiapi-nodejs.herokuapp.com/

Install

$ npm install

Setup

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

Run

$ npm start

API Details

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.

GET Method -> JSON Response Example

    [
        {
            "_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."
        }
    ]

POST Method -> Request Body

Request body must be x-www-form-urlencoded, with key-value pairs for title and content fields.

About

๐ŸŒŽ RESTful API for Wikipedia-like articles using Node.js, Express and MongoDB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published