Eat-Da-Burger it is a web app which showcase the capabilities of some important web technologies working together such as:
NodeJS, Express, Handlebars, MySQL and Heroku in action.
- The user will have a Text Box available to type and submit the name of the Burger of his/her like.
- All these burgers will pile up in the left side of the window with a button to activate the action of devour the Burger.
- Once a burger is
Devoured
this will be piled up in the right side of the window. - All the Burgers will be stored in the database.
- Repository
2018bootcamp12NodeExpressHandlebars
created and cloned locally. npm init
executed inside the project.- Dependencies installed.
npm install express
npm install express-handlebars
npm install mysql
npm install path
- Create the
server.js
file which is the applications entry point. - Create the app directory to contain all our application dependencies.
- Create the
db
directory and inside it:- Create the
schema.sql
file to define the database:- Database:
burgers_db
. - Table:
burgers
.- id
- burguer_name
- devoured
- Database:
- Create the
seeds.sql
file and create three entries. - Run these two files into MySQL Workbench.
- Create the
- Create the
config
directory and inside it:- Create the
connection.js
file with:- MySQL connection configuration
host
,port
,user
,password
anddatabase
.
- MySQL connection configuration
- Create the
orm.js
file with:- The following methods to interact with MySQL Database:
- selectAll()
- insertOne()
- updateOne()
- Export the ORM object in module.exports.
- The following methods to interact with MySQL Database:
- Create the
- Create the
models
directory and inside it:- Create the
burger.js
file with:- A require statement for the
orm.js
. - Methods that use the ORM functionality to manipulate the burgers.
- Export the Burger object in
module.exports
.
- A require statement for the
- Create the
- Create the
controllers
directory and inside it:- Create burgers_controller.js file with:
- Require Statements of
Express
andburger.js
. - A Router with the routes that perform the required actions that interact with the views.
- Export the Router object.
- Require Statements of
- Create burgers_controller.js file with:
- Create the
public
directory and inside it:- Create the
css
directory with:style.css
file for custom styles.
- Create the
img
directory.- Include the required images.
- Create the
js
directory.- Create the
burgers_frontend
file, this will contain all front end javascript functionality.
- Create the
- Create the
- Create the
views
directory and inside it:- Create the
index.handlebars
file. - Create the
layouts
directory with:- The
main.handlebars
file.
- The
- Create the
partials
directory with:- The
burger-block.handlebars
file.
- The
- Create the
- Complete the ORM and Model functionality.
- Build the Routes in the controller and use the Model methods.
- Populate the information in the Front end.
- Iterate over the code into
index.handlebar
,frontend.js
and thecontroller.js
to finish up the required application functionalities.
orm.slectAll(tableInput, cb)
tableInput: String "Name of the Table"
cb: function "Callback Function"
orm.insertOne(table, cols, vals, cb)
table: String "Name of the Table"
cols: Array "Column Names"
vals: Array "Values of the Fields"
cb: function "Callback Function"
orm.updateOne(table, objColVals, condition, cb)
table: String "Name of the Table"
objColVals: Object "// An example of objColVals would be {burger_name: TinyMc, devoured: true}"
condition: ** Example of Condition "id = " + req.params.id
cb: function "Callback Function"
orm.deleteOne(table, id, cb)
table: String "Name of the Table"
id: Integer "id"
cb: function "Callback Function"
burger.all(cb)
cb: function "Callback Function"
burger.create(cols, vals, cb)
cols: Array "Column Names"
vals: Array "Values of the Fields"
cb: function "Callback Function"
burger.update(objColVals, condition, cb)
objColVals: Object "// An example of objColVals would be {burger_name: TinyMc, devoured: true}"
condition: ** Example of Condition "id = " + req.params.id
cb: function "Callback Function"
burger.delete(id, cb)
table: String "Name of the Table"
id: Integer "id"
cb: function "Callback Function"
server.js
^ ^
^ express = app <<<<<<<< app.use(routes)
^ ^
controllers.burgers_controllers.js = router
^ ^ ^
^ ^ express.Router()
^ ^
^ views.index > views.layouts.main < public.assets
^ ^
^ views.partials.burger.burger-block
^
^
models.burger.js
^
config.orm.js
^
config.connection.js