middleware
0. Overview
Middleware layer implementing API connection to databases and authentication
0.1 Technologies Used
- Node.js
- Express.js
- MySQL (with
Sequelize
as ORM)
1. Getting Started
1.1 Prerequisites
Ensure you have the following installed on your local machine.
1.2 Installing/Running locally
-
Clone repository
- git clone https://github.com/BanTheBad/middleware.git - cd middleware - npm install
-
Google Oauth config
- Visit the Google API Console (create an account if necessary)
- From the project drop-down, select an existing project, or create a new one by selecting Create a new project
- You may need to fill out the
OAuth consent screen
- Unless you're a G Suite user, you have to select
External
for theUser Type
- You don't need to fill out the
App Domains
section - Select the
userinfo.email
anduserinfo.profile
scopes to match the scopes used by the server - When done, go back to the Credentials page and repeat the process, this time you'll be able to create the Oauth client
- Unless you're a G Suite user, you have to select
- In the sidebar under "APIs & Services", select Credentials
- In the Credentials tab, select the Create credentials drop-down list, and choose OAuth client ID.
- Under Application type, select Web application.
- In Authorized redirect URI use
http://localhost:<PORT>/auth/google/callback
- Press the Create button and copy the generated client ID and client secret
- In your
.env
file, paste the values in theGOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
variables
-
Create/configure a
.env
file with your credentials. A sample.env.example
file has been provided to get you started. Make a duplicate of.env.example
and rename to.env
, then configure your credentials. -
Two
npm
scripts are available to spin up the server:npm run dev
spins up the server and watch for file changesnpm run dev:debug
spins up the server and attaches a debugger to it