Hidden Gems API
- About This Project
- Project Links
- Available Endpoints
- Running This Project Locally
- Technology
- Dependencies and Software Requirements
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.
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
- 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
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.
-
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
-
In the cloned directory, type
npm install
in your terminal to install all dependencies. -
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"
-
To connect to the databases locally, create two dotenv files: .env.development:
PGDATABASE=hidden_gems
.env.test:
PGDATABASE=hidden_gems_test
-
To create the necessary databases, run:
npm setup-dbs
These files should point to your local PostgreSQL databases for development and testing environments.
-
Populate the development database with initial data by running:
npm run seed
Ensure that the database is correctly seeded before running any tests.
-
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 -
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 ☺
- 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.
"husky": "^9.1.6",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"jest-sorted": "^1.0.15",
"supertest": "^7.0.0"
"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"