Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Nov 14, 2022
1 parent 397e8af commit 6570491
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
}
},
"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup.sh",
"build": "rm -rf dist && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && ./fixup.sh",
"dev": "tsc --watch",
"prepare": "npm run build"
},
"directories": {
"test": "test"
}
}
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface YFResponse {
chart: { result: { meta: { regularMarketPrice: number } }[] }
}

export async function getExchangeRate (from: CurrencyCode, to: CurrencyCode): Promise<number | undefined> {
export async function getExchangeRate (from: CurrencyCode, to: CurrencyCode): Promise<number> {
let response
try {
const rateUrl = YF_BASE + from.toUpperCase() + to.toUpperCase() + YF_PARAMS
Expand All @@ -26,8 +26,10 @@ export async function getExchangeRate (from: CurrencyCode, to: CurrencyCode): Pr

const result = await response.json() as YFResponse
const rate = result.chart?.result[0]?.meta?.regularMarketPrice

if (!rate) {
throw new MalformedError('Service did not return correct data structure.')
}

return rate
}
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig-cjs.json → tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig-base.json",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": false,
"module": "commonjs",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig-base.json",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/esm",
Expand Down

0 comments on commit 6570491

Please sign in to comment.