molly-db 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ module.exports = function(){
2
+ //FIXME: falta crear el importador DB
3
+ }
@@ -1,4 +1,5 @@
1
- const crypto = require('./crypto_handler')
1
+ const download = require('./import_handler');
2
+ const crypto = require('./crypto_handler');
2
3
  const fetch = require('molly-fetch');
3
4
  const readline = require('readline');
4
5
  const path = require('path');
@@ -23,7 +23,7 @@ module.exports = function( data,inst,db ){
23
23
  const cfg = copy(data,input[i]); try {
24
24
  const bool = await utils.validator(db,cfg);
25
25
  if( !bool[0] ) return reject(bool[1]);
26
- else result.push(utils[cfg.type](cfg,db));
26
+ else result.push(await utils[cfg.type](cfg,db));
27
27
  } catch(e) {
28
28
  return reject({ status:404, message:`error: ${e.message}` })
29
29
  }
package/module/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /*--────────────────────────────────────────────────────────────────────────────────────────────--*/
2
2
 
3
3
  const crypto = require('./crypto_handler');
4
+ const init = require('./init_handler');
4
5
  const path = require('path');
5
6
  const output = new Object();
6
7
  const fs = require('fs');
@@ -335,4 +336,22 @@ output.saveAll = async function(data,db){
335
336
 
336
337
  /*--────────────────────────────────────────────────────────────────────────────────────────────--*/
337
338
 
339
+ output.reset = async function(data,db){
340
+ const args = JSON.parse(process.env.MOLLY_DB_ARGS);
341
+ return new Promise((response,reject)=>{
342
+ init( args ).then((ndb)=>{ db = ndb;
343
+
344
+ return response({
345
+ status: 200,
346
+ database: data.db,
347
+ table: data.table,
348
+ message: 'DB Reseted'
349
+ });
350
+
351
+ }).catch((e)=>{ response(parseError(db,data,e)) });
352
+ })
353
+ }
354
+
355
+ /*--────────────────────────────────────────────────────────────────────────────────────────────--*/
356
+
338
357
  module.exports = output;
@@ -26,6 +26,7 @@ function saveTimeout(data,db){
26
26
  /*--────────────────────────────────────────────────────────────────────────────────────────────--*/
27
27
 
28
28
  module.exports = (args)=>{
29
+ process.env.MOLLY_DB_ARGS = JSON.stringify(args);
29
30
  init( args ).then((db)=>{ saveTimeout( args, db );
30
31
  const dir = path.join(__dirname,'server_worker.js');
31
32
  const srv = new worker.Worker(dir,{ workerData: args });
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "license": "MIT",
10
10
  "main": "main.js",
11
11
  "name": "molly-db",
12
- "version": "1.3.3",
12
+ "version": "1.3.4",
13
13
  "author": "bececrazy",
14
14
  "description": "Molly-db is a free and open source library for nodejs that allow you create a lightweight encrypted database using Json files",
15
15
  "keywords": [