@chainlink/external-adapter-framework 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/adapter.js +128 -0
  2. package/background-executor.js +45 -0
  3. package/cache/factory.js +58 -0
  4. package/cache/index.js +173 -0
  5. package/cache/local.js +83 -0
  6. package/cache/metrics.js +120 -0
  7. package/cache/redis.js +100 -0
  8. package/chainlink-external-adapter-framework-v0.0.6.tgz +0 -0
  9. package/config/index.js +366 -0
  10. package/config/provider-limits.js +74 -0
  11. package/examples/bank-frick/accounts.js +192 -0
  12. package/examples/bank-frick/config/index.js +54 -0
  13. package/examples/bank-frick/index.js +15 -0
  14. package/examples/bank-frick/util.js +39 -0
  15. package/examples/coingecko/src/config/index.js +13 -0
  16. package/examples/coingecko/src/config/overrides.json +10826 -0
  17. package/examples/coingecko/src/cryptoUtils.js +41 -0
  18. package/examples/coingecko/src/endpoint/coins.js +33 -0
  19. package/examples/coingecko/src/endpoint/crypto-marketcap.js +46 -0
  20. package/examples/coingecko/src/endpoint/crypto-volume.js +46 -0
  21. package/examples/coingecko/src/endpoint/crypto.js +47 -0
  22. package/examples/coingecko/src/endpoint/dominance.js +26 -0
  23. package/examples/coingecko/src/endpoint/global-marketcap.js +26 -0
  24. package/examples/coingecko/src/endpoint/index.js +15 -0
  25. package/examples/coingecko/src/globalUtils.js +48 -0
  26. package/examples/coingecko/src/index.js +14 -0
  27. package/examples/coingecko/test/e2e/adapter.test.js +262 -0
  28. package/examples/coingecko/test/integration/adapter.test.js +264 -0
  29. package/examples/coingecko/test/integration/capturedRequests.json +1 -0
  30. package/examples/coingecko/test/integration/fixtures.js +41 -0
  31. package/examples/coingecko-old/batch-warming.js +53 -0
  32. package/examples/coingecko-old/index.js +11 -0
  33. package/examples/coingecko-old/rest.js +51 -0
  34. package/examples/ncfx/config/index.js +15 -0
  35. package/examples/ncfx/index.js +11 -0
  36. package/examples/ncfx/websocket.js +73 -0
  37. package/index.js +127 -0
  38. package/metrics/constants.js +25 -0
  39. package/metrics/index.js +122 -0
  40. package/metrics/util.js +9 -0
  41. package/package.json +5 -15
  42. package/rate-limiting/background/fixed-frequency.js +35 -0
  43. package/rate-limiting/index.js +84 -0
  44. package/rate-limiting/metrics.js +44 -0
  45. package/rate-limiting/request/simple-counting.js +62 -0
  46. package/test.js +6 -0
  47. package/transports/batch-warming.js +101 -0
  48. package/transports/index.js +87 -0
  49. package/transports/metrics.js +105 -0
  50. package/transports/rest.js +138 -0
  51. package/transports/util.js +86 -0
  52. package/transports/websocket.js +166 -0
  53. package/util/index.js +35 -0
  54. package/util/logger.js +62 -0
  55. package/util/recordRequests.js +45 -0
  56. package/util/request.js +2 -0
  57. package/util/subscription-set/expiring-sorted-set.js +47 -0
  58. package/util/subscription-set/subscription-set.js +19 -0
  59. package/util/test-payload-loader.js +83 -0
  60. package/validation/error.js +79 -0
  61. package/validation/index.js +91 -0
  62. package/validation/input-params.js +30 -0
  63. package/validation/override-functions.js +40 -0
  64. package/validation/overrideFunctions.js +40 -0
  65. package/validation/preset-tokens.json +23 -0
  66. package/validation/validator.js +303 -0
  67. package/.c8rc.json +0 -3
  68. package/.eslintignore +0 -10
  69. package/.eslintrc.js +0 -96
  70. package/.github/README.MD +0 -42
  71. package/.github/actions/setup/action.yaml +0 -13
  72. package/.github/workflows/label.yaml +0 -39
  73. package/.github/workflows/main.yaml +0 -39
  74. package/.github/workflows/publish.yaml +0 -17
  75. package/.prettierignore +0 -13
  76. package/.yarnrc +0 -0
  77. package/README.md +0 -103
  78. package/dist/examples/coingecko/test/e2e/adapter.test.ts.js +0 -82953
  79. package/dist/examples/coingecko/test/integration/adapter.test.ts.js +0 -91672
  80. package/dist/main.js +0 -72703
  81. package/docker-compose.yaml +0 -35
  82. package/env.sh +0 -54
  83. package/env2.sh +0 -55
  84. package/jest.config.js +0 -5
  85. package/publish.sh +0 -0
  86. package/src/adapter.ts +0 -263
  87. package/src/background-executor.ts +0 -52
  88. package/src/cache/factory.ts +0 -26
  89. package/src/cache/index.ts +0 -258
  90. package/src/cache/local.ts +0 -73
  91. package/src/cache/metrics.ts +0 -112
  92. package/src/cache/redis.ts +0 -93
  93. package/src/config/index.ts +0 -517
  94. package/src/config/provider-limits.ts +0 -127
  95. package/src/examples/bank-frick/README.MD +0 -10
  96. package/src/examples/bank-frick/accounts.ts +0 -246
  97. package/src/examples/bank-frick/config/index.ts +0 -53
  98. package/src/examples/bank-frick/index.ts +0 -13
  99. package/src/examples/bank-frick/types.d.ts +0 -38
  100. package/src/examples/bank-frick/util.ts +0 -55
  101. package/src/examples/coingecko/src/config/index.ts +0 -12
  102. package/src/examples/coingecko/src/config/overrides.json +0 -10826
  103. package/src/examples/coingecko/src/cryptoUtils.ts +0 -88
  104. package/src/examples/coingecko/src/endpoint/coins.ts +0 -54
  105. package/src/examples/coingecko/src/endpoint/crypto-marketcap.ts +0 -66
  106. package/src/examples/coingecko/src/endpoint/crypto-volume.ts +0 -66
  107. package/src/examples/coingecko/src/endpoint/crypto.ts +0 -63
  108. package/src/examples/coingecko/src/endpoint/dominance.ts +0 -40
  109. package/src/examples/coingecko/src/endpoint/global-marketcap.ts +0 -40
  110. package/src/examples/coingecko/src/endpoint/index.ts +0 -6
  111. package/src/examples/coingecko/src/globalUtils.ts +0 -78
  112. package/src/examples/coingecko/src/index.ts +0 -17
  113. package/src/examples/coingecko/test/e2e/adapter.test.ts +0 -278
  114. package/src/examples/coingecko/test/integration/__snapshots__/adapter.test.ts.snap +0 -15
  115. package/src/examples/coingecko/test/integration/adapter.test.ts +0 -281
  116. package/src/examples/coingecko/test/integration/capturedRequests.json +0 -1
  117. package/src/examples/coingecko/test/integration/fixtures.ts +0 -42
  118. package/src/examples/coingecko-old/batch-warming.ts +0 -79
  119. package/src/examples/coingecko-old/index.ts +0 -9
  120. package/src/examples/coingecko-old/rest.ts +0 -77
  121. package/src/examples/ncfx/config/index.ts +0 -12
  122. package/src/examples/ncfx/index.ts +0 -9
  123. package/src/examples/ncfx/websocket.ts +0 -99
  124. package/src/index.ts +0 -149
  125. package/src/metrics/constants.ts +0 -23
  126. package/src/metrics/index.ts +0 -115
  127. package/src/metrics/util.ts +0 -18
  128. package/src/rate-limiting/background/fixed-frequency.ts +0 -45
  129. package/src/rate-limiting/index.ts +0 -100
  130. package/src/rate-limiting/metrics.ts +0 -18
  131. package/src/rate-limiting/request/simple-counting.ts +0 -76
  132. package/src/transports/batch-warming.ts +0 -127
  133. package/src/transports/index.ts +0 -152
  134. package/src/transports/metrics.ts +0 -95
  135. package/src/transports/rest.ts +0 -168
  136. package/src/transports/util.ts +0 -63
  137. package/src/transports/websocket.ts +0 -245
  138. package/src/util/index.ts +0 -23
  139. package/src/util/logger.ts +0 -69
  140. package/src/util/recordRequests.ts +0 -47
  141. package/src/util/request.ts +0 -117
  142. package/src/util/subscription-set/expiring-sorted-set.ts +0 -54
  143. package/src/util/subscription-set/subscription-set.ts +0 -35
  144. package/src/util/test-payload-loader.ts +0 -87
  145. package/src/validation/error.ts +0 -116
  146. package/src/validation/index.ts +0 -110
  147. package/src/validation/input-params.ts +0 -45
  148. package/src/validation/override-functions.ts +0 -44
  149. package/src/validation/overrideFunctions.ts +0 -44
  150. package/src/validation/preset-tokens.json +0 -23
  151. package/src/validation/validator.ts +0 -384
  152. package/test/adapter.test.ts +0 -27
  153. package/test/background-executor.test.ts +0 -108
  154. package/test/cache/cache-key.test.ts +0 -114
  155. package/test/cache/helper.ts +0 -100
  156. package/test/cache/local.test.ts +0 -54
  157. package/test/cache/redis.test.ts +0 -89
  158. package/test/correlation.test.ts +0 -114
  159. package/test/index.test.ts +0 -37
  160. package/test/metrics/feed-id.test.ts +0 -38
  161. package/test/metrics/helper.ts +0 -14
  162. package/test/metrics/labels.test.ts +0 -36
  163. package/test/metrics/metrics.test.ts +0 -267
  164. package/test/metrics/redis-metrics.test.ts +0 -113
  165. package/test/metrics/warmer-metrics.test.ts +0 -193
  166. package/test/metrics/ws-metrics.test.ts +0 -225
  167. package/test/rate-limit-config.test.ts +0 -242
  168. package/test/smoke/smoke.test.ts +0 -166
  169. package/test/smoke/test-payload-fail.json +0 -3
  170. package/test/smoke/test-payload.js +0 -22
  171. package/test/smoke/test-payload.json +0 -7
  172. package/test/transports/batch.test.ts +0 -466
  173. package/test/transports/rest.test.ts +0 -242
  174. package/test/transports/websocket.test.ts +0 -183
  175. package/test/tsconfig.json +0 -5
  176. package/test/util.ts +0 -77
  177. package/test/validation.test.ts +0 -178
  178. package/test.sh +0 -20
  179. package/test2.sh +0 -2
  180. package/tsconfig.json +0 -28
  181. package/typedoc.json +0 -6
  182. package/webpack.config.js +0 -57
  183. package/yarn-error.log +0 -3778
