/node-book-api

An advanced, production-grade Node JSON API with CRUD functionalities🚩

Primary LanguageHandlebarsMIT LicenseMIT

Node JSON API logo

An advanced, production-grade Node JSON API with CRUD functionalities🚩


Contributions welcome License: MIT


API Documentation 📝

Indices


Authentication

Contains ALL routes for user authentication (register, login, reset password, etc).

1. Forgot Password

Generate password token & send a reset URL email to the email address if valid.

Endpoint:

Method: POST
Type: RAW (JSON)
URL: https://json-node-api.herokuapp.com/api/v1/auth/forgotPassword/

Headers:

Key Value Description
Content-Type application/json JSON Content Type

Body:

{
    "email": "john@example.com"
}

2. Get Logged In User Details

Get the details of the current logged in user. This can be helpful when user details are required in a Front-End with any CRUD action.

Endpoint:

Method: GET
URL: https://json-node-api.herokuapp.com/api/v1/auth/me/

3. Login User

Validates the credentials passed in. Returns a JWT token & cookie.

Endpoint:

Method: POST
Type: RAW (JSON)
URL: https://json-node-api.herokuapp.com/api/v1/auth/login/

Headers:

Key Value Description
Content-Type application/json JSON Content Type

Body:

{
    "email": "john@example.com",
    "password": "Qwert0"
}

4. Logout User

Clears out token cookie.

Endpoint:

Method: GET
URL: https://json-node-api.herokuapp.com/api/v1/auth/logout/

5. Register User

Creates a user if account with email address sent is non-existing. Returns a JWT token & cookie.

Endpoint:

Method: POST
Type: RAW (JSON)
URL: https://json-node-api.herokuapp.com/api/v1/auth/register/

Headers:

Key Value Description
Content-Type application/json JSON Content Type

Body:

{
    "firstName": "John",
    "lastName": "Doe",
    "email": "john@example.com",
    "password": "Qwert0"
}

6. Reset Password

Checks if the reset token sent is valid & updates the validated password respectively.

Endpoint:

Method: PUT
Type: RAW (JSON)
URL: https://json-node-api.herokuapp.com/api/v1/auth/resetPassword/8a9f8b89881ad27f0cb0150f2ede3ef15115fc25

Headers:

Key Value Description
Content-Type application/json JSON Content Type

Body:

{
    "password": "Qwert0"
}

Books

Books CRUD functionality. This includes routes for

  • Getting all books
  • Getting a single book
  • Adding a book
  • Updating a book
  • Deleting a book

1. Add A Book

Endpoint:

Method: POST
Type: RAW (JSON)
URL: https://json-node-api.herokuapp.com/api/v1/books/

Headers:

Key Value Description
Content-Type application/json JSON Content Type

Body:

{
    "title": "The Debugger",
    "price": 10.99,
    "author": "Omezibe Obioha",
    "datePublished": "06-09-2021",
    "pages": 153,
    "publisher": "Diamonds Books 💎",
    "description": "This book talks about the \"adventures\" of the author in his programming journey so far: the good, bad, and ugly.",
    "isbn": "9876543210"
}

2. Delete A Book

Endpoint:

Method: DELETE
URL: https://json-node-api.herokuapp.com/api/v1/books/e297d1d4-8050-4368-85c2-75aa7e8c5c04/

3. Get A Book

Endpoint:

Method: GET
URL: https://json-node-api.herokuapp.com/api/v1/books/e297d1d4-8050-4368-85c2-75aa7e8c5c05/

4. Get All Books

Endpoint:

Method: GET
URL: https://json-node-api.herokuapp.com/api/v1/books/

Query Params:

Key Value Description
select title,author,price,isbn Allows you to select the fields you want the API to send. By default, ALL fields are sent. Also, the "id" field can't be deselected.
limit 5 Sets the number of records the APi sends per request. The default value is 5.
page 1 Allows to navigate to a "page" to get the next or previous set of records as required. The default value is 1.

5. Update A Book

Endpoint:

Method: PUT
Type: RAW (JSON)
URL: https://json-node-api.herokuapp.com/api/v1/books/e297d1d4-8050-4368-85c2-75aa7e8c5c05/

Headers:

Key Value Description
Content-Type application/json JSON Content Type

Body:

{
    "title": "Purple Hibiscus (Revised Edition)"
}

Back To Top ↺

Made with ♥ by Omzi