Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5d5bfe5
first attempt
Ethanng329 Jul 1, 2018
ba73801
refactored and changed a few spelling
Ethanng329 Aug 21, 2018
a4dbfaf
head reset
Ethanng329 Sep 21, 2018
e604e4a
reseting head
Ethanng329 Sep 21, 2018
a10822d
node js changes
Ethanng329 Sep 21, 2018
6c1a785
route changed
Ethanng329 Sep 21, 2018
ce22da5
handlebar path updated
Ethanng329 Sep 21, 2018
d008376
script amended
Ethanng329 Sep 21, 2018
ef2c71a
added publicpath
Ethanng329 Sep 21, 2018
87ad221
debugging
Ethanng329 Sep 21, 2018
35e90e3
fixing path
Ethanng329 Sep 21, 2018
40d5b0a
fixing path
Ethanng329 Sep 21, 2018
28a4e16
webpack changes
Ethanng329 Sep 21, 2018
6447db1
webpack updates
Ethanng329 Sep 21, 2018
be2e45d
path fixing
Ethanng329 Sep 21, 2018
3b944e8
path fixing
Ethanng329 Sep 21, 2018
73889af
defining handlebar type
Ethanng329 Sep 24, 2018
531fcee
npm build run
Ethanng329 Sep 24, 2018
8b00349
.
Ethanng329 Sep 24, 2018
b97c17e
added route
Ethanng329 Sep 24, 2018
dbd15fe
added path
Ethanng329 Sep 24, 2018
d132954
node updates
Ethanng329 Sep 24, 2018
15ba93a
handle bar test
Ethanng329 Sep 24, 2018
00c5a7e
node updates
Ethanng329 Sep 24, 2018
cdc5a15
node update
Ethanng329 Sep 24, 2018
ad01906
merged
Ethanng329 Sep 24, 2018
4b7ef0b
remove bundle from gitignore
Ethanng329 Sep 26, 2018
c6e465e
README updated
Ethanng329 Sep 27, 2018
768883b
screenshot centered
Ethanng329 Sep 27, 2018
c043a2a
README updates
Ethanng329 Sep 27, 2018
517d141
update README link
Ethanng329 Sep 27, 2018
fd10cb0
added env info
Ethanng329 Nov 6, 2018
19c5f97
updated env info
Ethanng329 Nov 6, 2018
c0b8544
updated changes
Ethanng329 Nov 6, 2018
f02e557
updates
Ethanng329 Nov 6, 2018
f6b1405
this should not be here, gitignore changed
Ethanng329 Nov 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
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/

96 changes: 19 additions & 77 deletions README.md
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
```
19 changes: 19 additions & 0 deletions index.html
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>
102 changes: 95 additions & 7 deletions index.js
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) {
Copy link
Contributor

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

// 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}`);
});
Loading