X-Easy
This is a simple way to raise a server in Node.JS.
Module installation
npm install x-easy --save
// or
yarn add x-easy
Using Example
Simple start file
//<project_path>/index.js // the default port is 3000// global object call. possibilities:// XEasy, xEasy, xeasy, XEASYXEasy // addModule can load <project_path>/<module_name>/index.js, <project_path>/<module_name>/index.json, // <project_path>/<module_name>.js and <project_path>/<module_name>.json // file to load data // json file // file to default settings // js file // file for route settings // js file // file for websocket settings // js file // method for creating channel between processes // start children process /* 'auto' sets automatic scanning for the number of processor ** cores and creates processes for each of them ** .start('auto') with 6 cores start 6 process ** ** negative numbers subtract from the number of cores to ** generate the number of processes that at least 1 ** .start(-2) with 6 cores start 4 process*/ start/* number of process, default is 1*/
The loadModule function is used to instantiate objects in the application by passing it in the constructor.
//data.json 'data': 'something else' 'viewEngine': 'pug' 'viewEnginePath': 'pages'
//config.jsmoduleexports = // order of the constructor parameters does not matter { // event called when the process is exiting app { //... stopping worker } // method that receives messages from channels between processes app // for password protection, this method transforms the hashed data app app // children properties can also be digested app // method to take a public folder app // if there are subfolders // app.setPublic('public/images') // page rendering system app app // permission for accept upload of files app }
//routes.jsmoduleexports = // again! order of the constructor parameters does not matter { app /** CAUTION **/ // the file will be loaded into RAM memory app }
//websocket.jsconst URL = moduleexports = // again! order of the constructor parameters does not matter // the definition of possibilities is in the part of // Constructor Parameters { wss
The websocket api documentation is located on this link
Constructor Parameters
server // http server objectapp // XEasy app controlname // application name entered in the creationworker // child process control objectwss || websocketServer || wsServer // Websocket servermodules // list of added modules in applicationdigest // convert data into hash sha512