mirror of https://github.com/buster-so/buster.git
currency response
This commit is contained in:
parent
58542c204d
commit
5352ae8f10
|
@ -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 { Hono } from 'hono';
|
||||||
import { requireAuth } from '../../../middleware/auth';
|
import { requireAuth } from '../../../middleware/auth';
|
||||||
import { CURRENCIES_MAP } from './config';
|
import { CURRENCIES_MAP } from './config';
|
||||||
|
@ -6,7 +6,7 @@ import { CURRENCIES_MAP } from './config';
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
|
|
||||||
app.use('*', requireAuth).get('/', async (c) => {
|
app.use('*', requireAuth).get('/', async (c) => {
|
||||||
return c.json<Currency[]>(CURRENCIES_MAP);
|
return c.json<CurrencyResponse>(CURRENCIES_MAP);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { queryOptions } from '@tanstack/react-query';
|
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'],
|
queryKey: ['nextjs', 'list', 'currencies'],
|
||||||
initialData: [],
|
initialData: [],
|
||||||
initialDataUpdatedAt: 0,
|
initialDataUpdatedAt: 0,
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
export * from './currency.types';
|
export * from './currency.types';
|
||||||
|
export * from './responses';
|
||||||
|
|
|
@ -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>;
|
Loading…
Reference in New Issue