Web Application and API (waaa)
npm install waaa
The why and how
Problem 1: There are many cases where in the development process, the body which makes the html & css are not part of the team which actually need to embed the content into a project. There are times, when a developer takes the html content and change it to fit to the current project/framework/templates and strip different part of it to create dynamic generated content and master pages. This leads to pain in the arse when changes on the front end are needed and are made by the original html creator(s) which sometimes does not even remotely looks like the current html content on the project end and the developer have a very hard time figuring out what needs to be changed and where.
This leads to healthy decoupling between the front end development to the backend development, where the front end development only taking care of UI and UX, and the backend development only takes care of the project logic and data flows.
The pages and auto API features are enables by default but can easily turned off and the module exposes the express module in cases you need to implement your own web server logic.
The following code will start a web server with the default parameters.
var waaa = ;waaastart;
Web server parameters
The following parameters can be supplied to the web server
appFolder (String) - the root folder of the site/application (i.e. /var/www/, /root/my_project/site, __dirname, etc.)
confFolder (String) - the folder of the configuration files (i.e. /var/www/conf, /root/my_project/site/conf, __dirname + '/conf/', etc.)
usePages (Boolean) - enable the pages handling. true by default. When using this feature, a valid pages.json must exist in the configuration folder
useModules (Boolean) - enable the auto API handling. true by default. When using this feature, a valid modules.json must exist in the configuration folder
port (Integer) - The web server port. default is 80.
var waaa =options = appFolder: __dirname confFolder: __dirname + '/config/' port:8080;waaastartoptions;
"master":"default":"template":"/templates/pages/master.html""special":"template":"/templates/pages/master_special.html""pages":"master":"default""home":"title":"my site::home""template":"/templates/pages/home.html""resources":"js":"/static/js/home.js""css":"url":"/static/css/home.css""attr":"media":"screen""news":"title":"my site::news""template":"/templates/pages/news.html""master":"special""resources":"js":"/service/module/news""/static/js/news.js"
master - [optional] list of master pages
[master_name] - name of a master pages settings
template - path to a relative master page template in the root of the app folder
pages - [required] list of pages
master - [optional] default master pages name for all the pages
[page_name] - [required] the page name as it will be fetched (i.e. http://www.mysite.com/pages/[page_name])
title - [optional] text to set as the inside the page title element
template - [required] path to a relative page template in the root of the app folder
master - [optional] use a specific master page
css - [optional] - list of css files to attach to page
url - [required] - path to the css file
attr - [optional] - list of key value collection to be used as attributes on the link element
modules - [required] list of modules to expose
[module_name] - [required] the module name to be used in the auto API (i.e. http://www.mysite.com/modules/[module_name])
location - [optional] override the modules location folder for this module
fileName - [required] the module file name inside the modules folder
methods - [optional] list of public methods in the module which should be exposed as part of the auto API
properties - [optional] list of public properties in the module which should be exposed as part of the auto API
Master pages are optional but when they are used, there are very basic rules to follow.
In the master page declare an element with the id of "content", that's where the content pages will be injected
When a page is merged with a master pages, all the content under the body element is used, and if only a partial part of the page is needed, use the ".bodyContent" class on an element which wraps the desired content