You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.ts 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import Client from './client'
  2. import Method from './method'
  3. import Resource from './resource'
  4. export enum AuthenticationTypes {
  5. BasicAuth = 'basic',
  6. TokenAuth = 'token',
  7. KeyAuth = 'key',
  8. BearerAuth = 'bearer',
  9. }
  10. export type Seconds = number
  11. export type BaseUrl = string | URL
  12. export interface Headers {}
  13. export interface Authentication {
  14. type: AuthenticationTypes,
  15. }
  16. export interface Config {
  17. baseUrl: BaseUrl,
  18. headers?: Headers,
  19. authentication?: Authentication,
  20. retries?: number,
  21. timeout?: Seconds,
  22. }
  23. export interface Portal {
  24. route: Method, // TODO: function taking some spec
  25. resource: Resource, // TODO: function taking some spec
  26. _client: Client,
  27. }
  28. export interface Response {
  29. status: {
  30. code: number,
  31. word: string,
  32. },
  33. body: Object | undefined,
  34. headers: Headers,
  35. _rawResponse: string, // raw string response
  36. }
  37. export function createBaseClient (config: Config) /*: Portal*/ {
  38. const client = new Client()
  39. // const portal: Portal = {
  40. // _client: client,
  41. // }
  42. // return portal
  43. return client
  44. }
  45. export default createBaseClient