This project is a simple REST API built using Express. It provides endpoints for managing users including creating, reading, updating, and deleting user data. Additionally, it incorporates authentication features using sessions and Passport.js.
-
Install Node.js: If you haven't already, install Node.js from nodejs.org.
-
Fetch the GitHub Repository: Clone or download the GitHub repository to your local machine.
-
Install Dependencies: Navigate to the project directory in your terminal and run the following command to install dependencies:
npm install
-
Start the Server: Once the dependencies are installed, start the server using:
npm start
- GET /users - Renders an HTML document.
- GET /api/users - Returns a list of all users in JSON format.
- GET /api/users/:id - Returns the user with the specified ID.
- POST /api/users - Creates a new user.
- PATCH /api/users/:id - Edits the user with the specified ID.
- DELETE /api/users/:id - Deletes the user with the specified ID.
- /auth/login - Endpoint for user login.
- /auth/register - Endpoint for user registration.
- /auth/discord/ - Endpoint for Discord redirection to sign in.
- /auth/discord/redirect - Endpoint for Discord redirection to sign in.
User passwords are encrypted using the bcrypt module to enhance security.
Session management is employed to store user authentication data securely on the server-side rather than in cookies.
- Mockaroo Integration: Fake data is generated using Mockaroo for testing purposes.
Unit testing has been implemented for the Discord strategy and the endpoint - auth/register
using Jest. Contributions to unit testing other functions are welcome.
Feel free to explore and contribute to this project. For any issues or suggestions, please open an issue on GitHub.