Skip to content
This repository has been archived by the owner on Mar 30, 2020. It is now read-only.

keetela/niveloio

Repository files navigation

Niveloio Build Status Coverage Status Maintainability dependencies Status

Niveloio API Standards

Setup Instructions

Install dependencies:

$ npm install

Startup the Server:

$ npm start

Run Tests:

$ npm run test

RESTful URLs

Method Endpoint Description
GET /api/v1/posts List all posts
GET /api/v1/posts/:postId Query one post
POST /api/v1/posts Create a new post
PUT /api/v1/posts/:postId/publish Publish a new post
PUT /api/v1/posts/:postId/unpublish Unpublish a post
DELETE /api/v1/posts/:postId Delete a post

Request & Response Examples

API Resources

GET /posts

Example: https://niveloio.herokuapp.com/api/v1/posts

Response body:

    "message": "all posts",
    "posts": [
      {
        "id": 5,
        "title": "what is es6?",
        "content": "Lorem Ipsum is simply dummy",
        "publish": true,
        "unpublish": false
      },
      {
        "id": 7,
        "title": "what is nodejs?",
        "content": "Lorem Ipsum is simply dummy",
        "publish": true,
        "unpublish": false
      },
      {
        "id": 6,
        "title": "what is javascript?",
        "content": "Lorem Ipsum is simply dummy",
        "publish": true,
        "unpublish": false
      },
      {
        "id": 8,
        "title": "what is TDD?",
        "content": "Lorem Ipsum is simply dummy",
        "publish": true,
        "unpublish": false
      }
    ]

}

GET /postId

Response body: Example: https://niveloio.herokuapp.com/api/v1/posts/5

    {

      "post": {
      "id": 5,
      "title": "what is es6?",
      "content": "Lorem Ipsum is simply dummy",
      "publish": true,
      "unpublish": false
      }
    }

Register a new user

Remember to add SECRET="YOUR_SECRET_KEY" in your .env file

Note: Remember to update npm

npm update

RESTful URLs

Method Endpoint Description
GET /api/v1/users List all users
POST /api/v1/register Register a new user
POST /api/v1/login Log in a user

Test Autheticated Routes

Method Endpoint Description
GET /api/v1/protected Testing protected route

POST: Registering new user

{
  "names": "John Doe",
  "username": "johndoe",
  "email": "john@doe.com",
  "password": "secret"
}

POST: Loggin in

{
  "email": "john@doe.com",
  "password": "secret"
}