Skip to content

Commit

Permalink
chore: api response, request 타입 세팅 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
saseungmin authored May 24, 2024
1 parent 99a3623 commit 9e69970
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
5 changes: 4 additions & 1 deletion frontend/src/lib/apis/earningRate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* eslint-disable import/prefer-default-export */

import { EarningRate } from '../types/earningRate';

import api from '.';

export const getEarningRate = async () => {
const response = await api<any>({
const response = await api<EarningRate>({
url: '/v1/earning_rate',
method: 'POST',
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import qs from 'qs';

import { FetchRequest } from '@/types/api';
import { FetchRequest } from '../types/api';

export class FetchError extends Error {
constructor(
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/lib/apis/scenario.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ScenariosTickerResponse, ScenarioTickerRequest } from '../types/scenario';

import api from '.';

export const getTicker = async () => {
const response = await api<any>({
export const getTicker = async (params: ScenarioTickerRequest) => {
const response = await api<ScenariosTickerResponse>({
url: '/v1/scenario/{ticker}',
method: 'POST',
params,
});

return response;
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions frontend/src/lib/types/earningRate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface EarningRate {
asset: number;
result: number;
rate: string;
}
27 changes: 27 additions & 0 deletions frontend/src/lib/types/scenario.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export type ScenarioTickerRequest = {
start_time: number;
end_time: number;
};

export type ScenariosTickerResponse = ScenariosTicker[];

export interface ScenariosTicker {
code: 'BTC/KRW';
high: number;
open: number;
close: number;
low: number;
buySignal: number; // 주문
buyInfo: BuyInfo[]; // 채결
sellSignal: number;
sellInfo: SellInfo[];
currentTime: number;
hasMore: boolean;
}

export type BuyInfo = {
price: number;
amount: number;
};

export type SellInfo = BuyInfo;

0 comments on commit 9e69970

Please sign in to comment.