1.0.0 • Published 1 year ago

@m92/http-client-fe-v2 v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

http-client-fe-v2

http-client-fe-v2 is a custom http-request package for browser with in-built support for JOSE (JWE) encryption. The ready package for backed could be found at

  1. Express JS(NodeJS)

Installation and Setup

ReactAppBoilerplate

If you're using ReactAppBoilerplate as recommended, requires 4 step configuration:

  1. Create Config File
// src/configurations/network/HTTP_CLIENT_CONFIG.js
import API_ROUTES from './API_ROUTES'

const { REACT_APP_ENABLE_CRPTOGRAPHY = '', REACT_APP_API_KEY } = process.env

const ENABLE_CRPTOGRAPHY = REACT_APP_ENABLE_CRPTOGRAPHY.trim().toLowerCase() === 'true'

const HTTP_CLIENT_CONFIG = {
  ENABLE_CRPTOGRAPHY,
  API_KEY: REACT_APP_API_KEY,
  API_ROUTES
}

export default HTTP_CLIENT_CONFIG
  1. Create Constants File
// src/configurations/network/HTTP_CLIENT_CONSTANTS.js
const { API_TIMEOUT } = process.env

const TIMEOUT = API_TIMEOUT || 3000

const HTTP_CLIENT_CONSTANTS = {
  TIMEOUT
}

export default HTTP_CLIENT_CONSTANTS
  1. Create HttpClient File
import HttpClientClass from '@m92/http-client-fe-v2'
import HTTP_CLIENT_CONFIG from 'configurations/network/HTTP_CLIENT_CONFIG'
import HTTP_CLIENT_CONSTANTS from 'configurations/network/HTTP_CLIENT_CONSTANTS'

const HttpClient = new HttpClientClass(HTTP_CLIENT_CONFIG, HTTP_CLIENT_CONSTANTS)

export default HttpClient
  1. Inject HttpClient in Redux Thunk
// src/configurations/redux/store.js
.....
import HttpClient from '//path/to/HttpClient/File'
.....

const middlewares = [
  thunk.withExtraArgument({ HttpClient }) // Argument can be a request object used inside all calls
]
.....

License

MIT

1.0.0

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.9

1 year ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago