A basic express app for authorizing users with JWT strategy.
After cloning repo and changing to directory
-
Install Dependencies
npm i
-
Set env variables
- Create a
.env
file at the root of repo. - (REQUIRED): set value for SECRET
SECRET=...
- (OPTIONAL): set value for PORT (default: 3030)
PORT=...
- Create a
-
Run development server
npm run dev
Or build and start
npm run build npm run start
-
Login Endpoint
On Postman, make a
POST
request to http://localhost:3030/auth/login/- The request should have a body of type
x-www-form-urlencoded
- request body should have an
email
andpassword
- The email and password are hard coded in this example. There are 2 existing users.
{ email: '[email protected]', password: 'johnny-password' }, { email: '[email protected]', password: 'jane-password' }
- The email and password are hard coded in this example. There are 2 existing users.
- The request should return an object with a JSON web token.
- The request should have a body of type
-
Dashboard Endpoint
On Postman, make a
GET
request to http://localhost:3030/dashboard/user/- Create a header with
- key:
Authorization
- value:
JWT <jwt-from-login-post-request>
- key:
- This should return an object representing the user information.
- Create a header with