/
http.ts
41 lines (36 loc) · 1.2 KB
/
http.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AxiosInstance, AxiosRequestConfig } from 'axios'
import { RestEndpoint } from '../types'
import * as raw from './raw'
export const get: RestEndpoint<'Http', 'get'> = <T = any>(
http: AxiosInstance,
{ url, config }: { url: string; config?: AxiosRequestConfig }
) => {
return raw.get<T>(http, url, config)
}
export const post: RestEndpoint<'Http', 'post'> = <T = any>(
http: AxiosInstance,
{ url, config }: { url: string; config?: AxiosRequestConfig },
payload?: any
) => {
return raw.post<T>(http, url, payload, config)
}
export const put: RestEndpoint<'Http', 'put'> = <T = any>(
http: AxiosInstance,
{ url, config }: { url: string; config?: AxiosRequestConfig },
payload?: any
) => {
return raw.put<T>(http, url, payload, config)
}
export const del: RestEndpoint<'Http', 'delete'> = <T = any>(
http: AxiosInstance,
{ url, config }: { url: string; config?: AxiosRequestConfig }
) => {
return raw.del<T>(http, url, config)
}
export const request: RestEndpoint<'Http', 'request'> = <T = any>(
http: AxiosInstance,
{ url, config }: { url: string; config?: AxiosRequestConfig }
) => {
return raw.http<T>(http, url, config)
}