it's my util collection
npm i node-jutil --save
-
npm install to node-jutil
-
require to node-jutil
var jutil = require('node-jutil');
- call to util
- 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;
}
});
- redis
jutil.cache.redis.connect('url');
- 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');
- net
jutil.net.http({
// option..
}, (err, res, body) => {
// result code..
});
- 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');