Browse Source

db file in config

isundil 6 years ago
parent
commit
1826b4ec65
2 changed files with 17 additions and 14 deletions
  1. 13 12
      package.json
  2. 4 2
      srv/src/database.js

+ 13 - 12
package.json

@@ -1,18 +1,19 @@
 {
   "name": "mimouchat",
   "description": "Slack http client using long polling",
-  "dependencies": [
-    "ws",
-    "http",
-    "client-sessions",
-    "crypto",
-    "sqlite3",
-    "node-file-cache",
-    "memory-cache",
-    "sleep",
-    "jimp",
-    "openpgp"
-  ],
+  "dependencies": {
+    "client-sessions": "latest",
+    "crypto": "latest",
+    "http": "latest",
+    "jimp": "latest",
+    "lowdb": "^0.14.0",
+    "memory-cache": "latest",
+    "node-file-cache": "^1.0.2",
+    "openpgp": "latest",
+    "sleep": "^5.2.3",
+    "sqlite3": "^4.0.0",
+    "ws": "latest"
+  },
   "repository": {
     "type": "git",
     "url": "git@git.knacki.info:isundil/mimouchat"

+ 4 - 2
srv/src/database.js

@@ -1,8 +1,9 @@
 const sqlite3 = require('sqlite3'),
     updateAccountTable = require('./models/accounts.js').updateTable,
-    updateAccountConfigTable = require('./models/accountConfig.js').updateTable;
+    updateAccountConfigTable = require('./models/accountConfig.js').updateTable,
+    config = require("../config.js");
 
-const DB_PATH = __dirname +"/../database.sqlite",
+const DB_PATH = config.db || (__dirname +"/../database.sqlite"),
     DB_VERSION = 3;
 
 function updateMetaTable(dbObj, currentVersion, cb) {
@@ -60,6 +61,7 @@ Database.prototype.updateTables = function(cb, currentVersion) {
 Database.prototype.initDb = function(cb) {
     var self = this;
     if (!self.db) {
+	console.log("DB: " +DB_PATH);
         self.db = new sqlite3.Database(DB_PATH, sqlite3.OPEN_READWRITE, (err) => {
             if (err) {
                 if (err.code === "SQLITE_CANTOPEN") {