generated from phucvinh57/fastify-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from TickLabVN:feature/update-excute-and-check…
…out-api refactor(printing request): add printing request and file ID in some APIs
- Loading branch information
Showing
12 changed files
with
91 additions
and
16 deletions.
There are no files selected for viewing
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,8 +1,34 @@ | ||
FASTIFY_PORT= | ||
FASTIFY_TEST_PORT= | ||
|
||
POSTGRES_USER= | ||
POSTGRES_PASSWORD= | ||
POSTGRES_DB= | ||
POSTGRES_DB=ssps_db | ||
POSTGRES_PORT= | ||
POSTGRES_TEST_PORT=s | ||
POSTGRES_URL= | ||
|
||
CORS_WHITE_LIST= | ||
CORS_WHITE_LIST=[http://localhost:3000, http://localhost:8080] | ||
COOKIE_SECRET= | ||
JWT_SECRET= | ||
JWT_SECRET= | ||
|
||
MINIO_URL= | ||
MINIO_SERVER_ENDPOINT= | ||
MINIO_PORT=9000 | ||
MINIO_ACCESS_KEY= | ||
MINIO_SECRET_KEY= | ||
MINIO_BUCKET_NAME=ssps | ||
|
||
CHECKOUT_ENVIRONMENT=sandbox | ||
PAYPAL_LIVE_ENDPOINT=https://api-m.paypal.com | ||
PAYPAL_SANDBOX_ENDPOINT=https://api-m.sandbox.paypal.com | ||
PAYPAL_CLIENT_ID= | ||
PAYPAL_CLIENT_SECRET= | ||
|
||
OPEN_EXCHANGE_RATES_ENDPOINT=https://open.er-api.com | ||
OPEN_EXCHANGE_RATES_APP_ID= | ||
|
||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
GOOGLE_REDIRECT_URL= | ||
UI_HOME_URL=https://ssps.tickflow.net/home |
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
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
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,7 @@ | ||
import { invoke, openExchangeRatesServer } from './common'; | ||
|
||
export const currencyExchangeRateService = { | ||
getVietNameseExchangeRate: (apiKey: string) => { | ||
return invoke<Record<string, Record<string, string | number>>>(openExchangeRatesServer.get(`/v6/latest/VND?apikey=${apiKey}`)); | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { envs } from '@configs'; | ||
import { currencyExchangeRateService } from '@services'; | ||
|
||
export async function convertVNDtoUSD(amountInVND: number): Promise<number> { | ||
const targetCurrency = 'USD'; | ||
|
||
try { | ||
const currencyExchangeRates = await currencyExchangeRateService.getVietNameseExchangeRate(envs.OPEN_EXCHANGE_RATES_APP_ID); | ||
|
||
const exchangeRate = currencyExchangeRates.rates[targetCurrency]; | ||
const amountInUSD = amountInVND * Number(exchangeRate) * 1.0; | ||
return amountInUSD; | ||
} catch (error) { | ||
console.error(`Error: ${error.message}`); | ||
throw new Error('An error occurred while processing the conversion'); | ||
} | ||
} |
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