A dummy module for the Gladys-Project
See documentation on Gladys Doc
This has been designed for early stages of comprehension on gladys' modules dev and mostly inspired by Gladys Doc
It does nothing but installing files in '/api/hooks/slug' Slug is the slug you define when installing a module in advanced mode.
This file should be a node module ( Node doc ) that exports a function which takes 'sails' as only argument
index.js in root folder:
// index.js
module.exports = function(sails) {
const myAwesomeFunction = require('./lib/myAwesomeFunction');
const iLoveGladys = require('./lib/iLoveGladys');
return {
myAwesomeFunction : myAwesomeFunction,
iLoveGladys : iLoveGladys
}
};
the rest of the code in /lib
| - index.js | - lib | - myAwesomeFunction.js | - iLoveGladys.js
If your not familiar with Promise : check this
Most existing Gladys modules use 'bluebird' to "promisify" : See doc here
// /lib/myAwesomeFunction.js
const Promise = require('bluebird');
module.exports = function myFirstFunction() {
return new Promise(function(resolve, reject) {
// async work here
const valueToReturn = 42;
resolve(valueToReturn);
// if something fails
reject(new Error('Oups'));
})
};
Simply do :
gladys.modules.myAwesomeModule.MyStunningFunc()
If you want to acces or log the results of those functions, don't forget they return a Promise !
gladys.modules.myAwesomeModule.MyStunningFunc()
.then((result)=> console.log(result))
.catch((error) => console.log('oups: ', error );
If u don't like git and are silly... Copy paste the content of each file respecting the tree.
Or...
-
Clone this repo :
cd /path/To/My/Projects/Directory git clone https://github.com/Boimb/gladys-dummy-module.git
-
Create your new repo in github or gitlab or whatever.
-
Clone it
git clone <my-awesome-module-git-uri>
-
Copy files from gladys-dummy-module to my-awesome-module
/bin/cp -rf gladys-dummy-module my-awesome-module
-
Remove reference to initial git repo
cd my-awesome-module rm -R .git
-
Push new files
git init git add . git commit -a -m "Initial commit" git remote add origin <my-awesome-module-git-uri> git push -u --force origin master
-
Now you're on your own...
Released under MIT Licence