-
Notifications
You must be signed in to change notification settings - Fork 38
i have many problem with this. see README #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ethanng329
wants to merge
36
commits into
constructorlabs:master
Choose a base branch
from
Ethanng329:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
5d5bfe5
first attempt
Ethanng329 ba73801
refactored and changed a few spelling
Ethanng329 a4dbfaf
head reset
Ethanng329 e604e4a
reseting head
Ethanng329 a10822d
node js changes
Ethanng329 6c1a785
route changed
Ethanng329 ce22da5
handlebar path updated
Ethanng329 d008376
script amended
Ethanng329 ef2c71a
added publicpath
Ethanng329 87ad221
debugging
Ethanng329 35e90e3
fixing path
Ethanng329 40d5b0a
fixing path
Ethanng329 28a4e16
webpack changes
Ethanng329 6447db1
webpack updates
Ethanng329 be2e45d
path fixing
Ethanng329 3b944e8
path fixing
Ethanng329 73889af
defining handlebar type
Ethanng329 531fcee
npm build run
Ethanng329 8b00349
.
Ethanng329 b97c17e
added route
Ethanng329 dbd15fe
added path
Ethanng329 d132954
node updates
Ethanng329 15ba93a
handle bar test
Ethanng329 00c5a7e
node updates
Ethanng329 cdc5a15
node update
Ethanng329 ad01906
merged
Ethanng329 4b7ef0b
remove bundle from gitignore
Ethanng329 c6e465e
README updated
Ethanng329 768883b
screenshot centered
Ethanng329 c043a2a
README updates
Ethanng329 517d141
update README link
Ethanng329 fd10cb0
added env info
Ethanng329 19c5f97
updated env info
Ethanng329 c0b8544
updated changes
Ethanng329 f02e557
updates
Ethanng329 f6b1405
this should not be here, gitignore changed
Ethanng329 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| /node_modules | ||
| /static/bundle.js | ||
| /static/bundle.map.js | ||
| node_modules/ | ||
| env.development/ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,30 @@ | ||
| # Delivereat | ||
| # Deliver-Eat app | ||
|
|
||
| Let's create an app that allows customers to order food online. | ||
| - app to place order and browse items from database. | ||
|
|
||
| A few notes before we get started | ||
| <p align="center"><img src="./screenshot.png"></p> | ||
|
|
||
| * Fork and clone repo at [https://github.com/constructorlabs/delivereat](https://github.com/constructorlabs/delivereat) | ||
| * Start by building the simplest thing that works. Add to it as you go along. Test your application as frequently as possible to make sure it does what you expect | ||
| * Create a RESTful API for your service. Think about a good way to organise your API into **nouns** and **verbs**, which correspond to **resources** and **HTTP methods** | ||
| * Split your code into an API on the server and render data from server in browser using React. | ||
| * Splitting out our application into an API and interface allows us to re-use the API. For example we could use it to create a native mobile app or allow third parties to place orders on our system | ||
| * Commit frequently and push to Github | ||
| * Implement features one at a time | ||
| * Make sure your app is responsive | ||
| * You may want to design the API first, before implementing the UI that uses and API | ||
| ## Technology used | ||
|
|
||
| ## Features | ||
| - React | ||
| - node.js | ||
| - Javascipt | ||
| - CSS with responsive design | ||
| - HTML | ||
|
|
||
| **Menu** | ||
| * Design a menu for a restaurant such as food items, prices etc. By providing each item with an id we can refer to it later. The first item has already been created for you. Feel free to amend it. | ||
| * Create an API endpoint that returns a menu of items with prices available to order | ||
| * Create a page that displays the menu to the user using the API | ||
| # features | ||
|
|
||
| **Order** | ||
| - you can browse items(data pulled from server) add quantity to the shopping basket | ||
| - shopping basket will display current total | ||
| - you can submit order with customer information | ||
| - orders can be viewed <a href="https://delivereat.herokuapp.com/orders">here</a> | ||
|
|
||
| * Update the menu page to make it an order page | ||
| * It should allow the user to specify quantities of items to order | ||
| * It should add a delivery charge and display the total order cost | ||
| * Create an API to receive and save the submitted order | ||
| # team | ||
|
|
||
| **Closures** | ||
| Ethan - ([Twitter](https://twitter.com/Ethanng329)) - ([Github](https://github.com/ethan329)) | ||
|
|
||
| * Rather than storing all data in global scope on the server, try to implement data manipulation and retrieval functionality using closures. | ||
| # to run app | ||
|
|
||
| **Order history** | ||
|
|
||
| * Allow the user to see their order history | ||
| * Allow the user to re-order same items again | ||
| * Allow users to delete items from order history | ||
|
|
||
| **Extension** | ||
|
|
||
| * Design and implement an extension of your choosing | ||
|
|
||
| ## Stretch goals | ||
|
|
||
| **Admin** | ||
|
|
||
| * Create a new page for the restaurant owner to see all orders coming in | ||
| * When an order is ready to ship the restaurant owner needs to be able to mark the order as sent | ||
| * Create an API endpoint to receive and update order status | ||
|
|
||
| **Notification** | ||
|
|
||
| * Send the user an SMS using [Twilio](https://www.twilio.com/) when their order is ready | ||
|
|
||
| ## Technical notes | ||
|
|
||
| * Run `npm install` after cloning to download all dependencies | ||
| * Use `npm run dev -- --watch` to build React | ||
| * Use `node index.js` to run the Node server in another tab | ||
| * Place all static files such as images and CSS in the `static` folder. When requesting those files from the server use `/static` at the beginning of the URL. For example `<link rel="stylesheet" type="text/css" href="/static/styles.css">` | ||
| * `bundle.js` produced by webpack will be output in the `static` folder | ||
| * To send data server using a POST, PUT or PATCH request you can do something the example below, where `order` is an object we want to send to the server and `http://localhost:8080/api/order` is URL we want to send it to. | ||
|
|
||
| ```js | ||
| fetch('http://localhost:8080/api/order', { | ||
| method: 'post', | ||
| body: JSON.stringify(order), | ||
| headers: { | ||
| 'Content-Type': 'application/json' | ||
| } | ||
| }).then(function(response) { | ||
| return response.json(); | ||
| }).then(function(data) { | ||
| // handle response | ||
| }); | ||
| ``` | ||
|
|
||
| * Check out [Nodemon](https://nodemon.io/) to automatically rebuild and restart your server when changes are saved. | ||
|
|
||
| ## README | ||
|
|
||
| * Produce a README.md which explains | ||
| * what the project does | ||
| * what technologies it uses | ||
| * how to build it and run it | ||
| * any unresolved issues the user should be aware of | ||
| $npm run build | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <link rel="stylesheet" type="text/css" href="/static/styles.css"> | ||
| <title>Document</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div className="container"> | ||
| <div id="root"></div> | ||
| </div> | ||
| <script src="/static/bundle.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,111 @@ | ||
| const path = require('path'); | ||
| const express = require('express'); | ||
| const bodyParser = require('body-parser'); | ||
| const app = express(); | ||
| const MongoClient = require('mongodb').MongoClient; | ||
|
|
||
| require('dotenv').config({ | ||
| path: path.resolve(__dirname, `.env.${process.env.NODE_ENV}`) | ||
| }); | ||
|
|
||
| const url = `mongodb://${process.env.MONGO}:${process.env.PW}@ds253203.mlab.com:53203/delivereat`; | ||
|
|
||
|
|
||
| app.set('view engine', 'hbs'); | ||
|
|
||
| app.use(bodyParser.json()); | ||
|
|
||
| app.use('/static', express.static('static')); | ||
| app.set('view engine', 'hbs'); | ||
|
|
||
|
|
||
| const menu = { | ||
| 1: { | ||
| id: 1, | ||
| name: "Strawberry cheesecake", | ||
| price: 6 | ||
| name: 'Strawberry cheesecake', | ||
| price: 6, | ||
| img: | ||
| 'https://realfood.tesco.com/media/images/Strawberry-cheesecake-HERO-5a1d2423-4523-4f1e-9917-7bdf16c5008b-0-472x310.jpg' | ||
| }, | ||
|
|
||
| 2: { | ||
| id: 2, | ||
| name: 'Blueberry cheesecake', | ||
| price: 10, | ||
| img: | ||
| 'https://realfood.tesco.com/media/images/Strawberry-cheesecake-HERO-5a1d2423-4523-4f1e-9917-7bdf16c5008b-0-472x310.jpg' | ||
| }, | ||
|
|
||
| 3: { | ||
| id: 3, | ||
| name: 'Vanilla cheesecake', | ||
| price: 20, | ||
| img: | ||
| 'https://realfood.tesco.com/media/images/Strawberry-cheesecake-HERO-5a1d2423-4523-4f1e-9917-7bdf16c5008b-0-472x310.jpg' | ||
| }, | ||
|
|
||
| 4: { | ||
| id: 4, | ||
| name: 'New York cheesecake', | ||
| price: 30, | ||
| img: | ||
| 'https://realfood.tesco.com/media/images/Strawberry-cheesecake-HERO-5a1d2423-4523-4f1e-9917-7bdf16c5008b-0-472x310.jpg' | ||
| } | ||
| }; | ||
|
|
||
| app.get('/', function(req, res){ | ||
| res.render('index'); | ||
| let id = 5; | ||
|
|
||
| let orderTime = new Date(); | ||
|
|
||
| const orders = {}; | ||
|
|
||
| let orderid = 1; | ||
|
|
||
| app.get('/', function(req, res) { | ||
| res.render(__dirname + '/views/index.hbs'); | ||
| }); | ||
|
|
||
|
|
||
| app.get('/menu', function(req, res) { | ||
| MongoClient.connect( | ||
| url,{useNewUrlParser: true}, | ||
| function(err, db) { | ||
| if (err) throw err; | ||
| var dbo = db.db('delivereat'); | ||
| dbo | ||
| .collection('food') | ||
| .find({}) | ||
| .toArray(function(err, result) { | ||
| if (err) throw err; | ||
| console.log(result); | ||
| res.json(result); | ||
| db.close(); | ||
| }); | ||
| }) | ||
| }); | ||
|
|
||
| app.post('/api/order', function(req, res) { | ||
| const index = orderid; | ||
| orders[index] = req.body; | ||
| orders[index]['id'] = index; | ||
| orderid++; | ||
| orders[index]['orderTime'] = orderTime.toISOString(); | ||
| res.render('Successorder'); | ||
| }); | ||
|
|
||
| app.listen(8080, function(){ | ||
| console.log('Listening on port 8080'); | ||
| app.get('/orders', function(req, res) { | ||
|
|
||
| res.json(orders); | ||
| }); | ||
|
|
||
| // app.post('/menu', function(req, res) { | ||
| // const index = id; | ||
| // menu[index] = req.body; | ||
| // menu[index]['id'] = index; | ||
| // id++; | ||
| // res.status(200).json({ ok: 'menu added' }); | ||
| // }); | ||
|
|
||
| const port = process.env.PORT || 8080; | ||
| app.listen(port, function() { | ||
| console.log(`Listening on port number ${port}`); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented out code can be removed