diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c43590 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.well-known +wssGatewayConfig.json +nodeserver.cert +nodeserver.key +package-lock.json +/brol +/node_modules +*.log diff --git a/configHelper.js b/configHelper.js index a993140..237bb06 100644 --- a/configHelper.js +++ b/configHelper.js @@ -7,22 +7,9 @@ module.exports = class configHelper { constructor(options){ this.config = {} - if(options.onAws) { - DynamoDBClient = require("@aws-sdk/client-dynamodb").DynamoDBClient - GetItemCommand = require("@aws-sdk/client-dynamodb").GetItemCommand - marshall = require("@aws-sdk/util-dynamodb").marshall - unmarshall = require("@aws-sdk/util-dynamodb").unmarshall - this. dynamoClient = new DynamoDBClient({ region: options.awsRegion }) - - this.awsTable = options.awsTable - this.awsServiceName = options.awsServiceName - this.fetchConfig = this.fetchConfigDynamo - this.refreshAccessRights = this.refreshAccessRightsDynamo - } else { - this.localfile = options.localfile - this.fetchConfig = this.fetchConfigFile - this.refreshAccessRights = this.refreshAccessRightsFile - } + this.localfile = options.localfile + this.fetchConfig = this.fetchConfigFile + this.refreshAccessRights = this.refreshAccessRightsFile const ajv = new Ajv({ allowUnionTypes: true }) @@ -35,37 +22,6 @@ module.exports = class configHelper { return(false) } - async dynamoGet(subKey = null){ - let params = new GetItemCommand({ - TableName: this.awsTable, - Key: { - serviceName: marshall(this.awsServiceName), - }, - }) - - let result = await this.dynamoClient.send(params) - let obj = unmarshall(result.Item) - if((typeof(subKey)=='string') && (subKey in obj)) return(obj[subKey]) - return(obj) - } - - async fetchConfigDynamo(){ - let curConfig = this.config - this.config = await this.dynamoGet() - - if(process.env.UNSECURE) this.config.server.unsecure = Boolean(process.env.UNSECURE); - if(process.env.REDIS_HOST) this.config.redis.host = process.env.REDIS_HOST; - if(process.env.REDIS_TLS) this.config.redis.tls = Boolean(process.env.REDIS_TLS); - if(process.env.REDIS_PORT) this.config.redis.port = Number(process.env.REDIS_PORT); - if(process.env.REDIS_USER) this.config.redis.user = process.env.REDIS_USER; - if(process.env.REDIS_PASSWORD) this.config.redis.pass = process.env.REDIS_PASSWORD; - - if(this.isValidConfig(this.config)) return(this.config) - console.error(this.isValidConfig.errors) - //revert if invalid conf - this.config = curConfig - } - async fetchConfigFile(){ let curConfig = this.config this.config = await require(this.localfile) diff --git a/package.json b/package.json index 4dd59c8..a9afaf5 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,10 @@ "dependencies": { "ajv": "^8.12.0", "cookie-parser": "^1.4.6", - "pm2": "^5.2.0", + "pm2": "^6.0.10", "redis": "^4.3.0", "urldecode": "^1.0.1", "ws": "^8.8.1", "yargs": "^17.5.1" - }, - "devDependencies": { - "jest": "^29.7.0" } } diff --git a/wssGateway.js b/wssGateway.js index d09b6e6..37615ce 100644 --- a/wssGateway.js +++ b/wssGateway.js @@ -20,10 +20,6 @@ const debug = Boolean(process.env.DEBUG) || argv.debug const cfgh = new configHelper({ localfile: './wssGatewayConfig.json', - onAws: typeof(process.env.AWS_EXECUTION_ENV)=='string', - awsRegion: 'eu-west-1', - awsTable: 'bus-config', - awsServiceName: 'wssGateway', }) async function startRedis(wssGatewayConfig) {