diff options
| author | Saumit <justsaumit@protonmail.com> | 2025-09-27 02:14:26 +0530 |
|---|---|---|
| committer | Saumit <justsaumit@protonmail.com> | 2025-09-27 02:14:26 +0530 |
| commit | 82e03978b89938219958032efb1448cc76baa181 (patch) | |
| tree | 626f3e54d52ecd49be0ed3bee30abacc0453d081 /src/frontend/pages/api/currency.ts | |
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'src/frontend/pages/api/currency.ts')
| -rw-r--r-- | src/frontend/pages/api/currency.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/frontend/pages/api/currency.ts b/src/frontend/pages/api/currency.ts new file mode 100644 index 0000000..fd69909 --- /dev/null +++ b/src/frontend/pages/api/currency.ts @@ -0,0 +1,25 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +import type { NextApiRequest, NextApiResponse } from 'next'; +import InstrumentationMiddleware from '../../utils/telemetry/InstrumentationMiddleware'; +import CurrencyGateway from '../../gateways/rpc/Currency.gateway'; +import { Empty } from '../../protos/demo'; + +type TResponse = string[] | Empty; + +const handler = async ({ method }: NextApiRequest, res: NextApiResponse<TResponse>) => { + switch (method) { + case 'GET': { + const { currencyCodes = [] } = await CurrencyGateway.getSupportedCurrencies(); + + return res.status(200).json(currencyCodes); + } + + default: { + return res.status(405); + } + } +}; + +export default InstrumentationMiddleware(handler); |
