Skip to content

Commit

Permalink
Merge pull request #21 from supergoodsystems/add-remote-config-fetching
Browse files Browse the repository at this point in the history
Add remote config fetching
  • Loading branch information
aklarfeld authored Dec 19, 2023
2 parents b2e8e05 + d58b979 commit 20753c6
Show file tree
Hide file tree
Showing 19 changed files with 1,914 additions and 208 deletions.
675 changes: 675 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ module.exports = {
node: true,
'jest/globals': true
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'prettier'],
overrides: [],
parserOptions: {
ecmaVersion: 'latest'
ecmaVersion: 'latest',
sourceType: 'module',
allowImportExportEverywhere: true
},
plugins: ['react', 'prettier', 'jest', '@typescript-eslint'],
plugins: ['prettier', 'jest'],
rules: {
// 'indent': ['error', 2],
// 'quotes': ['error', 'single'],
Expand All @@ -28,5 +23,11 @@ module.exports = {
// 'no-multi-spaces': ['error'],
// 'max-len': ['error', 80],
'prettier/prettier': 2
// 'react/jsx-max-props-per-line': [
// 1,
// {
// maximum: 1
// }
// ]
}
};
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"configurations": [
{
"command": "yarn worker:data",
"name": "Run Data Worker",
"request": "launch",
"type": "node-terminal"
},
{
"command": "yarn worker:cron",
"name": "Run Cron Worker",
"request": "launch",
"type": "node-terminal"
},
{
"command": "yarn server",
"name": "Run Server",
"request": "launch",
"type": "node-terminal"
},
]
}
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"typescript",
"javascript"
],
"editor.tabSize": 2
"editor.tabSize": 2,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@types/lodash.set": "^4.3.7",
"@types/signal-exit": "^3.0.1",
"@types/superagent": "^4.1.16",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"axios": "^1.4.0",
"dotenv": "^16.0.3",
Expand Down
10 changes: 7 additions & 3 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HeaderOptionType, EventRequestType, ErrorPayloadType } from './types';
import { post } from './utils';
import { post, get } from './utils';

const postError = async (
errorSinkUrl: string,
Expand Down Expand Up @@ -29,8 +29,12 @@ const postEvents = async (
data,
options.headers.Authorization
);

return response;
};

export { postError, postEvents };
const fetchRemoteConfig = async (configUrl: string, options: HeaderOptionType) => {
const response = await get(configUrl, options.headers.Authorization);
return JSON.parse(response);
}

export { postError, postEvents, fetchRemoteConfig };
5 changes: 3 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const defaultConfig = {
flushInterval: 1000,
remoteConfigFetchInterval: 10000,
eventSinkEndpoint: '/events',
errorSinkEndpoint: '/errors',
remoteConfigFetchEndpoint: '/config',
allowLocalUrls: false,
keysToHash: [],
ignoredDomains: [],

// After the close command is sent, wait for this many milliseconds before
// exiting. This gives any hanging responses a chance to return.
waitAfterClose: 1000
waitAfterClose: 1000,
};

const errors = {
Expand Down
Loading

0 comments on commit 20753c6

Please sign in to comment.