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

chore: renamed remote reference #170

Merged
merged 1 commit into from
Apr 14, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -33,8 +33,8 @@
"node-fetch": "^3.3.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"babel-eslint": "^10.1.0",
"c8": "^9.1.0",
"chai": "^5.1.0",
Expand Down
14 changes: 7 additions & 7 deletions src/index.js
Expand Up @@ -5,7 +5,7 @@ import DateMoment from './lib/utils/datemoment.js';
import SnapshotAutoUpdater from './lib/utils/snapshotAutoUpdater.js';
import { loadDomain, validateSnapshot, checkSwitchersLocal } from './lib/snapshot.js';
import { SnapshotNotFoundError } from './lib/exceptions/index.js';
import * as services from './lib/remote.js';
import * as remote from './lib/remote.js';
import checkCriteriaLocal from './lib/resolver.js';
import { writeFileSync, watchFile, unwatchFile } from 'fs';
import {
Expand Down Expand Up @@ -52,7 +52,7 @@ export class Switcher {

static _buildOptions(options) {
if (SWITCHER_OPTIONS.CERT_PATH in options && options.certPath) {
services.setCerts(options.certPath);
remote.setCerts(options.certPath);
}

if (SWITCHER_OPTIONS.SILENT_MODE in options && options.silentMode) {
Expand Down Expand Up @@ -166,7 +166,7 @@ export class Switcher {
static async _checkSwitchersRemote(switcherKeys) {
try {
await Switcher._auth();
await services.checkSwitchersRemote(Switcher.context.url, Switcher.context.token, switcherKeys);
await remote.checkSwitchers(Switcher.context.url, Switcher.context.token, switcherKeys);
} catch (e) {
if (Switcher.options.silentMode) {
checkSwitchersLocal(Switcher.snapshot, switcherKeys);
Expand Down Expand Up @@ -200,7 +200,7 @@ export class Switcher {
}

static async _auth() {
const response = await services.auth(Switcher.context);
const response = await remote.auth(Switcher.context);
Switcher.context.token = response.token;
Switcher.context.exp = response.exp;
}
Expand All @@ -212,7 +212,7 @@ export class Switcher {

if (Switcher._isTokenExpired()) {
Switcher._updateSilentToken();
services.checkAPIHealth(Switcher.context.url || '').then((isAlive) => {
remote.checkAPIHealth(Switcher.context.url || '').then((isAlive) => {
if (isAlive) {
Switcher._auth();
}
Expand Down Expand Up @@ -358,7 +358,7 @@ export class Switcher {
let responseCriteria;

if (this._useSync()) {
responseCriteria = await services.checkCriteria(
responseCriteria = await remote.checkCriteria(
Switcher.context, this._key, this._input, this._showDetail);

if (Switcher.options.logger) {
Expand All @@ -374,7 +374,7 @@ export class Switcher {
_executeAsyncRemoteCriteria(showDetail) {
if (this._nextRun < Date.now()) {
this._nextRun = Date.now() + this._delay;
services.checkCriteria(Switcher.context, this._key, this._input, showDetail)
remote.checkCriteria(Switcher.context, this._key, this._input, showDetail)
.then(response => ExecutionLogger.add(response, this._key, this._input));
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/remote.js
Expand Up @@ -99,7 +99,7 @@ export async function auth({ url, apiKey, domain, component, environment }) {
}
}

export async function checkSwitchersRemote(url, token, switcherKeys) {
export async function checkSwitchers(url, token, switcherKeys) {
try {
const response = await FetchFacade.fetch(`${url}/criteria/switchers_check`, {
method: 'post',
Expand Down