UNPKG

molly-db

Version:

Molly-db is a free and open source library for nodejs that allow you create a lightweight encrypted database using Json files

37 lines (27 loc) 1.9 kB
/*--────────────────────────────────────────────────────────────────────────────────────────────--*/ const path = require('path'); const url = require('url'); const fs = require('fs'); /*--────────────────────────────────────────────────────────────────────────────────────────────--*/ function config( _config ) { const _default = { offset:0, length:100 }; if( !_config ) return _default; Object.keys(_config).map(x=>{ _default[x] = _config[x]; }); } /*--────────────────────────────────────────────────────────────────────────────────────────────--*/ class molly_db{ constructor( opt ){ const dir = path.join(__dirname,'/module/worker_handler.js'); this.host = opt?.host || '127.0.0.1'; this.protocol = opt?.protocol || 'http'; this.port = opt?.port || 27017; this.path = opt?.path || null; this.pass = opt?.pass || null; this.time = opt?.saveTime || .1; return require(dir)(this); } } /*--────────────────────────────────────────────────────────────────────────────────────────────--*/ module.exports = molly_db;