The NodeZA platform is an express application that uses handlebars for templating, MySQL as the main application database, Bookshelf.js ORM, and Redis for session storage. It has a custom plugin system responsible for displaying content snippets, the plugins are called widgets
.
Some of the major dependencies are express
, mysql
, knex
, bookshelf
, and connect-redis
. Please checkout the dependencies page for a complete list.
Clone this repo to your local machine and install dependencies.
git clone https://github.com/nodeza/nodeza.git &&
cd nodeza && npm install
Once all the dependencies are installed we need to setup our database and create tables.
npm run setup
You will be prompted for your database information.
NodeZA is built on a MVC-like architecture. The main building blocks are models
, collections
, views
, controllers
, widgets
, and routes
.
/
collections/
models/
controllers/
views/
widgets/
routes/
The descriptions below are guidelines that have been used in the NodeZA project and should be followed as closely as possible.
Routes are the entry point to the application, they are responsible for routing and determine which controller
and method to call for each http request.
All routes are located in the routes
directory
Controllers contain the logical parts that work as a glue between views
and models
. They accept a request and response object, load data from a model
or collection
, pass the data to a view
template and then render the view
.
Each path base should have its own controller
, e.g, the route /events
should have a controller
named events.js
.
All controllers are located in the controllers
directory.
A model
is associated with a database table and its properties represent the table columns. The whole table is represented by the associated collection
- which is basically a group of the same model
. A model
name should be a singular and a
collection
name should be the plural version.
All models
are located in the models
folder and collections
in the collections
folder.
A widget
is a special kind of module. It is self contained and is completely decoupled from other parts of the application.
A widget comprises of 3 files, config.json
, template.hbs
, and index.js
.
config.json
contains the configuration.
template.hbs
contains the handlebars template.
index.js
is the main program file.
npm test
Create a new branch, make changes, commit and push branch.