Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Http] Add Http module #400

Closed
kiaking opened this issue Nov 21, 2023 · 0 comments · Fixed by #407
Closed

[Http] Add Http module #400

kiaking opened this issue Nov 21, 2023 · 0 comments · Fixed by #407
Labels
enhancement New feature or request

Comments

@kiaking
Copy link
Member

kiaking commented Nov 21, 2023

Http is a wrapper around axios that provides some additional features. For response type, I guess we can use AxiosResponse as is if we don't have any other thoughts. Here I'm defining as Response just to make the api look simpler.

Import

import { Http } from '@globalbrain/sefirot/http/Http'

Api

class Http {
  get<T = any, R = Response<T>>(
    url: string,
    config?: Config
  ): Promise<R>

  post<T = any, R = Response<T>>(
    url: string,
    data?: Record<string, any>,
    config?: Config
  ): Promise<R>

  put<T = any, R = Response<T>>(
    url: string,
    data?: Record<string, any>,
    config?: Config
  ): Promise<R>

  delete<T = any, R = Response<T>>(
    url: string,
    config?: Config
  ): Promise<R>

  resolve<T = any, R = Response<T>>(
    method: Method,
    url: string,
    config?: Config
  ): Promise<R>

  // Send multi-part request to upload files.
  upload<T = any, R = Response<T>>(
    url: string,
    data?: Record<string, any>
  ): Promise<R>

  // Download a file.
  download(
    url: string,
    config?:Config
  ): Promise<void>
}
@kiaking kiaking added the enhancement New feature or request label Nov 21, 2023
kiaking added a commit that referenced this issue Dec 7, 2023
close #400

---------

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
Co-authored-by: Kia King Ishii <kia.king.08@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant