Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/FirstAssignment #105

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

adityaKrModak
Copy link

@adityaKrModak adityaKrModak commented Apr 7, 2023

closes #43 #205 #206 #207

Please refer README.md for more details

Description

The structure includes separate folders for controllers, middlewares, models, and routes.

This PR adds the following routes to our application:

  • /signup (POST): Allows users to sign up for the platform
  • /login (POST): Allows registered users to login to the platform
  • /questions (GET): Returns a list of all available questions
  • /submissions/:questionId (GET): Returns a list of submissions for a particular question
  • /submissions/:questionId (POST): Allows logged in users to submit a solution for a particular question

Admin Routes

Implemented separate routes, controllers, middleware, and models for admin functionality, for separation of concerns

  • /admin/signup (POST): Allows admin to sign up for the platform
  • /admin/login (POST): Allows registered admin to login to the platform
  • /admin/question (POST): Allows registered admin to add question.

Folder Structure

- controllers
  - adminController.js
  - authController.js
  - questionsController.js
  - submissionsController.js
- middleware
  - adminMiddleware.js
  - authMiddleware.js
  - validators.js
- models (object store)
  - Admin.js
  - question.js
  - submission.js
  - user.js 
- routes
  - authRoutes.js
  - questionsRoutes.js
  - submissionsRoutes.js

Changes Made

Authentication

  • Implemented JWT for authentication and stored it in the browser using cookie.
  • Created authMiddleware to verify JWT and authenticate user for protected routes.

User Management

  • Implemented input validation and sanitization on routes using the express-validator middleware.
  • Hashed passwords using bcrypt before storing them in the object store.
  • Generated unique user IDs using v1 from the uuid package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add README.md
2 participants