switched to f** ESS modules
This commit is contained in:
+9
-8
@@ -1,9 +1,8 @@
|
||||
const Ajv = require("ajv")
|
||||
const confSchema = require('./configSchema.json')
|
||||
import Ajv from 'ajv'
|
||||
import confSchema from './configSchema.json' with { type: 'json' }
|
||||
import { pathToFileURL } from 'url'
|
||||
|
||||
let DynamoDBClient, GetItemCommand, marshall, unmarshall
|
||||
|
||||
module.exports = class configHelper {
|
||||
export class configHelper {
|
||||
|
||||
constructor(options){
|
||||
this.config = {}
|
||||
@@ -24,7 +23,10 @@ module.exports = class configHelper {
|
||||
|
||||
async fetchConfigFile(){
|
||||
let curConfig = this.config
|
||||
this.config = await require(this.localfile)
|
||||
const url = pathToFileURL(this.localfile).href
|
||||
this.config = await import(url, {
|
||||
with: { type: 'json' }
|
||||
}).then(m => m.default)
|
||||
if(this.isValidConfig(this.config)) return(this.config)
|
||||
console.error(this.isValidConfig.errors)
|
||||
//revert if invalid conf
|
||||
@@ -37,9 +39,8 @@ module.exports = class configHelper {
|
||||
}
|
||||
|
||||
async refreshAccessRightsFile(){
|
||||
delete require.cache[require.resolve(this.localfile)]
|
||||
let tmp
|
||||
try { tmp = require(this.localfile) }
|
||||
try { tmp = import(`${this.localfile}?update=${Date.now()}`, { assert: { type: 'json' } }) }
|
||||
catch(err) {
|
||||
console.error('Error Reloading config !! (bad json?) => Keeping current accessRights !')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user