currency response

This commit is contained in:
Nate Kelley 2025-07-14 09:41:25 -06:00
parent 58542c204d
commit 5352ae8f10
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 11 additions and 3 deletions

View File

@ -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<Currency[]>(CURRENCIES_MAP);
return c.json<CurrencyResponse>(CURRENCIES_MAP);
});
export default app;

View File

@ -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<CurrencyResponse>({
queryKey: ['nextjs', 'list', 'currencies'],
initialData: [],
initialDataUpdatedAt: 0,

View File

@ -1 +1,2 @@
export * from './currency.types';
export * from './responses';

View File

@ -0,0 +1,6 @@
import { z } from 'zod';
import { CurrencySchema } from './currency.types';
export const CurrencyResponseSchema = z.array(CurrencySchema);
export type CurrencyResponse = z.infer<typeof CurrencyResponseSchema>;