0.0.112 • Published 2 months ago

@joktec/http v0.0.112

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Table of Contents

  1. Introduction
  2. Installation
  3. Getting Started
  4. Reference
  5. Contributing

Introduction

@joktec/http is a library used for making HTTP requests, based on NestJS. It is a wrapper for axios and @nestjs/axios, providing an easy-to-use interface for creating HTTP clients with NestJS.

Installation

To install this library, use either npm or yarn:

npm install -S @joktec/core @joktec/http
# or
yarn add -S @joktec/core @joktec/http

Getting Started

Configuration

@joktec/http uses a configuration file to set up the default options for the HTTP client. Create a config.yml file in the root of your project, and add the following configuration options:

http:
  baseURL: https://mydomain.com
  method: GET
  timeout: 30000
  auth:
    username: myuser
    password: mypass
  raxConfig:
    retry: 3

Update the values according to your HTTP client details. The raxConfig option is using the retry-axios package to automatically retry failed requests.

Module

Once you have provided the configuration, you can import the MongoModule in your AppModule:

import { CoreModule, Module } from '@joktec/core';
import { HttpModule } from '@joktec/http';

@Module({
  imports: [CoreModule, HttpModule],
})
export class AppModule {}

Service

You can then use the HttpService and do any request:

import { Injectable } from '@joktec/core';
import { HttpService, Client, HttpResponse, HttpFormData } from '@joktec/http';
import { firstValueFrom } from 'rxjs';

@Injectable()
export class MyService {
  constructor(private readonly httpService: HttpService) {}
  
  async request(): Promise<HttpResponse<T>> {
    return firstValueFrom(this.httpService.request<T>({
      // ... input config
    }));
  }

  async upload(): Observable<HttpResponse<T>> {
    const data: HttpFormData = new HttpFormData();
    return firstValueFrom(this.httpService.upload<T>({
      // ... input config
    }, data));
  }
}

Reference

axios

@nestjs/axios

retry-axios

Contributing

Contributions to @joktec/http are welcome. If you would like to contribute, please fork the repository, make your changes, and submit a pull request.

Please make sure to update tests as appropriate.

0.0.112

2 months ago

0.0.111

2 months ago

0.0.108

3 months ago

0.0.107

4 months ago

0.0.105

5 months ago

0.0.104

5 months ago

0.0.103

5 months ago

0.0.84

9 months ago

0.0.85

8 months ago

0.0.86

8 months ago

0.0.87

8 months ago

0.0.88

8 months ago

0.0.89

8 months ago

0.0.80

9 months ago

0.0.81

9 months ago

0.0.82

9 months ago

0.0.83

9 months ago

0.0.73

10 months ago

0.0.74

9 months ago

0.0.75

9 months ago

0.0.76

9 months ago

0.0.77

9 months ago

0.0.78

9 months ago

0.0.79

9 months ago

0.0.70

10 months ago

0.0.71

10 months ago

0.0.72

10 months ago

0.0.69

10 months ago

0.0.102

6 months ago

0.0.101

6 months ago

0.0.100

6 months ago

0.0.95

6 months ago

0.0.96

6 months ago

0.0.97

6 months ago

0.0.98

6 months ago

0.0.99

6 months ago

0.0.90

8 months ago

0.0.91

8 months ago

0.0.92

8 months ago

0.0.93

8 months ago

0.0.94

8 months ago

0.0.67

10 months ago

0.0.68

10 months ago

0.0.62

11 months ago

0.0.63

11 months ago

0.0.64

11 months ago

0.0.65

11 months ago

0.0.66

11 months ago

0.0.60

11 months ago

0.0.61

11 months ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

12 months ago

0.0.55

12 months ago

0.0.56

11 months ago

0.0.57

11 months ago

0.0.58

11 months ago

0.0.49

1 year ago

0.0.48

1 year ago

0.0.46

1 year ago

0.0.45

1 year ago

0.0.44

1 year ago

0.0.43

1 year ago

0.0.42

1 year ago

0.0.41

1 year ago

0.0.40

1 year ago

0.0.39

1 year ago

0.0.38

1 year ago

0.0.37

1 year ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.34

1 year ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago