Home

Awesome

Programming Quotes API

Programming Quotes API for open source projects.

Visit: programming-quotes-api.azurewebsites.net

Github repo: github.com/mudroljub/programming-quotes-api

Feel free to get involved, suggest or implement new features.

API Documentation

Public Routes

GET /api/quotes/random

GET /api/quotes?author=Edsger_W._Dijkstra

GET /api/quotes?page=1&quotesPerPage=20

GET /api/quotes

GET /api/quotes/:id


Protected Routes

Access to these routes requires a valid token.

POST /api/quotes

PUT /api/quotes/:id

POST /api/quotes/vote

DELETE /api/quotes/:id


Authentication

GET /api/auth/token

Token Usage: For all subsequent requests, include the token in the Authorization header as follows:

Authorization: Bearer <token>

Development

Prerequisites

Setup database

Import json file into local MongoDB database (replace with real values):

mongoimport --db quotes --collection quotes --file quotes.json --jsonArray --username quotes --password quotes

Env variables

Create .env file proper values:

# database credentials (obtain from MongoDB)
CONNECTION_STRING=

# whatever random string you like
JWT_SECRET=

# use development for local testing
NODE_ENV=development 

Start

npm i
npm run dev