Skip to content

Backend API of the Hidden Gems website, which provides the data requests to the Hidden Gems web application

Notifications You must be signed in to change notification settings

christianaao/hidden-gems-be

 
 

Repository files navigation

Hidden Gems API

Table of Contents

About This Project

Hidden Gems API is a RESTful API built for the purpose of accessing application data programatically for a front end application. This is the backend service which provides information about events and places in Manchester, user information, and comment information, and provides this information to the front end architecture. The backend is built with PostgreSQL, node-postgres and Node.js, using the Express framework.

Project Links

Backend API: https://hidden-gems-project.onrender.com/api
Backend Repo: https://github.com/christianaao/hidden-gems-backend
Original Repo Link: https://github.com/espiers13/hidden-gems

Frontend APP: https://hidden-gems-oo.vercel.app/
Frontend Repo: https://github.com/christianaao/hidden-gems-frontend
Original Repo Link: https://github.com/flynnjim/hidden-gems-frontend

Available Endpoints

  • GET /api
  • GET /api/users
  • GET /api/users/:user_id
  • POST /api/users
  • PATCH /api/users
  • GET /api/comments
  • GET /api/comments/:gem_id
  • POST /api/comments
  • DELETE /api/comments/:comment_id
  • GET /api/gems
  • GET /api/gems/:gem_id
  • POST /api/gems
  • PATCH /api/gems

Please see endpoints.json for all available endpoints and example responses

Running This Project Locally

Database Setup

To set up PostgreSQL on your system, please follow this guide: Install PostgreSQL

To install npm: run npm install npm@latest -g in your terminal.

Installation

  1. In your terminal, locate the directory you would like to save the code to and enter the following. This command will clone this repo:

    git clone https://github.com/christianaao/hidden-gems-backend
  2. In the cloned directory, type npm install in your terminal to install all dependencies.

  3. Enter the following Dev-Dependency Scripts into your packet.json file:

    • "preinstall": "npx only-allow npm
    • "setup-dbs": "psql -f ./db/setup.sql",
    • "seed": "node ./db/seeds/run-seed.js",
    • "test": "jest",
    • "prepare": "husky install",
    • "start": "node listen.js",
    • "seed-prod": "NODE_ENV=production npm run seed"
  4. To connect to the databases locally, create two dotenv files: .env.development:

    PGDATABASE=hidden_gems

    .env.test:

    PGDATABASE=hidden_gems_test
  5. To create the necessary databases, run:

    npm setup-dbs  

    These files should point to your local PostgreSQL databases for development and testing environments.

  6. Populate the development database with initial data by running:

    npm run seed  

    Ensure that the database is correctly seeded before running any tests.

  7. To start the application locally, run:

    npm start  

    This will start the Express server on your local machine. Please see endpoints.json for all available endpoints

  8. To run the test suite and verify the application’s functionality, run:

    npm test  

    Tests are run using Jest and Supertest for API endpoint validation.

☺ I hope you enjoy testing my server ☺

Technology

  • Node.js: JavaScript runtime for building the backend.
  • Express: Web framework for handling routing and HTTP requests.
  • PostgreSQL: Relational database for storing data.
  • node-postgres (pg): PostgreSQL client for Node.js.
  • Jest & Supertest: For testing the API endpoints.

Dependencies and Software Requirements

Dev Dependencies

  • "husky": "^9.1.6",
  • "jest": "^29.7.0",
  • "jest-extended": "^4.0.2",
  • "jest-sorted": "^1.0.15",
  • "supertest": "^7.0.0"

Dependencies

  • "cors": "^2.8.5",
  • "dotenv": "^16.4.5",
  • "express": "^4.21.0",
  • "nodemon": "^3.1.7",
  • "pg": "^8.13.0",
  • "pg-format": "^1.0.4"

About

Backend API of the Hidden Gems website, which provides the data requests to the Hidden Gems web application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%