A back-end server that returns information regarding restaurant entries in the database and corresponding review information
Contents
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.
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.
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
.
The API here returns the following status codes:
Status Code | Description |
---|---|
200 | Ok |
404 | Bad Request |
400 | Not Found |
500 | Internal Server Error |
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
For tests involving time to run properly, configure your Postgres database to run in the UTC timezone.
- Locate the
postgresql.conf
file for your Postgres installation.- E.g. for an OS X, Homebrew install:
/usr/local/var/postgres/postgresql.conf
- E.g. on Windows, maybe:
C:\Program Files\PostgreSQL\11.2\data\postgresql.conf
- E.g on Ubuntu 18.04 probably: '/etc/postgresql/10/main/postgresql.conf'
- E.g. for an OS X, Homebrew install:
- Find the
timezone
line and set it toUTC
:
# - 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.
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
View the client repo here. The live api is hosted on Heroku. The live client is hosted with Vercel.
🔭 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.