Programming Quotes API

Programming Quotes API for open source projects.

Homepage: programming-quotes-api.herokuapp.com

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

API Documentation

Suported languages: en, sr.

Public routes

GET /quotes (get all quotes)

GET /quotes/lang/en (get quotes by language)

GET /quotes/page/2 (get quotes by page)

GET /quotes/random (get random quote)

GET /quotes/random/lang/sr (get random quote by language)

GET /quotes/id/5a6ce86f2af929789500e824 (get quote by id)

Protected routes

POST /quotes/vote (post vote)

POST /quotes (for registered user)

PUT /quotes (update quote for admin)

DELETE: /quotes (for admin)

Authentication

GET /auth/{provider} (user login)

After successful login, user will be redirected to client app. The client app should handle token on this route: #/auth/{provider}/${token}.

GET /auth/{provider}:token (get user data)

Development

Prerequisites

Env variables

Create .env file proper values:

# Database credentials (obtain from MongoDB)
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_DOMAIN=

# obtain from Github (have two separate OAuth apps, for local and for production)
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# OAuth 2.0 client IDs (obtain from Google API Console)
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# whatever random string you like
JWTSECRET=

# use development for local testing
NODE_ENV=development 

Start

npm i
npm run dev

See server logs:

heroku logs --app programming-quotes-api

Deploy

Deploy will be done automatically after merge into master branch.