-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed fetch default implementation (#184)
- Loading branch information
Showing
11 changed files
with
87 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Staging CI | ||
run-name: Staging - Node ${{ github.event.inputs.node }} / ${{ github.event.inputs.os }} by @${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
node: | ||
description: 'Node version' | ||
required: true | ||
default: '20.x' | ||
os: | ||
description: 'Operating System (ubuntu-20.04, ubuntu-latest, windows-latest)' | ||
required: true | ||
default: 'ubuntu-latest' | ||
|
||
jobs: | ||
test: | ||
name: Test - Node ${{ github.event.inputs.node }} on ${{ github.event.inputs.os }} | ||
runs-on: ${{ github.event.inputs.os }} | ||
|
||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ github.event.inputs.node }} | ||
|
||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
import https from 'node:https'; | ||
import http from 'node:http'; | ||
|
||
export default class FetchFacade { | ||
static async fetch(url, init) { | ||
return fetch(url, init); | ||
return new Promise((resolve, reject) => { | ||
const lib = url.startsWith('https') ? https : http; | ||
const request = lib.request(url, init, (response) => { | ||
let body = ''; | ||
response.on('data', (chunk) => body += chunk); | ||
response.on('end', () => FetchFacade.#handleResponse(response, body, resolve)); | ||
}); | ||
request.on('error', reject); | ||
if (init.body) { | ||
request.write(init.body); | ||
} | ||
request.end(); | ||
}); | ||
} | ||
|
||
static #handleResponse(response, body, resolve) { | ||
resolve({ status: response.statusCode, json: () => JSON.parse(body) }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { assert } from 'chai'; | ||
|
||
import { Switcher } from '../switcher-client.js'; | ||
|
||
describe('Switcher integrated test', () => { | ||
|
||
it('should hit remote API and return Switcher response', async function () { | ||
this.timeout(3000); | ||
|
||
// given context build | ||
Switcher.buildContext({ | ||
url: 'https://api.switcherapi.com', | ||
apiKey: 'JDJiJDA4JEFweTZjSTR2bE9pUjNJOUYvRy9raC4vRS80Q2tzUnk1d3o1aXFmS2o5eWJmVW11cjR0ODNT', | ||
domain: 'Playground', | ||
component: 'switcher-playground' | ||
}); | ||
|
||
// test | ||
const switcher = Switcher.factory().detail(); | ||
const result = await switcher.isItOn('CLIENT_JS_FEATURE_1'); | ||
|
||
assert.isNotNull(result); | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.