From a84131d5f23107089b81336996ac1c4f032a95ab Mon Sep 17 00:00:00 2001 From: AP Date: Tue, 10 Dec 2019 20:18:56 +0100 Subject: [PATCH] chore: prettier --- src/schemas/query/data/bitcoinPrice.ts | 74 +++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/schemas/query/data/bitcoinPrice.ts b/src/schemas/query/data/bitcoinPrice.ts index 8a16205e..55c2e20b 100644 --- a/src/schemas/query/data/bitcoinPrice.ts +++ b/src/schemas/query/data/bitcoinPrice.ts @@ -1,45 +1,45 @@ -import { logger } from "../../../helpers/logger"; -import { requestLimiter } from "../../../helpers/rateLimiter"; -import { GraphQLString } from "graphql"; -import { BitcoinPriceType } from "../../../schemaTypes/query/data/bitcoinPrice"; -import fetch from "node-fetch"; +import { logger } from '../../../helpers/logger'; +import { requestLimiter } from '../../../helpers/rateLimiter'; +import { GraphQLString } from 'graphql'; +import { BitcoinPriceType } from '../../../schemaTypes/query/data/bitcoinPrice'; +import fetch from 'node-fetch'; -const url = "https://blockchain.info/ticker"; +const url = 'https://blockchain.info/ticker'; export const getBitcoinPrice = { - type: BitcoinPriceType, - args: { - currency: { - type: GraphQLString - } - }, - resolve: async (root: any, params: any, context: any) => { - await requestLimiter(context.ip, params, "bitcoinPrice", 1, "1s"); + type: BitcoinPriceType, + args: { + currency: { + type: GraphQLString, + }, + }, + resolve: async (root: any, params: any, context: any) => { + await requestLimiter(context.ip, 'bitcoinPrice'); - try { - const response = await fetch(url); - const json = await response.json(); + try { + const response = await fetch(url); + const json = await response.json(); - if (!params.currency && "EUR" in json) { - const value = json.EUR; + if (!params.currency && 'EUR' in json) { + const value = json.EUR; - return { - price: value.last, - symbol: value.symbol - }; - } else if (params.currency in json) { - const value = json[params.currency]; + return { + price: value.last, + symbol: value.symbol, + }; + } else if (params.currency in json) { + const value = json[params.currency]; - return { - price: value.last, - symbol: value.symbol - }; - } else { - throw new Error("Problem getting Bitcoin price."); - } - } catch (error) { - logger.error("Error getting bitcoin price: %o", error); - throw new Error("Problem getting Bitcoin price."); - } - } + return { + price: value.last, + symbol: value.symbol, + }; + } else { + throw new Error('Problem getting Bitcoin price.'); + } + } catch (error) { + logger.error('Error getting bitcoin price: %o', error); + throw new Error('Problem getting Bitcoin price.'); + } + }, };