Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(2151): helm-release-v12.1.0 #106

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
const config = {
"extends": "airbnb-base",
"env": {
"node": true
},
"rules": {
indent: [
"error",
4,
{ "SwitchCase": 1 }
],
"spaced-comment": [
"error",
"always",
{
"exceptions": ["*"]
}
],
'max-len': [
'error',
100,
2,
{
ignoreUrls: true,
ignoreComments: true,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}
],
strict: [
"off",
],
'lines-around-directive': [
'error',
{
before: 'never',
after: 'always',
}
],
}
}
extends: 'airbnb-base',
env: {
node: true,
},
rules: {
indent: [
'error',
4,
{ SwitchCase: 1 },
],
'spaced-comment': [
'error',
'always',
{
exceptions: ['*'],
},
],
'max-len': [
'error',
100,
2,
{
ignoreUrls: true,
ignoreComments: true,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
strict: [
'off',
],
'lines-around-directive': [
'error',
{
before: 'never',
after: 'always',
},
],
},
};

module.exports = config
module.exports = config;
4 changes: 0 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async function readFile(...args) {
return p;
}


// TODO: implement toString, toJSON toAnythingElse methods on config so that secrets can't be
// printed
const config = {
Expand All @@ -60,7 +59,6 @@ const config = {
parties: [],
};


const setConfig = async (cfg) => {
config.tls.mutualTLS.enabled = cfg.MUTUAL_TLS_ENABLED.toLowerCase() !== 'false';
config.tls.enabled = cfg.HTTPS_ENABLED !== 'false';
Expand All @@ -82,10 +80,8 @@ const setConfig = async (cfg) => {
config.parties = cfg.PARTIES ? JSON.parse(cfg.PARTIES) : config.parties;
};


const getConfig = () => config;


module.exports = {
getConfig,
setConfig,
Expand Down
12 changes: 1 addition & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ const simHandlers = require('./simulator/handlers');
const reportHandlers = require('./reports/handlers');
const testApiHandlers = require('./test-api/handlers');

const { setConfig, getConfig } = require('./config.js');
const { setConfig, getConfig } = require('./config');
const Model = require('./models/model');


const simApiSpec = yaml.load('./simulator/api.yaml');
const reportApiSpec = yaml.load('./reports/api.yaml');
const testApiSpec = yaml.load('./test-api/api.yaml');
Expand All @@ -76,7 +75,6 @@ const testApi = new Koa();
const reportLogger = new Logger({ context: { app: 'report' }, space, transports });
const testApiLogger = new Logger({ context: { app: 'test-api' }, space, transports });


const rulesEngine = new RulesEngine({ logger: simLogger });
rulesEngine.loadRules(rules);

Expand Down Expand Up @@ -116,7 +114,6 @@ const testApi = new Koa();
ctx.state.logger.push({ response: { body, status } }).log('Request processed');
});


report.use(async (ctx, next) => {
ctx.state.logger = reportLogger.push({
request: {
Expand All @@ -132,7 +129,6 @@ const testApi = new Koa();
ctx.state.logger.push({ response: { body, status } }).log('Request processed');
});


testApi.use(async (ctx, next) => {
ctx.state.logger = testApiLogger.push({
request: {
Expand All @@ -148,15 +144,12 @@ const testApi = new Koa();
ctx.state.logger.push({ response: { body, status } }).log('Request processed');
});


testApi.use(cors());


simulator.use(koaBody());
report.use(koaBody());
testApi.use(koaBody());


// Add validation and data model for each request
const simValidator = new Validate();

Expand Down Expand Up @@ -214,7 +207,6 @@ const testApi = new Koa();
}
});


// Add rule engine evaluation for each simulator request
simulator.use(async (ctx, next) => {
const facts = {
Expand Down Expand Up @@ -275,7 +267,6 @@ const testApi = new Koa();
await next();
});


// Handle requests
simulator.use(router(simHandlers.map));
report.use(router(reportHandlers.map));
Expand All @@ -287,7 +278,6 @@ const testApi = new Koa();
testApiValidator.initialise(testApiSpec),
]);


// If config specifies TLS, start an HTTPS server; otherwise HTTP
let simServer;
const simulatorPort = conf.ports.simulatorApi;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/log/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"author": "Matt Kingston, ModusBox Inc",
"license": "Apache-2.0",
"dependencies": {
"sqlite": "3.0.1"
"sqlite": "4.0.23",
"sqlite3": "5.0.2"
}
}
6 changes: 5 additions & 1 deletion src/lib/log/transports.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const fs = require('fs');
// TODO: consider: https://github.com/JoshuaWise/better-sqlite3
// TODO: consider moving this require into the sqliteTransport function
const sqlite = require('sqlite');
const sqlite3 = require('sqlite3');

const nullTransport = () => {};

Expand Down Expand Up @@ -59,7 +60,10 @@ const file = (path) => {

const sqliteTransport = async (path) => {
// TODO: enable db object cache? https://github.com/mapbox/node-sqlite3/wiki/Caching
const db = await sqlite.open(path);
const db = await sqlite.open({
filename: path,
driver: sqlite3.Database,
});
await db.run('CREATE TABLE IF NOT EXISTS log(timestamp TEXT, entry TEXT)');
await db.run('CREATE INDEX IF NOT EXISTS log_timestamp_index ON log(timestamp)');
// TODO: when the filesystem fills up?
Expand Down
9 changes: 4 additions & 5 deletions src/lib/rules-engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const util = require('util');
const { Engine } = require('json-rules-engine');
const { getStackOrInspect } = require('@internal/log');


class RulesEngine {
constructor(config) {
this.config = config;
Expand All @@ -44,7 +43,6 @@ class RulesEngine {
this.engine.addOperator('numberStringGreaterThanInclusive', (a, b) => Number(a) >= b);
}


/**
* Loads an array of rules into the engine
*
Expand Down Expand Up @@ -73,8 +71,10 @@ class RulesEngine {
this.logger.log(`Rule engine evaluating facts: ${util.inspect(facts)}`);
this.engine
.run(facts)
.then((events) => {
this.logger.log(`Rule engine returning events: ${util.inspect(events)}`);
.then((engineResult) => {
const { events } = engineResult;

this.logger.log(`Rule engine returning events: ${util.inspect(engineResult)}`);
// Events is always longer than 0 for istanbul
/* istanbul ignore next */
return resolve(events.length === 0 ? null : events.map((e) => e.params));
Expand All @@ -83,5 +83,4 @@ class RulesEngine {
}
}


module.exports = RulesEngine;
2 changes: 1 addition & 1 deletion src/lib/rules-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"license": "Apache-2.0",
"dependencies": {
"@internal/log": "file:../log",
"json-rules-engine": "2.3.6"
"json-rules-engine": "6.1.2"
}
}
2 changes: 1 addition & 1 deletion src/lib/validate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Ajv = require('ajv');

// Don't stop at the first error, we'll let the user know what all their errors are. Also, when we
// validate, coerce types to those we're interested in where possible.
const ajv = new Ajv({ allErrors: true, coerceTypes: true });
const ajv = new Ajv({ allErrors: true, coerceTypes: true, strict: false });

const httpMethods = ['get', 'head', 'post', 'put', 'delete', 'connnect', 'options', 'trace', 'patch'];

Expand Down
8 changes: 4 additions & 4 deletions src/lib/validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Matt Kingston, ModusBox Inc.",
"license": "Apache-2.0",
"devDependencies": {
"eslint": "5.12.0"
"eslint": "7.28.0"
},
"dependencies": {
"ajv": "6.7.0",
"json-schema-ref-parser": "6.0.3",
"openapi-jsonschema-parameters": "1.1.0"
"ajv": "8.6.0",
"json-schema-ref-parser": "9.0.7",
"openapi-jsonschema-parameters": "9.0.3"
}
}
1 change: 0 additions & 1 deletion src/models/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ const ApiErrorCodes = {
VALIDATION_ERROR: { statusCode: '7003', message: 'Request was malformed' },
};


module.exports = { ApiErrorCodes };
7 changes: 6 additions & 1 deletion src/models/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
*/

const sqlite = require('sqlite');
const sqlite3 = require('sqlite3');

const Party = require('./party');
const Quote = require('./quote');
const BulkQuote = require('./bulkQuote');
Expand Down Expand Up @@ -90,7 +92,10 @@ module.exports = class Model {
throw new Error('Attempted to initialise database twice');
}

this.db = await sqlite.open(databaseFilepath);
this.db = await sqlite.open({
filename: databaseFilepath,
driver: sqlite3.Database,
});
await this.db.run('PRAGMA foreign_keys = true');
await this.db.run(createPartyTable);
await this.db.run(createPartyTableUniqueIndex);
Expand Down
2 changes: 0 additions & 2 deletions src/models/party.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

const { partyTable, partyExtensionTable } = require('./constants');


/**
* @typedef {Object} Party
*
Expand Down Expand Up @@ -157,7 +156,6 @@ module.exports = class Party {
}
}


/**
* Updates a party
*
Expand Down
Loading