Use Node.js
, Express
and Knex
to build an API that provides Register and Login functionality using SQLite
to store User information. Make sure the password is not stored as plain text.
Follow these steps to set up and work on your project:
- Create a forked copy of this project.
- Clone your OWN version of the repository (Not Lambda's by mistake!).
- Create a new branch: git checkout -b
<firstName-lastName>
. - Implement the project on your newly created
<firstName-lastName>
branch, committing changes regularly. - Push commits: git push -u origin
<firstName-lastName>
.
Complete the following endpoints:
Method | Endpoint | Description |
---|---|---|
POST | /api/register | Creates a user using the information sent inside the body of the request. Hash the password before saving the user to the database. |
POST | /api/login | Use the credentials sent inside the body to authenticate the user. On successful login, create a new session for the user and send back a 'Logged in' message and a cookie that contains the user id. If login fails, respond with the correct status code and the message: 'You shall not pass!' |
GET | /api/users | If the user is logged in, respond with an array of all the users contained in the database. If the user is not logged in repond with the correct status code and the message: 'You shall not pass!'. |
Add support for sessions and cookies, use them to keep a record of logged in users across requests.
- Write a piece of global middleware that ensures a user is logged in when accessing any route prefixed by
/api/users
. - Build a React application that implements components to register, login and view a list of users. Gotta keep sharpening your React skills.
Follow these steps for completing your project.
- Submit a pull request to merge Branch into master (student's Repo). Please don't merge your own pull request