Added the config module to handle app configuration loading; adding data/ folder for local sqlite storage

This commit is contained in:
Gregory Ballantine 2022-11-02 14:03:20 -04:00
parent aa980948d8
commit 182356c685
5 changed files with 49 additions and 1 deletions

6
config/default.json Normal file
View File

@ -0,0 +1,6 @@
{
"database": {
"driver": "sqlite",
"connection_string": "data/overseer.db"
}
}

0
data/.gitkeep Normal file
View File

36
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "0.1.0", "version": "0.1.0",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"config": "^3.3.8",
"express": "^4.18.2", "express": "^4.18.2",
"sequelize": "^6.25.3", "sequelize": "^6.25.3",
"sqlite3": "^5.1.2", "sqlite3": "^5.1.2",
@ -1041,6 +1042,17 @@
"typedarray": "^0.0.6" "typedarray": "^0.0.6"
} }
}, },
"node_modules/config": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/config/-/config-3.3.8.tgz",
"integrity": "sha512-rFzF6VESOdp7wAXFlB9IOZI4ouL05g3A03v2eRcTHj2JBQaTNJ40zhAUl5wRbWHqLZ+uqp/7OE0BWWtAVgrong==",
"dependencies": {
"json5": "^2.2.1"
},
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/console-control-strings": { "node_modules/console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
@ -2745,6 +2757,17 @@
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
"dev": true "dev": true
}, },
"node_modules/json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"bin": {
"json5": "lib/cli.js"
},
"engines": {
"node": ">=6"
}
},
"node_modules/just-debounce": { "node_modules/just-debounce": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz", "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz",
@ -7022,6 +7045,14 @@
"typedarray": "^0.0.6" "typedarray": "^0.0.6"
} }
}, },
"config": {
"version": "3.3.8",
"resolved": "https://registry.npmjs.org/config/-/config-3.3.8.tgz",
"integrity": "sha512-rFzF6VESOdp7wAXFlB9IOZI4ouL05g3A03v2eRcTHj2JBQaTNJ40zhAUl5wRbWHqLZ+uqp/7OE0BWWtAVgrong==",
"requires": {
"json5": "^2.2.1"
}
},
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
@ -8389,6 +8420,11 @@
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
"dev": true "dev": true
}, },
"json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA=="
},
"just-debounce": { "just-debounce": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz", "resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.1.0.tgz",

View File

@ -24,6 +24,7 @@
"sass": "^1.55.0" "sass": "^1.55.0"
}, },
"dependencies": { "dependencies": {
"config": "^3.3.8",
"express": "^4.18.2", "express": "^4.18.2",
"sequelize": "^6.25.3", "sequelize": "^6.25.3",
"sqlite3": "^5.1.2", "sqlite3": "^5.1.2",

View File

@ -1,5 +1,10 @@
const dbConfig = require('config').get('database');
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const sequelize = new Sequelize('sqlite::memory:');
const sequelize = new Sequelize({
dialect: dbConfig.get('driver'),
storage: dbConfig.get('connection_string')
});
const db = {}; const db = {};