molly-db 1.3.6 → 1.3.7

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.
@@ -28,15 +28,20 @@ module.exports = function(db,req,res,arg){
28
28
 
29
29
  req.on('data',(chunk)=>{ raw.push(chunk) });
30
30
  req.on('close',()=>{
31
- const data = JSON.parse(Buffer.concat(raw));
32
- send(db,arg,data).then(msg=>{
33
- const status = msg.match(/\d+/i)[0];
34
- res.writeHead(status,{'content-type': 'text/plain'});
35
- res.write(msg); res.end();
36
- }).catch(e=>{
31
+ try {
32
+ const data = JSON.parse(Buffer.concat(raw));
33
+ send(db,arg,data).then(msg=>{
34
+ const status = msg.match(/\d+/i)[0];
35
+ res.writeHead(status,{'content-type': 'text/plain'});
36
+ res.write(msg); res.end();
37
+ }).catch(e=>{
38
+ res.writeHead(404,{'content-type': 'text/plain'});
39
+ res.write(e); res.end();
40
+ })
41
+ } catch(e) {
37
42
  res.writeHead(404,{'content-type': 'text/plain'});
38
- res.write(e); res.end();
39
- })
43
+ res.write('unexpected body'); res.end();
44
+ }
40
45
  });
41
46
 
42
47
  }
@@ -33,7 +33,7 @@ module.exports = (arg)=>{ init( arg ).then((db)=>{
33
33
  const server = http.createServer((req,res)=>app(db,req,res,arg));
34
34
  server.listen( arg.port, arg.host, ()=>{
35
35
  console.log(JSON.stringify({
36
- name: 'molly-file', protocol: 'HTTP',
36
+ name: 'molly-db', protocol: 'HTTP',
37
37
  port: arg.port, host: arg.host,
38
38
  }));
39
39
  }); saveTimeout( arg, db );
package/package.json CHANGED
@@ -5,12 +5,12 @@
5
5
  "repository": "https://github.com/EDBC-REPO-NPM/Molly-db",
6
6
  "dependencies": {
7
7
  "crypto-js": "^4.1.1",
8
- "molly-fetch": "^1.1.2"
8
+ "molly-fetch": "^1.1.7"
9
9
  },
10
10
  "license": "MIT",
11
11
  "main": "main.js",
12
12
  "name": "molly-db",
13
- "version": "1.3.6",
13
+ "version": "1.3.7",
14
14
  "author": "bececrazy",
15
15
  "description": "Molly-db is a free and open source library for nodejs that allow you create a lightweight encrypted database using Json files",
16
16
  "keywords": [