diff --git a/apps/server/src/api/v2/currency/index.ts b/apps/server/src/api/v2/currency/index.ts index eba3c307e..b431ef09b 100644 --- a/apps/server/src/api/v2/currency/index.ts +++ b/apps/server/src/api/v2/currency/index.ts @@ -1,4 +1,4 @@ -import type { Currency } from '@buster/server-shared/currency'; +import type { Currency, CurrencyResponse } from '@buster/server-shared/currency'; import { Hono } from 'hono'; import { requireAuth } from '../../../middleware/auth'; import { CURRENCIES_MAP } from './config'; @@ -6,7 +6,7 @@ import { CURRENCIES_MAP } from './config'; const app = new Hono(); app.use('*', requireAuth).get('/', async (c) => { - return c.json(CURRENCIES_MAP); + return c.json(CURRENCIES_MAP); }); export default app; diff --git a/apps/web/src/api/query_keys/currency.ts b/apps/web/src/api/query_keys/currency.ts index a9cecebd6..349e2b8fd 100644 --- a/apps/web/src/api/query_keys/currency.ts +++ b/apps/web/src/api/query_keys/currency.ts @@ -1,6 +1,7 @@ import { queryOptions } from '@tanstack/react-query'; +import { CurrencyResponse } from '@buster/server-shared/currency'; -export const getCurrencies = queryOptions<{ code: string; description: string; flag: string }[]>({ +export const getCurrencies = queryOptions({ queryKey: ['nextjs', 'list', 'currencies'], initialData: [], initialDataUpdatedAt: 0, diff --git a/packages/server-shared/src/currency/index.ts b/packages/server-shared/src/currency/index.ts index a72a25d98..31f9dd1a3 100644 --- a/packages/server-shared/src/currency/index.ts +++ b/packages/server-shared/src/currency/index.ts @@ -1 +1,2 @@ export * from './currency.types'; +export * from './responses'; diff --git a/packages/server-shared/src/currency/responses.ts b/packages/server-shared/src/currency/responses.ts new file mode 100644 index 000000000..c04531a7b --- /dev/null +++ b/packages/server-shared/src/currency/responses.ts @@ -0,0 +1,6 @@ +import { z } from 'zod'; +import { CurrencySchema } from './currency.types'; + +export const CurrencyResponseSchema = z.array(CurrencySchema); + +export type CurrencyResponse = z.infer;