Rice business provides and serves restaurant and rating information for Rice.
- Getting started
- Clone the latest version
- Install Dependencies
- Setup Environment Variables
- Start the application
- Setup Database
- [Technologies] (#Technologies)
- Architecture
- API Endpoints
Start by cloning the latest version of rice-business on your local machine by running:
$ git clone https://github.com/dadamaka/rice-business
$ cd rice-business
From within the root directory run the following command to install all dependencies:
$ npm install
- Copy and save the
example.env
file in the env folder asdevelopment.env
. - Enter your desired
PORT
- Create a free account on https://www.yelp.com/developers/api_console and create your API Keys.
- Enter and save your consumer key and token in your
development.env
file.
-
Start the server by running the following command from the root directory:
$ npm start
-
Your server is now live at
http://localhost:PORT
- Run the follow command from the root directory to run database query tests.
$ npm test
-
Start a mySQL server:
$ mysql.server start Starting mySQL SUCCESS!
-
Sign into your mySQL server with in the terminal (if you do not know your password try not inputting a password):
$ mysql -u root -p
-
Create a database, make sure its name is the same as what you specified earlier as
APP_NAME
.mysql> CREATE DATABASE APP_NAME;
-
Open up the database:
mysql> USE APP_NAME;
-
Create an account and specifiy privileges. Here, we will be creating an
DB_USER
account with the passwordDB_PASSWORD
, with a connection tolocalhost
and all access to the database,APP_NAME
.mysql> CREATE USER 'DB_USER'@'localhost' IDENTIFIED BY 'DB_PASSWORD'; mysql> GRANT ALL PRIVILEGES ON APP_NAME.* TO 'DB_USER'@'localhost';
To see privileges on the account you've just created:
```
mysql> SHOW GRANTS FOR 'DB_USER'@'localhost';
```
###Dropping the database
-
Run the following command from the root directory:
$ npm run drop
- Node
- Express
- Bookshelf/Knex
- MySQL
- Yelp
- Mocha
- Chai
- AWS EC2
- AWS RDS
- Docker
├── /env/ # Environment variables
├── /node_modules/ # 3rd-party libraries and utilities
├── /server/ # Server source code
│ ├── /config/ # Initial server config files
│ ├── /controllers/ # Controllers for database interaction
│ ├── /env/ # Environment variables
│ ├── /models/ # Data models
│ ├── /routes/ # Routes for incoming GET and POST requests
│ ├── /lib/ # Lib for util functions
│ └── /server.js # Server-side startup script
├── /test/ # Server and client side tests
│ ├── /test-data.js # Holds seed & dummy data
│ ├── /test-server.js # Server side tests
└── package.json # List of 3rd party libraries and utilities to be installed
└── .babelrc # Babel presets
└── .eslintrc # ESLint settings
GET
/api/business/info
GET
/api/business/review
POST
/api/business/review
GET
/api/business/detail
POST
/api/business/yelp
###GET
/api/business/info
Objective: Get a specific Business profile
Input:
{
name: *string*
}
Output:
{
"id": 1,
"business_id": "sunrise-coffee-las-vegas-3",
"name": "Sunrise Coffee",
"address": "3130 E Sunset Rd",
"phone": "7024333304",
"city": "Las Vegas",
"state": "NV",
"latitude": "36.0718727111816",
"longitude": "-115.106788635254",
"rating": 4.5,
"review_count": 759,
"is_closed": "0",
"created_at": "2016-07-02T09:10:58.000Z",
"updated_at": "2016-07-02T09:10:58.000Z"
}
###GET
/api/business/review
Objective: Get all reviews of a specific Business
Input:
{
business_id: *string*
}
Output:
[
{
"id": 10,
"business_id": "the-beat-coffeehouse-and-records-las-vegas",
"user_id": "google-oauth2|109741962026347685714",
"review": "",
"rating": 0,
"created_at": "2016-07-04T15:39:07.000Z",
"updated_at": "2016-07-04T15:39:07.000Z"
},
###POST
/api/business/review
Objective: Add a review and rating to database for a specific Business
Input:
{
clientId: *string*
business_id: *string*
rating: *float*
review: *string*
}
Output:
'Add success'
###GET
/api/business/detail
Objective: Get all details of a specific Business
Input:
{
business_id: *string*
}
Output:
[
{
"id": 4,
"business_id": "the-beat-coffeehouse-and-records-las-vegas",
"type": "category",
"value": "coffee",
"created_at": "2016-07-02T09:10:58.000Z",
"updated_at": "2016-07-02T09:10:58.000Z"
},
]
###POST
/api/business/yelp
Objective: Pull more information from Yelp on recommended Business
Input:
{
response: [{
cuisine: "cafes",
id: "unlessstring",
name: "The Beat Coffeehouse & Records",
rating: 0.20202,
userRated: false
},
{
cuisine: "french",
id: "unlessstring",
name: "Sunrise Coffee",
rating: 0.20202,
userRated: false
}]
}
Output:
'Add Business sucessful!'