Lecturer Suggestion
- Decide which routes your app needs
- Code 'stubs' for each route
- Code small HTML pages to test the design
- Static HTML files instead of writing HTML from Express
- Covert static files to Handlebars templates
- Insert data into his templates - at first, hard-coded JSON
- Now, fetch the data from MongoDB database
- Add a header and footer and some CSS to main.hbs
npm init -y
package.json appears
npm install <package> [local or global]
npm install express
const <varname> = require('express')
npm install mongodb
- Decide :: what routes do we need to display these screens?
/food/123
/filter (GET and POST)
Target :: Snacks in a Van
Expectation → 100 vans and 100k customers
Customer App
Needs:
- Get customer current location
- Calculate the five closest vans → display their details
- show details as a list
- show their location on the map
- Menu function
- Order function
- Without login:
login:
Order:
- One or more snacks
- quantities
- confirmation
- timestamp
- 20% discount for customer if snacks are not ready in 15 mins
- allow cancel order within 10 mins before fulfilled
- Cancel order invisiable towards customer and vender
- save all order
- change order will reset the timestamp and window session
- Rating system
Vender App
- login using van name
- store location to database → get geo location
- Mark van status
- outstanding order
- order details
- order number
- given name
- minutes remaining
- update order status
Menu
→ No hard coding
→ Don't breach the copyright
Current sales:
- Latte
- Flat white
- Long black
- plain biscuit
- fancy biscuit
- small cake
- big cake
Location, distance and map
→ geo location (longitude, latitude) 4 decimal points
→ Get location via Geolocation API
→ display location
Live page
npm install md5
var md5 = require('md5');
console.log(md5('message'));
Database management
express
express.router