user authorization backend
This backend will create new users and store them in a PSQL db and also handle authorize login requests from a frontend, returning a signed JWT.
Dependencies
- pg-promise
- express
- bcrypt
- jwt
- dotenv
- cors
Paths –
-
/user/register – registers a new user
- takes a json body in the format { “name”: “John, “email”: “[email protected]“, “password”: “password123” }
-
/user/login – validates credentials sent from front end against email/ pass stored in DB
- takes a JSON body in the format : { “email”: “[email protected]“, “password”: “password123” }
- returns a signed jwt
SQL Table Structure
Columns – – id SERIAL PRIMARY KEY – name text NOT NULL – email text NOT NULL UNIQUE – password varchar NOT NULL
Notes
Will require a .env with the following variables
PG_HOST= db address PG_PORT= db port PG_DATABASE= db name PG_USER= db username PG_PASSWORD= db password
SECRET_KEY= secret key for bcrypt