Skip to content

This backend server is to be used with the client aniledev/bon-appetit and provides support for the restaurant tracker and review application. This repo directory is organized by source files, files related to the /api/restaurant endpoint, and configuration files.

Notifications You must be signed in to change notification settings

aniledev/bon-appetit-server

Repository files navigation

Bon Appetit Server

A back-end server that returns information regarding restaurant entries in the database and corresponding review information

GitHub language count GitHub top language GitHub code size in bytes GitHub repo size in bytes GitHub issues GitHub closed issues

Contents

Contents
  1. Application Summary
  2. API Documentation
  3. Local Dev Setup
  4. Configuring PostgreSQL
  5. Scripts
  6. Built With
  7. Technical Aspects
  8. Deployment
  9. Acknowledgements
  10. Connect With Me

Application Summary

This backend server is to be used with the client aniledev/bon-appetit and provides support restaurant tracker and review application. This repo directory is organized by source files, files related to the /api/restaurant endpoint, and configuration files.

Each endpoint uses the express.Router class to create modularized route handlers. Additionally, the routers make use of node-postgres, a module for easy interfacing with PostgreSQL databases.

API Documentation

Full API documentation can be found on Postman. See the complete documentation for endpoint descriptions, example request snippets, and example response snippets in various formats.

Endpoints

Restaurant

GET /api/restaurant

POST /api/restaurant
This endpoint requires a request body in the form of const { name, location, price_range } = req.body.

GET /api/restaurant/:id

PUT /api/restaurant/:id
This endpoint requires a request body in the form of const { name, location, price_range } = req.body.

DELETE /api/restaurant/:id

POST /api/restaurant/:id/review
This endpoint requires a request body in the form of const { name, review, rating } = req.body.

Status Codes

The API here returns the following status codes:

Status Code Description
200 Ok
404 Bad Request
400 Not Found
500 Internal Server Error

Local Dev Setup

If using user dunder-mifflin:

mv example.env .env
createdb -U dunder-mifflin bon-appetit
createdb -U dunder-mifflin bon-appetit-test

If your dunder-mifflin user has a password be sure to set it in .env for all appropriate fields. Or if using a different user, update appropriately.

npm install
npm run migrate
env MIGRATION_DB_NAME=bon-appetit-test npm run migrate

Configuring PostgreSQL

For tests involving time to run properly, configure your Postgres database to run in the UTC timezone.

  1. Locate the postgresql.conf file for your Postgres installation.
    1. E.g. for an OS X, Homebrew install: /usr/local/var/postgres/postgresql.conf
    2. E.g. on Windows, maybe: C:\Program Files\PostgreSQL\11.2\data\postgresql.conf
    3. E.g on Ubuntu 18.04 probably: '/etc/postgresql/10/main/postgresql.conf'
  2. Find the timezone line and set it to UTC:
# - Locale and Formatting -

datestyle = 'iso, mdy'
#intervalstyle = 'postgres'
timezone = 'UTC'
#timezone_abbreviations = 'Default'     # Select the set of available time zone

And npm test should work at this point.

Scripts

Start the application npm run start

Start nodemon for the application npm run dev

Run the test mode npm test

Run the migrations up npm run migrate

Run the migrations down npm run migrate -- 0

Built With

express git heroku javascript mocha nodejs postgresql postman

Technical Aspects

Deployment

View the client repo here. The live api is hosted on Heroku. The live client is hosted with Vercel.

Acknowledgements

Connect With Me

🔭 I’m currently working on mastering data structures and complex algorithms.

🌱 I’m currently learning the fundamentals of Angular.

🤝 I’m looking for help with networking as a new dev in the community.

👨‍💻 All of my projects are available here

💬 Ask me about the ease of the PERN stack.

📫 The best way to reach me is by email: elinamcgill@gmail.com

📄 Check out my resume of experiences

⚡ Fun fact Hiatus Kaiyote is my favorite band at the moment.

elina-mcgill

About

This backend server is to be used with the client aniledev/bon-appetit and provides support for the restaurant tracker and review application. This repo directory is organized by source files, files related to the /api/restaurant endpoint, and configuration files.

Topics

Resources

Stars

Watchers

Forks