0.0.1 • Published 8 years ago

node-jutil v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

node-jutil

NPM Version Join the chat at https://gitter.im/devjin0617/node-jutil

it's my util collection

how to install

npm i node-jutil --save

how to use

  1. npm install to node-jutil

  2. require to node-jutil

var jutil = require('node-jutil');
  1. call to util

db

  • mongodb
jutil.db.mongo.connect('mongo://url.to/dbname');
  • mysql
jutil.db.mysql.connect({
    host : 'url'
    user : 'username',
    password : 'password',
    database : 'db name'
}, (err) => {
    if(err) {
        console.log(err);
        return;
    }

});
  • mssql
jutil.db.mssql.connect({
    user: 'id',
    password: 'password',
    server: 'url',
    database: 'db name'
}, (err) => {
    if(err) {
        console.log(err);
        return;
    }

});

cache

  • redis
jutil.cache.redis.connect('url');

crypto

  • crypto
var crypto = jutil.crypto;

var strMD5 = crypto.md5('helloworld');

var strSHA1 = crypto.sha1('hellworld');

var strSHA256 = crypto.sha256('helloworld');

var strSHA512 = crypto.sha512('helloworld');

networking

  • net
jutil.net.http({
    // option..
}, (err, res, body) => {
    // result code..
});

logger

  • log
var jconsole = jutil.log;

jconsole.log('hello world');

jconsole.trace('hello world');

jconsole.debug('hello world');

jconsole.info('hello world');

jconsole.warn('hello world');

jconsole.error('hello world');

jconsole.fatal('hello world');