Skip to content

Commit

Permalink
cli option for config file
Browse files Browse the repository at this point in the history
  • Loading branch information
recap committed Jun 12, 2024
1 parent c880b77 commit f8fe047
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const User = require("./user.js")
const Agreement = require("./agreement.js")
// const classLoader = require('./class_loader.js')
const ClassLoader = require("./class_loader.js")
const config = require("./config.json")
// const config = require("./config.json")
const { userInfo } = require("os")
const UserDb = require("./UserDb.js")

Expand All @@ -30,12 +30,14 @@ const secretKey = process.env.SECRET_KEY
const keyWordArray = CryptoJS.enc.Base64.parse(apiKey)

program
.option("-p, --port <int>", "server listen port")
.option("--reset-db", "reset users database")
.option("--db-file <type>", "user database file to use")
.option("-p, --port <int>", "server listen port.")
.option("-c, --config <type>", "config file path.")
.option("--reset-db", "reset users database.")
.option("--db-file <type>", "user database file to use.")

program.parse(process.argv)
const options = program.opts()
const config = (options.config) ? require(options.config) : require("./config.json")

const port = options.port || "8060"
const userDbFile = options.dbFile || "./data/userdb.json"
Expand Down

0 comments on commit f8fe047

Please sign in to comment.