0.0.1 • Published 8 years ago
node-jutil v0.0.1
node-jutil
it's my util collection
how to install
npm i node-jutil --save
how to use
npm install to node-jutil
require to node-jutil
var jutil = require('node-jutil');
- 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');
0.0.1
8 years ago