diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/index.js b/src/index.js index a7dff9b..31ae590 100644 --- a/src/index.js +++ b/src/index.js @@ -4,10 +4,8 @@ const fs = require('fs'); const path = require('path'); const jwt = require('jsonwebtoken'); -const config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'))); - -const dbCreds = config.database; -const secret = config.jwt_secret; +const { env } = require('node:process'); +const secret = env.JWT_SECRET const jwtFunctions = { sign: function(message) { @@ -18,7 +16,7 @@ const jwtFunctions = { } } -const database = new Sequelize(dbCreds.database, dbCreds.user, dbCreds.password, { +const database = new Sequelize(env.DATABASE, env.DATABASE_USER, env.DATABASE_PASS, { logging(str) { console.debug(`DB:${str}`); }, @@ -26,7 +24,7 @@ const database = new Sequelize(dbCreds.database, dbCreds.user, dbCreds.password, charset: 'utf8mb4', multipleStatements: true, }, -// host: dbCreds.host, + host: env.DATABASE_HOST, dialect: 'mysql', pool: { max: 5, @@ -36,7 +34,7 @@ const database = new Sequelize(dbCreds.database, dbCreds.user, dbCreds.password, }); database.authenticate().then(() => { - console.debug(`database connection successful: ${dbCreds.database}`); + console.debug(`database connection successful: ${env.DATABASE}`); }, (e) => console.log(e)); async function sync(alter, force, callback) { @@ -114,5 +112,5 @@ const models = setUpModels(); const templates = require('./templates'); sync(); server.setUpRoutes(models, jwtFunctions, database, templates.setUpTemplates()); -server.listen(config.port); +server.listen(8080); |