From 4d153e9fff4a04f649e9425af1f4dbeb42929d4c Mon Sep 17 00:00:00 2001 From: Nichelle Date: Wed, 6 Apr 2022 16:41:50 +0800 Subject: [PATCH] Introduce OracleStatus for explicit API response --- ...ntroller.test.ts => OracleStatusController.test.ts} | 0 .../src/controllers/OracleStatusController.ts | 10 +++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) rename apps/status-api/__tests__/controllers/{OraclesController.test.ts => OracleStatusController.test.ts} (100%) diff --git a/apps/status-api/__tests__/controllers/OraclesController.test.ts b/apps/status-api/__tests__/controllers/OracleStatusController.test.ts similarity index 100% rename from apps/status-api/__tests__/controllers/OraclesController.test.ts rename to apps/status-api/__tests__/controllers/OracleStatusController.test.ts diff --git a/apps/status-api/src/controllers/OracleStatusController.ts b/apps/status-api/src/controllers/OracleStatusController.ts index f49625629d..e7bed5cbfa 100644 --- a/apps/status-api/src/controllers/OracleStatusController.ts +++ b/apps/status-api/src/controllers/OracleStatusController.ts @@ -11,10 +11,16 @@ export class OracleStatusController { ) { } + /** + * To provide the status of each oracle given the address based on the last published time for any given token + * + * @param oracleAddress + * @return {Promise} + */ @Get() async getOracleStatus ( @Query('address') oracleAddress: string - ): Promise<{ [key: string]: string }> { + ): Promise<{status: OracleStatus}> { const oraclePriceFeed: OraclePriceFeed = await this.cachedGet(`oracle-${oracleAddress}`, async () => { const oracle = await this.client.oracles.getOracleByAddress(oracleAddress) return (await this.client.oracles.getPriceFeed(oracle.id, oracle.priceFeeds[0].token, oracle.priceFeeds[0].currency, 1))[0] @@ -41,3 +47,5 @@ function requireValue (value: T | undefined, name: string): T { } return value } + +export type OracleStatus = 'outage' | 'operational'