git ssb

1+

clemo / helperjs



Branch:
Clemens Burger committed initLatest: fbad027 on 10/22/2016, 7:25:45 PM
📄.babelrc
📄.gitignore
📄.gitlab-ci.yml
📄Dockerfile.test
📄README.md
📄index.js
📁lib
📄package.json
📁test
README.md

devcontrol-helper

how does it work?

the best code of devcontrol in one module

add it to your package.json file

'dependencies':{
  ...
'devcontrol-helper':'git+https://git.devcontrol.org/team/helperjs.git#stable-v1'  
}

todo:

Debug

see npm package debug

DEBUG=helper:* node app.js

or to only log 1 lib:

DEBUG=helper:form node app.js

what can it do?

const player = new Lib('player');
player.setHook('beforeAdd',(x) => {x.name = x.name.toUpperCase();return x;});
let p1 = player.add({name:"Max Muster"});
console.log(player.getById(p1.id)); //{id:uuid,name:'Max Muster'}
console.log(player.getArray()) //[p1]
player.remove(p1.id);

vaitation.validator can be validator string or a boolean function

let validation = {name:{type:'text',element:'input',validator:'isLength',options:{max:20,min:10},required:true}}
//or
let validation = {name:{type:'text',element:'input',convert:(x){return x.toUpperCase()},validator(val){return val.length > 3}}
let sample = Form(validation);
sample.fill(post,false);
if(sample.isValid()){
  pug.renderfile('form.pug',sample);
}else{
  pug.renderfile('success.pug',sample);
}
//full pug and valitation file will follow soon
let m = new Math();
let u = m.uuid(); //unique id xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
console.log(m.checkUuid(u)) //true
console.log(m.random(0,5)); //int between 0 and 5
console.log(uniqueRandomArray(10,0,30)); //[10 unique values]
import {config} from 'devcontrol-helper';
console.log(config); //object cointaining of config.default.js, config.js, APP_ENV
or
import {Config} from 'devcontrol-helper';
const config = new Config(env.PWD,'APP'); //directory, env-prefix

config.js and config.default.js can look like this

module.exports.development = {
  title:'hello developer'
}
module.exports.test = {
  title:'hello test-world'
}
module.exports.production = {
  title:'hello world'
}

to overwrite an config property on execution:

APP_TITLE="meeeh" npm run start

express module is awesome, more doku and examples are comming with stable-v2

import * as helper from 'devcontrol-helper';
helper.express.moduleLoader(app, config, passport);

Built with git-ssb-web