@@ -1,183 +0,0 @@
1
- import FakeTimers from '@sinonjs/fake-timers'
2
- import test from 'ava'
3
- import axios, { AxiosError } from 'axios'
4
- import { Server, WebSocket } from 'mock-socket'
5
- import { AddressInfo } from 'net'
6
- import { expose } from '../../src'
7
- import { Adapter, AdapterEndpoint } from '../../src/adapter'
8
- import { DEFAULT_SHARED_MS_BETWEEN_REQUESTS } from '../../src/rate-limiting'
9
- import { DEFAULT_WS_TTL, WebSocketClassProvider, WebSocketTransport } from '../../src/transports'
10
- import { ProviderResult } from '../../src/util'
11
- import { InputParameters } from '../../src/validation'
12
- import { MockCache } from '../util'
13
-
14
- interface AdapterRequestParams {
15
- base: string
16
- quote: string
17
- }
18
-
19
- export const inputParameters: InputParameters = {
20
- base: {
21
- type: 'string',
22
- required: true,
23
- },
24
- quote: {
25
- type: 'string',
26
- required: true,
27
- },
28
- }
29
-
30
- interface ProviderMessage {
31
- pair: string
32
- value: number
33
- }
34
-
35
- const URL = 'wss://test-ws.com/asd'
36
-
37
- /**
38
- * Sets the mocked websocket instance in the provided provider class.
39
- * We need this here, because the tests will connect using their instance of WebSocketClassProvider;
40
- * fetching from this library to the \@chainlink/ea-bootstrap package would access _another_ instance
41
- * of the same constructor. Although it should be a singleton, dependencies are different so that
42
- * means that the static classes themselves are also different.
43
- *
44
- * @param provider - singleton WebSocketClassProvider
45
- */
46
- export const mockWebSocketProvider = (provider: typeof WebSocketClassProvider): void => {
47
- // Extend mock WebSocket class to bypass protocol headers error
48
- class MockWebSocket extends WebSocket {
49
- constructor(url: string, protocol: string | string[] | Record<string, string> | undefined) {
50
- super(url, protocol instanceof Object ? undefined : protocol)
51
- }
52
- }
53
-
54
- // Need to disable typing, the mock-socket impl does not implement the ws interface fully
55
- provider.set(MockWebSocket as any) // eslint-disable-line @typescript-eslint/no-explicit-any
56
- }
57
-
58
- export const websocketTransport = new WebSocketTransport({
59
- url: URL,
60
- handlers: {
61
- async open() {
62
- return
63
- },
64
-
65
- message(message: ProviderMessage): ProviderResult<AdapterRequestParams>[] {
66
- const [base, quote] = message.pair.split('/')
67
- return [
68
- {
69
- params: { base, quote },
70
- value: message.value,
71
- },
72
- ]
73
- },
74
- },
75
- builders: {
76
- subscribeMessage: (params: AdapterRequestParams) => ({
77
- request: 'subscribe',
78
- pair: `${params.base}/${params.quote}`,
79
- }),
80
- unsubscribeMessage: (params: AdapterRequestParams) => ({
81
- request: 'unsubscribe',
82
- pair: `${params.base}/${params.quote}`,
83
- }),
84
- },
85
- })
86
-
87
- export const webSocketEndpoint: AdapterEndpoint = {
88
- name: 'test',
89
- transport: websocketTransport,
90
- inputParameters,
91
- }
92
-
93
- const CACHE_MAX_AGE = 1000
94
-
95
- const adapter: Adapter = {
96
- name: 'test',
97
- defaultEndpoint: 'test',
98
- endpoints: [webSocketEndpoint],
99
- envDefaultOverrides: {
100
- CACHE_MAX_AGE,
101
- },
102
- }
103
-
104
- test('connects to websocket, subscribes, gets message, unsubscribes', async (t) => {
105
- const clock = FakeTimers.install()
106
-
107
- // Disable retries to make the testing flow easier
108
- process.env['CACHE_POLLING_MAX_RETRIES'] = '0'
109
-
110
- const base = 'ETH'
111
- const quote = 'DOGE'
112
- const price = 251324
113
-
114
- // Mock WS
115
- mockWebSocketProvider(WebSocketClassProvider)
116
- const mockWsServer = new Server(URL, { mock: false })
117
- mockWsServer.on('connection', (socket) => {
118
- let counter = 0
119
- const parseMessage = () => {
120
- if (counter++ === 0) {
121
- socket.send(
122
- JSON.stringify({
123
- pair: `${base}/${quote}`,
124
- value: price,
125
- }),
126
- )
127
- }
128
- }
129
- socket.on('message', parseMessage)
130
- })
131
-
132
- // Create mocked cache so we can listen when values are set
133
- // This is a more reliable method than expecting precise clock timings
134
- const mockCache = new MockCache()
135
-
136
- // Start up adapter
137
- const server = await expose(adapter, {
138
- cache: mockCache,
139
- })
140
- const address = `http://localhost:${(server?.address() as AddressInfo)?.port}`
141
-
142
- const makeRequest = () =>
143
- axios.post(address, {
144
- data: {
145
- base,
146
- quote,
147
- },
148
- })
149
-
150
- // Expect the first response to time out
151
- // The polling behavior is tested in the cache tests, so this is easier here.
152
- // Start the request:
153
- const errorPromise: Promise<AxiosError | undefined> = t.throwsAsync(makeRequest)
154
- // Advance enough time for the initial request async flow
155
- clock.tickAsync(10)
156
- // Wait for the failed cache get -> instant 504
157
- const error = await errorPromise
158
- t.is(error?.response?.status, 504)
159
-
160
- // Advance clock so that the batch warmer executes once again and wait for the cache to be set
161
- const cacheValueSetPromise = mockCache.waitForNextSet()
162
- await clock.tickAsync(DEFAULT_SHARED_MS_BETWEEN_REQUESTS + 10)
163
- await cacheValueSetPromise
164
-
165
- // Second request should find the response in the cache
166
- const response = await makeRequest()
167
-
168
- t.is(response.status, 200)
169
- t.deepEqual(response.data, {
170
- data: null,
171
- result: price,
172
- statusCode: 200,
173
- })
174
-
175
- // Wait until the cache expires, and the subscription is out
176
- await clock.tickAsync(Math.ceil(CACHE_MAX_AGE / DEFAULT_WS_TTL) * DEFAULT_WS_TTL + 1)
177
-
178
- // Now that the cache is out and the subscription no longer there, this should time out
179
- const error2: AxiosError | undefined = await t.throwsAsync(makeRequest)
180
- t.is(error2?.response?.status, 504)
181
-
182
- clock.uninstall()
183
- })
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "include": ["./**/*.ts"],
4
- "exclude": ["../src/**/*.ts"]
5
- }
package/test/util.ts DELETED
@@ -1,77 +0,0 @@
1
- import { InstalledClock } from '@sinonjs/fake-timers'
2
- import { AdapterDependencies } from '../src/adapter'
3
- import { LocalCache } from '../src/cache'
4
- import { SettingsMap } from '../src/config'
5
- import { Transport } from '../src/transports'
6
- import { AdapterRequest, AdapterResponse } from '../src/util'
7
-
8
- export class NopTransport implements Transport<null, null, SettingsMap> {
9
- async initialize(dependencies: AdapterDependencies): Promise<void> {
10
- return
11
- }
12
- async hasBeenSetUp(): Promise<boolean> {
13
- return false
14
- }
15
- async setup(req: AdapterRequest<unknown>): Promise<void | AdapterResponse<null>> {
16
- return
17
- }
18
- }
19
-
20
- type Resolve<T> = (value: T) => void
21
- export const deferredPromise = <T>(): [Promise<T>, Resolve<T>] => {
22
- let resolve!: Resolve<T>
23
- const promise = new Promise<T>((r) => {
24
- resolve = r
25
- })
26
- return [promise, resolve]
27
- }
28
-
29
- export class MockCache extends LocalCache {
30
- private awaitingPromiseResolve?: (value: unknown) => void
31
-
32
- waitForNextSet() {
33
- // eslint-disable-next-line no-promise-executor-return
34
- return new Promise((resolve) => (this.awaitingPromiseResolve = resolve))
35
- }
36
- override async set(key: string, value: unknown, ttl: number): Promise<void> {
37
- super.set(key, value, ttl)
38
- if (this.awaitingPromiseResolve) {
39
- this.awaitingPromiseResolve(value)
40
- }
41
- }
42
- }
43
-
44
- export async function runPeriodicAsyncBackgroundExecution(
45
- clock: InstalledClock,
46
- {
47
- interval,
48
- times,
49
- stepValidation,
50
- }: {
51
- interval: number
52
- times: number
53
- stepValidation: (iteration: number) => boolean
54
- },
55
- ) {
56
- for (let i = 0; i < times; i++) {
57
- // Tick once for the interval
58
- await clock.tickAsync(interval)
59
-
60
- // Then use auxiliary method to ensure that the background process, if it
61
- // spawns new timers, gets executed to completion
62
- await runAllUntil(clock, () => stepValidation(i))
63
- }
64
- }
65
-
66
- async function runAllUntil(clock: InstalledClock, isComplete: () => boolean): Promise<void> {
67
- while (!isComplete()) {
68
- await clock.nextAsync()
69
- }
70
- }
71
-
72
- export async function runAllUntilTime(clock: InstalledClock, time: number): Promise<void> {
73
- const targetTime = clock.now + time
74
- while (clock.now < targetTime) {
75
- await clock.nextAsync()
76
- }
77
- }
@@ -1,178 +0,0 @@
1
- import untypedTest, { TestFn } from 'ava'
2
- import axios, { AxiosError } from 'axios'
3
- import { AddressInfo } from 'net'
4
- import { expose } from '../src'
5
- import { Adapter, AdapterEndpoint } from '../src/adapter'
6
- import { AdapterResponse } from '../src/util'
7
- import { NopTransport } from './util'
8
-
9
- const test = untypedTest as TestFn<{
10
- serverAddress: string
11
- adapterEndpoint: AdapterEndpoint
12
- }>
13
-
14
- test.beforeEach(async (t) => {
15
- const adapter: Adapter = {
16
- name: 'test',
17
- endpoints: [
18
- {
19
- name: 'test',
20
- inputParameters: {},
21
- transport: new (class extends NopTransport {
22
- override async setup(): Promise<void | AdapterResponse<null>> {
23
- return {
24
- data: null,
25
- statusCode: 200,
26
- result: null,
27
- }
28
- }
29
- })(),
30
- },
31
- ],
32
- }
33
-
34
- t.context.adapterEndpoint = adapter.endpoints[0]
35
- const server = await expose(adapter)
36
- if (!server) {
37
- throw 'Server did not start'
38
- }
39
- t.context.serverAddress = `http://localhost:${(server.address() as AddressInfo).port}`
40
- })
41
-
42
- /**
43
- * NOTE: The tests here are run serially, because to avoid setting up and tearing down the adapter
44
- * for each one, we're just modifying the inputParameters and sending a new request every time
45
- */
46
- test.serial('any content-type other than application/json throws 400', async (t) => {
47
- t.context.adapterEndpoint.inputParameters = {}
48
-
49
- const error: AxiosError | undefined = await t.throwsAsync(() =>
50
- axios.post(`${t.context.serverAddress}`, 'test string', {
51
- headers: {
52
- 'Content-Type': 'text/plain',
53
- },
54
- }),
55
- )
56
- t.is(error?.response?.status, 400)
57
- })
58
-
59
- test.serial('no body in request throws 400', async (t) => {
60
- t.context.adapterEndpoint.inputParameters = {}
61
-
62
- const error: AxiosError | undefined = await t.throwsAsync(() =>
63
- axios.post(`${t.context.serverAddress}`, '', {
64
- headers: {
65
- 'Content-Type': 'application/json',
66
- },
67
- }),
68
- )
69
- t.is(error?.response?.status, 400)
70
- })
71
-
72
- test.serial('invalid endpoint name throws 404', async (t) => {
73
- t.context.adapterEndpoint.inputParameters = {}
74
-
75
- const error: AxiosError | undefined = await t.throwsAsync(() =>
76
- axios.post(`${t.context.serverAddress}`, {
77
- endpoint: 'random',
78
- }),
79
- )
80
- t.is(error?.response?.status, 404)
81
- })
82
-
83
- test.serial('no endpoint without default throws 400', async (t) => {
84
- t.context.adapterEndpoint.inputParameters = {}
85
-
86
- const error: AxiosError | undefined = await t.throwsAsync(() =>
87
- axios.post(`${t.context.serverAddress}`, {
88
- data: {},
89
- }),
90
- )
91
- t.is(error?.response?.status, 400)
92
- })
93
-
94
- test.serial('endpoint in data object', async (t) => {
95
- t.context.adapterEndpoint.inputParameters = {}
96
-
97
- const response = await axios.post(`${t.context.serverAddress}`, {
98
- data: { endpoint: 'test' },
99
- })
100
- t.is(response.status, 200)
101
- })
102
-
103
- test.serial('no params returns 200', async (t) => {
104
- t.context.adapterEndpoint.inputParameters = {}
105
-
106
- const response = await axios.post(`${t.context.serverAddress}`, {
107
- data: {},
108
- endpoint: 'test',
109
- })
110
- t.is(response.status, 200)
111
- })
112
-
113
- test.serial('missing required param throws 400', async (t) => {
114
- t.context.adapterEndpoint.inputParameters = {
115
- base: {
116
- type: 'string',
117
- required: true,
118
- },
119
- }
120
-
121
- const error: AxiosError | undefined = await t.throwsAsync(() =>
122
- axios.post(`${t.context.serverAddress}`, {
123
- data: {},
124
- }),
125
- )
126
- t.is(error?.response?.status, 400)
127
- })
128
-
129
- test.serial('wrongly typed param throws 400', async (t) => {
130
- t.context.adapterEndpoint.inputParameters = {
131
- base: {
132
- type: 'string',
133
- required: true,
134
- },
135
- }
136
-
137
- const error: AxiosError | undefined = await t.throwsAsync(() =>
138
- axios.post(`${t.context.serverAddress}`, {
139
- data: {
140
- base: 123,
141
- },
142
- endpoint: 'test',
143
- }),
144
- )
145
- t.is(error?.response?.status, 400)
146
- })
147
-
148
- test.serial('correctly typed param returns 200', async (t) => {
149
- t.context.adapterEndpoint.inputParameters = {
150
- base: {
151
- type: 'string',
152
- required: true,
153
- },
154
- }
155
-
156
- const response = await axios.post(`${t.context.serverAddress}`, {
157
- data: {
158
- base: 'asd',
159
- },
160
- endpoint: 'test',
161
- })
162
- t.is(response.status, 200)
163
- })
164
-
165
- test.serial('omitted optional param returns 200', async (t) => {
166
- t.context.adapterEndpoint.inputParameters = {
167
- base: {
168
- type: 'string',
169
- required: false,
170
- },
171
- }
172
-
173
- const response = await axios.post(`${t.context.serverAddress}`, {
174
- data: {},
175
- endpoint: 'test',
176
- })
177
- t.is(response.status, 200)
178
- })
package/test.sh DELETED
@@ -1,20 +0,0 @@
1
- # for i in {1..100}; do
2
- # if (( $i % 50 == 0 )); then
3
- # echo "sent $i"
4
- # fi
5
- # curl -XPOST http://localhost:8080 -s \
6
- # -H 'Content-Type: application/json' \
7
- # -d '{"endpoint":"test", "data": {"base": "ethereum", "quote": "usd"}}' > /tmp/null &
8
- # sleep 0.1
9
- # done
10
-
11
- # wait
12
-
13
- # echo "done"
14
-
15
- curl -XPOST http://localhost:8080 -s \
16
- -H 'Content-Type: application/json' \
17
- -d '{"endpoint":"batch", "data": {"base": "ethereum", "quote": "usd"}}' > /tmp/null &
18
-
19
-
20
- wait
package/test2.sh DELETED
@@ -1,2 +0,0 @@
1
- curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer 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" \
2
- "https://api.github.com/repos/smartcontractkit/ea-framework-js/actions/secrets"
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "dist",
4
- "rootDir": ".",
5
- "target": "es2020",
6
- "esModuleInterop": true,
7
- "moduleResolution": "node",
8
- "module": "CommonJS",
9
- "resolveJsonModule": true,
10
-
11
- // Type checking
12
- "allowUnreachableCode": false,
13
- "allowUnusedLabels": false,
14
- "allowJs": true,
15
- "alwaysStrict": true,
16
- "noImplicitAny": true,
17
- "noImplicitOverride": true,
18
- "noImplicitReturns": false,
19
- "noImplicitThis": true,
20
- "noPropertyAccessFromIndexSignature": true,
21
- "noUnusedLocals": true,
22
- "strict": true,
23
- "sourceMap": true,
24
- // "declaration": true
25
- },
26
- "exclude": ["src/**/test/**/*"],
27
- "include": ["./src/**/*"]
28
- }
package/typedoc.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["./src/index.ts"],
4
- "out": "docs",
5
- "includeVersion": true
6
- }
package/webpack.config.js DELETED
@@ -1,57 +0,0 @@
1
- const path = require('path')
2
- const glob = require('glob')
3
-
4
- module.exports = {
5
- target: 'node',
6
- // entry: './src/index.ts',
7
- // entry: glob.sync('./src/**/*.test.{ts,tsx}').reduce((acc, file) => {
8
- // acc[file.replace(/^\.\/src\//, '')] = file
9
- // return acc
10
- // }, {}),
11
- mode: 'development', // This shouldn't be used in production, but is fine for now since the pkg is in active development.
12
- devtool: 'inline-source-map', // This shouldn't be used in production, but is fine for now since the pkg is in active development.
13
- module: {
14
- rules: [
15
- {
16
- test: /\.tsx?$/,
17
- use: 'ts-loader',
18
- exclude: /node_modules/,
19
- },
20
- { test: /\.json$/, type: 'json' },
21
- // { test: /\.js$/, type: 'js' },
22
- ],
23
- },
24
- resolve: {
25
- extensions: ['.tsx', '.ts', '.js', '.json'],
26
- fallback: {
27
- // buffer: require.resolve('buffer'),
28
- // https: require.resolve('https-browserify'),
29
- // assert: require.resolve('assert'),
30
- // http: require.resolve('stream-http'),
31
- // querystring: require.resolve('querystring-es3'),
32
- // url: require.resolve('url'),
33
- // stream: require.resolve('stream-browserify'),
34
- // crypto: require.resolve('crypto-browserify'),
35
- // path: require.resolve('path-browserify'),
36
- // os: require.resolve('os-browserify/browser'),
37
- // process: require.resolve('process/browser'),
38
- // fs: false,
39
- // tls: false,
40
- long: false,
41
- },
42
- // alias: {
43
- // 'node:async_hooks': 'async_hooks',
44
- // },
45
- },
46
- output: {
47
- // filename: 'bundle.js',
48
- path: path.resolve(__dirname, 'dist'),
49
- // filename: '[name].[contenthash].js',
50
- filename: '[name].js',
51
- },
52
- optimization: {
53
- splitChunks: {
54
- chunks: 'all',
55
- },
56
- },
57
- }