switched to f** ESS modules

This commit is contained in:
STEINNI
2025-09-14 21:06:13 +00:00
parent f4ac7df4a7
commit b4cd02add5
16 changed files with 63 additions and 49 deletions
+9 -8
View File
@@ -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