Scaffold out a devis project
_-----_ ╭──────────────────────────╮
| | │ Welcome to devis │
|--(o)--| │ microservice framework │
`---------´ │ generator! │
( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
__'.___.'__
´ ` |° ´ Y `
Wakanda is a W-RAD (Web Rapid Application Development) as well as M-RAD (Mobile Rapid Application Development), designed for creating multi-channel applications for mobile, web and desktop.
Wakanda App Factory consists of a stack of tools and technologies:
-Wakanda Server
Combines a relational object database with a JavaScript server engine.
-Wakanda Studio
Is a desktop IDE with WYSIWYG editors for designing the data model and prototyping the UI of the application. It provides building functionalities for mobile development (using Apache Cordova). Wakanda Application Framework (WAF) Consists of a data provider to communicate with the server and interface with front-end frameworks like AngularJS and Ionic.
Yeoman helps you to kickstart new projects, prescribing best practices and tools to help you stay productive.
To do so, Yeoman provide a generator ecosystem. A generator is basically a plugin that can be run with the yo
command to scaffold complete projects or useful parts.
Installation
npm install -g yo generator-devis
Or, if you upload the project
Install both yeoman and the generator:
npm install -g yo generator-generator
Setup a generator project:
yo generator
Link the generator in the global node modules:
npm link
Navigate to a folder you would love to scaffold a new project and run:
yo devis
we will define each part of the generator as a tree
|.app
|-->.script
|---->.script.js
- generate local depencies on different microservices and run server you can customise the code if you want for example use different microservice remotely not localy.
|---->You can add other scripts there
|-->.root.js
- it is here where will be added the different microservices locally or as a client
|-->.route.js - This is an optional file that you can delete if you want or take it as example to create your own. it's in this module where will be implemented and evaluated the different functions that you will use in the index file.
By default this module contains the functions put, get, post and delete to express routing framework, as i said it's just an example.
|-->.wakanda_config - it's here where you will find the necessary configuration to connect wakanda via api rest, you should change the login and password and you can add different data tables to use.
Of course you can delete this file or take it as example to connect another interface, or database, MongoDB for example by implementing the adequate Microservice.
|-->.client.json - If you intended to consume distance microservices you should add here the necessary information For each Microservice and the script that i described previously will handle these microservices by adding them to the root file.
|.microservices - You will add there your different microservices
|-->.Micro1
|---->.main.js - It's the core of your Microservice where you will define the different properties, but for clarity, you will only define the properties here, the callback functions will be reported elsewhere in the libs folder.
|---->.libs - Example:
If your Microservice is model called and contains properties: GET and Post then your main.js will be like that:
let model = require("devis");
let model_f = require("./libs/functions");
model.add({
role: "model",
action: "GET"
},
model_f.GET);
model.add({
role: "model",
action: "POST"
}, model_f.POST);
module.exports = model;
And the functions file will be something like that:
function POST(args, done) {
//do something
done(finalresult);
}
function GET(args, done) {
//do something
done(finalresult);
}
module.exports={
POST:POST,
GET:GET
}
|---->.confs
|------>.core.js
- If you want your Microservice to be used remotly too you should do like the two available microservices by adding the dependencies in the file depencies if you have.
|.index - it is here or you'll exploit your different microservices.
Once installed, you can start creating microservices by using devis framework. You can rely on both microservices that already exist in the project: model and authentification.
After, you should add your microservices to the file root.js, located in the folder app. Fortunately there already a script that will perform this task in your place , you just have to run the command :
npm install
npm start
If you just wanna test both existing microservices, you should install [ wakanda ] ( https://wakanda.github.io ), add one or more tables , a use, change login and password on app/wakanda_config.js
and launch
npm install
npm start
node index.js
The script will generate automatically the file root.js: use both microservices and launch the server. By running the index file you will consume the server and log in wakanda.
If you want to know handles that a Microservice offers, like model , you just have to write the following command:
npm run-script log microservices/model/main
If this microservice are distant, for example
var devis=require("devis");
devis.add({
action: 'game',
cmd:'play'
}, function(args, done) {
done({ result: 'play' });
});
devis.add({
action: 'game',
cmd:'pause'
}, function(args, done) {
done({ result: 'pause' });
});
devis.listen({
host:'127.0.0.1',
port:3030
})
You should run
npm run-script log connect port : '3030' , host : "127.0.0.1"
Don't forget space between each argument!
A file will be created under the name devis-log.txt or you will find all the information regarding this Microservice.