requester-common.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. export declare type Destroyable = {
  2. /**
  3. * Destroy any sockets that are currently in use by the agent.
  4. *
  5. * It is usually not necessary to do this. However, if using an agent with keepAlive enabled, then
  6. * it is best to explicitly shut down the agent when it will no longer be used. Otherwise, sockets
  7. * may hang open for quite a long time before the server terminates them.
  8. */
  9. readonly destroy: () => Readonly<Promise<void>>;
  10. };
  11. export declare const MethodEnum: Readonly<Record<string, MethodType>>;
  12. export declare type MethodType = 'DELETE' | 'GET' | 'POST' | 'PUT';
  13. export declare type Request = {
  14. /**
  15. * The headers of the request.
  16. */
  17. readonly headers: Readonly<Record<string, string>>;
  18. /**
  19. * The method of the request. `GET`, etc.
  20. */
  21. readonly method: MethodType;
  22. /**
  23. * The complete url of the request, with the protocol.
  24. */
  25. readonly url: string;
  26. /**
  27. * The timeout to stablish a connection with the server.
  28. */
  29. readonly connectTimeout: number;
  30. /**
  31. * The timeout to receive the response.
  32. */
  33. readonly responseTimeout: number;
  34. /**
  35. * The data to be transfered to the server.
  36. */
  37. readonly data: string | undefined;
  38. };
  39. export declare type Requester = {
  40. /**
  41. * Sends the given `request` to the server.
  42. */
  43. readonly send: (request: Request) => Readonly<Promise<Response>>;
  44. };
  45. export declare type Response = {
  46. /**
  47. * The raw response from the server.
  48. */
  49. content: string;
  50. /**
  51. * If the request timeouted.
  52. */
  53. isTimedOut: boolean;
  54. /**
  55. * The http status code.
  56. */
  57. status: number;
  58. };
  59. export { }