Version 0.1.2 - Ajout du systême d'authentification
This commit is contained in:
37
bin/config.js
Normal file
37
bin/config.js
Normal file
@ -0,0 +1,37 @@
|
||||
const { LogType } = require("loguix")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
const { __glob } = require("./global-variables")
|
||||
const clog = new LogType("Configuration")
|
||||
|
||||
setup()
|
||||
|
||||
function setup() {
|
||||
if(!fs.existsSync(__glob.CONFIG)) {
|
||||
clog.log("Création du fichier de configuration dans : " + __glob.CONFIG)
|
||||
fs.writeFileSync(__glob.CONFIG, JSON.stringify({
|
||||
ENCRYPTION_KEY: "1",
|
||||
}, null, 2))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns Config File
|
||||
*/
|
||||
module.exports.getFile = function () {
|
||||
const file = JSON.parse(fs.readFileSync(__glob.CONFIG))
|
||||
return file
|
||||
}
|
||||
|
||||
/**
|
||||
* Update le fichier configuration avec un object
|
||||
* @param {Array} file
|
||||
*/
|
||||
module.exports.updateFile = function (file) {
|
||||
if(fs.existsSync(__glob.CONFIG)) {
|
||||
clog.log("Mise à jour du fichier configuration dans : " + __glob.CONFIG)
|
||||
fs.writeFileSync(__glob.CONFIG, JSON.stringify(file, null, 2))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user