Skip to content

mgregerson/calvin-and-jobbes-backend

Repository files navigation

Calvin and Jobbes Backend

Welcome to the backend of Calvin and Jobbes! This is the server-side component of the job finding app, built with Node.js and Express. This README will guide you through the setup and usage of the backend.

In order for the frontend to run, please see my readme for frontend built in Javascript/React: https://github.com/mgregerson/jobber-the-hutt-frontend

This project was designed by Matt Gregerson. Feel free to reach out with any questions on my design philosophy.

Installation

To get started with the backend, follow these steps:

  • Clone the repository to your local machine.
  • Navigate to the backend directory: cd calvin-and-jobbes-backend.
  • Install the required dependencies by running: npm install.

Configuration

Before running the backend, make sure to set up the necessary configurations:

  • Create a .env file in the root of the backend directory.
  • Provide the required environment variables in the .env file. You can use the .env.example file as a template.

Starting the Server

To start the backend server, run the following command in the calvin-and-jobbes-backend directory:

npm start

This will start the server on the specified port (usually port 3000) and connect it to the configured database.

API Endpoints

The backend exposes various API endpoints to interact with the Calvin and Jobbes app. Here are some of the important endpoints:

Auth Endpoints

/auth/register (POST): Returns JWT token which can be used to authenticate further requests.

  • Auth Required: None /auth/token (POST): Returns JWT token which can be used to authenticate further requests.
  • Auth Required: None

Users Endpoints

/users/ (POST): Creates a new user. NOTE: This is not the registration endpoint --- instead, this is only for admin users to add new users. The new user being added can be an admin.

  • Auth Required: Admin /users/ (GET): Returns a list of all users.
  • Auth Required: Admin /users/:username (GET): Get detailed information about a specific user.
  • Auth Required: Admin or same-user-as-:username /users/:username (PATCH): Updates a user.
  • Auth Required: Admin - Data can include: - FirstName - lastName - password - email /users/:username (DELETE): Delete a user listing.
  • Auth Required: Admin or same-user-as-:username

Jobs Endpoints

/jobs/ (GET): Retrieve a list of jobs.

  • Auth Required: None /jobs/:id (GET): Get detailed information about a specific job.
  • Auth Required: None - Can provide search filter in query: - minSalary - hasEquity (true returns only jobs with equity > 0, other values ignored) - title (will find case-insensitive, partial matches) /jobs/ (POST): Create a new job listing.
  • Auth Required: Admin /jobs/:id (PATCH): Update a job listing.
  • Auth Required: Admin /jobs/:id (DELETE): Delete a job listing.
  • Auth Required: Admin

Companies Endpoints

/companies/ (GET): Retrieve a list of companies and associated jobs.

  • Auth Required: None /companies/:id (GET): Get detailed information about a specific company.
  • Auth Required: None - Can provide search filter in query: - minEmployees - maxEmployees - nameLike (will find case-insensitive, partial matches) /companies/ (POST): Create a new company listing.
  • Auth Required: Admin /companies/:id (PATCH): Update a company listing.
  • Auth Required: Admin /companies/:id (DELETE): Delete a company listing.
  • Auth Required: Admin

Please refer to the backend source code or API documentation for more details on available endpoints and their usage.

Database

The backend uses a database to store job listings and other relevant data. Make sure to configure the appropriate database connection settings in the .env file.

Testing

The backend includes test cases to ensure its functionality. To run the tests, use the following command:

npm test

Make sure to set up a separate test database and configure the connection settings in the .env file for testing purposes.

Additional Information

For additional information or assistance, please refer to the backend source code and documentation. Feel free to reach out if you have any questions or need further support.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published