Skip to content

Benja022/cs11_backend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

baner

CODE SPACE JOBS PORTAL - BACKEND

DEPENDENCIES

Packages Description
express Fast, unopinionated, minimalist web framework for Node.js.
bcrypt Library for hashing passwords
cors A node.js package for providing a Connect/Express middleware that can be used to enable Cross-origin resource sharing with various options.
dotenv Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code
jsonwebtoken Library for creating and managing tokens
express-async-handler Middleware for robust handling of asynchronous functions
express-rate-limit Used for create middleware with"login limiter" functionality in order to stop brute force attacks and optimize application performance by limiting the number of login attempts.
mongoose A JavaScript object-oriented programming library that creates a connection between MongoDB and the Node.js JavaScript runtime environment
nodemailer Email sending from NodeJS application
jwt-decode A library for decoding JWT tokens
swagger-ui-express A library for documenting API using Swagger

PROJECT LAYOUT

/
└───src
    ├───controllers
    ├───middlewares
    ├───models
    ├───routes
    ├───uploads
    └───utils

ROUTES

Auth routes:

  • auth/signup
  • auth/login
  • auth/refresh
  • auth/changePassword/:id

Forgotten password routes

  • forgotten-password/send-mail
  • forgotten-password/reset-password/:token

Candidate routes:

  • all-candidates
  • candidate/all-candidates
  • candidate/:loginId
  • candidate/:loginId
  • candidate/:loginId/watchlist
  • candidate/edit-job/:loginId/:jobId
  • candidate/employer-jobs/:loginId
  • candidate/delete-job/:loginId/:jobId

Jobs routes

  • job/all-jobs
  • job/jobs-applied/:loginId
  • job/jobs-applied/:loginId/:jobId
  • job/job-list
  • job/post-job
  • job/job-single/:jobId

MODELS

  • Auth model - contains the register schema with necessary validation prior to saving into the database.
  • Job model - contains the job schema with necessary validation prior to saving into the database.
  • Candidate model - contains the candidate schema with necessary validation prior to saving into the database.
  • Employer model - contains the employer schema with necessary validation prior to saving into the database.

CONTROLLERS

Auth controllers:

  • createNewUser - creates a new user in the database with an email and a password protected with bcrypt from the information received in the request body. It controls if the request body contains all necessary information and avoids duplications in the database. In successful request returns access and a refresh token in order to log the user in automatically in registration. The payload of the access token contains the user's id, role and email.

  • login - searches the database for a user with the email address specified in the request body.The received password is compared to the one in the database.If passwords match, return an access and refresh token in order to give the user access to operations that require authentication.

  • refresh - checking the refresh token in the request headers. Returns a new access token in order to improve user experience and avoid making the user restart their session when the access token has expired.

Forgotten password controllers:

  • sendMail - sends email with link which redirects to reset passord view in frontene application adding a token for email verification

  • resetPassword -verifies recieved token and decodes it, and only if email encrypted in the payload of token exists in database allows set new password.

Candidate controllers:

  • getAllCandidates - retrieves a list of all candidates from the database. This can be used to display a summary of available candidates or for administrative purposes.

  • addToWatchlist - adds a candidate to a user's watchlist by associating the candidate's ID with the user's ID. This allows users to easily track and review their preferred candidates.

  • modifyCandidate - updates a candidate's information based on the data received in the request body. Ensures that only authorized users can make changes to a candidate's record.

  • getById - retrieves a candidate's information from the database based on their unique ID. This can be used to display detailed information about a specific candidate.

  • deleteById - removes a candidate's record from the database based on their unique ID. Ensures that only authorized users can delete a candidate's record.

Job controllers:

  • getAllJobs - retrieves all jobs available in the database and returns them in a response. Useful for displaying a list of available jobs to users.

  • getEmployerJobsByLoginId - finds and returns all jobs created by a specific employer, identified by their login ID. Useful for employers to manage and view their posted jobs.

  • removeJobByLoginIdAndJobId - deletes a specific job from the database using the login ID of the employer and the job ID. Helps employers remove unwanted or outdated job postings.

  • updateJobByLoginIdAndJobId - allows an employer to update a specific job's information in the database using their login ID and the job ID. Useful for making changes or corrections to job postings.

  • getJobsAppliedByLoginId - retrieves a list of jobs that a specific user has applied for, identified by their login ID. Useful for users to track their job application progress.

  • removeJobApplication - deletes a user's job application from the database. Useful for users who want to withdraw their application or for employers who want to remove an applicant.

  • getJobList - retrieves a list of jobs based on specific criteria or filters, such as job title, location, or employer. Useful for users searching for specific job opportunities.

  • createJob - allows an employer to create and add a new job posting to the database with the necessary information. Helps employers advertise job openings.

  • getJobByJobId - finds and returns a specific job's information using its job ID. Useful for users who want to view more details about a job.

  • getCandidateAppliedJobs - retrieves a list of jobs that a specific candidate has applied for. Useful for employers to view the applications they have received.

  • deleteCandidateAppliedJobs - removes a candidate's job application from the database. Useful for employers who want to reject an applicant or for candidates who want to withdraw their application.

  • applyToJob - allows a user to submit a job application for a specific job using their login ID and the job ID. Helps users apply for job opportunities they are interested in.

CONTRIBUTORS

Name Github Linkedin Email
Alina Dorosh Contact me
Nelson González Contact me

| Rafael Fernandez | | | Contact me | | | | | | | | | | | | |

About

Final Bootcamp project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%