Skip to main content

http-client

@ensono-stacks/rest-client:http-client

Installs and creates a new instance of Axios, ready to generate a client with custom configuration

This plugin installs Axios and configures a new instance of the provider ready to be customised and consumed via your project.

Usage

nx g @ensono-stacks/rest-client:http-client

Command line arguments

The following command line arguments are available:

OptionDescriptionTypeAccepted ValuesDefaultRequired
--nameLibrary namestringtrue
--directorySubdirectory inside libs/ where the generated library is placedstring
--importPathWhat import path would you like to use for the librarystring
--tagsAdd tags to the library (used for linting)string
--skipFormatSkip formatting filesbooleanfalse

Generator Output

The http-client will create a new library within your libs folder for the axios http client:

Generated files

├── http-client
│ ├── src
│ │ ├── index.ts
│ │ ├── index.test.ts
│ ├── README.md
│ ├── tsconfig.json
│ ├── tsconfig.lib.json
│ ├── project.json
│ ├── .eslintrc.json
│ ├── jest.config.ts
└── └── tsconfig.spec.json

Additionally, the package.json will be updated with the axios dependency.

Modified files
├── root
│ ├── tsconfig.base.json
└── └──package.json

In order to import the http-client into your application a new entry for the client is added to the tsconfig.base.json "paths"

"paths": {
"@<workspace-name>/http-client": [
"libs/http-client/src/index.ts"
]
}