molly-db 1.0.33 → 1.0.40
Sign up to get free protection for your applications and to get access to all the features.
- package/main.js +1 -1
- package/module/_app_.js +1 -1
- package/module/_worker_.js +2 -6
- package/package.json +1 -1
package/main.js
CHANGED
@@ -20,7 +20,7 @@ class molly_db{
|
|
20
20
|
this.path = opt.path.replace( /^\./,process.cwd() );
|
21
21
|
this.threads = opt.threads || 1;
|
22
22
|
this.import = opt.import || '';
|
23
|
-
this.time = opt.saveTime || .
|
23
|
+
this.time = opt.saveTime || .1;
|
24
24
|
return require(`${__dirname}/module/_worker_.js`)(this);
|
25
25
|
}
|
26
26
|
}
|
package/module/_app_.js
CHANGED
@@ -145,10 +145,10 @@ async function save( _params ){
|
|
145
145
|
(async ()=>{
|
146
146
|
try{
|
147
147
|
|
148
|
+
body = await getBody();
|
148
149
|
if( api.pathname == '/saveAll' )
|
149
150
|
return json( await saveAll() );
|
150
151
|
params = await validate(params);
|
151
|
-
body = await getBody();
|
152
152
|
|
153
153
|
/* Find Api */
|
154
154
|
switch( api.pathname ){
|
package/module/_worker_.js
CHANGED
@@ -14,12 +14,10 @@ const db = new Object();
|
|
14
14
|
const api_script = fs.readFileSync(`${__dirname}/_api_.js`).toString();
|
15
15
|
const app_script = fs.readFileSync(`${__dirname}/_app_.js`).toString();
|
16
16
|
const init_script = fs.readFileSync(`${__dirname}/_init_.js`).toString();
|
17
|
-
//const importDB_script = fs.readFileSync(`${__dirname}/_importDB.js`).toString();
|
18
17
|
|
19
18
|
/* --------------------------------------------------------------------------------------- */
|
20
19
|
|
21
20
|
async function _init_(){ await eval(`try{ ${init_script} }catch(e){console.log(e)}`) }
|
22
|
-
async function _importDB_(){ await eval(`try{ ${importDB_script} }catch(e){console.log(e)}`) }
|
23
21
|
async function app(req,res){ await eval(`try{ ${api_script} \n ${app_script} }catch(e){console.log(e)}`) }
|
24
22
|
|
25
23
|
/* --------------------------------------------------------------------------------------- */
|
@@ -28,10 +26,8 @@ function saveTimeout(){
|
|
28
26
|
setTimeout(() => {
|
29
27
|
if( db._update_ ){db._update_ = false;
|
30
28
|
const port = process.mollyDB.port;
|
31
|
-
const api =
|
32
|
-
|
33
|
-
path: '/saveAll'
|
34
|
-
}); fetch(api).then().catch();
|
29
|
+
const api = `http://127.0.0.1:${port}/saveAll`;
|
30
|
+
fetch(api).then(()=>{}).catch(()=>{});
|
35
31
|
}
|
36
32
|
}, time);
|
37
33
|
}
|