Interface request fo inversion of control
npm install @odg/message



!Repository size



- ๐ Benefits
- ๐ Libraries
- ๐ Dependencies
- โฉ Get Started
- ๐ Add dependencies
- ๐ป Usage
- ๐ฐ Example Implements
- ๐งช Teste Code
---
- ๐ Inversion of control (IoC)
- ๐ Dependency Injection (DI)
- ๐จ Over 800 rules for pattern, possible errors and errors in Linter
- Node.js 16
- Typescript
- Eslint
- ODG-Linter-JS
- EditorConfig
- ReviewDog
- Node.js 16 or later
- Yarn Optional/Recommended
- ODG TsConfig Last Version
- ODG Exception Last Version
---
``powershell`
yarn add @odg/message
> for use axios implementation click here
`typescript
class Test {
public constructor(private readonly requester: MessageInterface) {
}
public async example(): ResponseInterface
return this.requester.request({
url: "https://google.com",
});
}
}
`
#### ๐ฐ Example Implements
`typescript
import axios, {
type AxiosInstance,
type AxiosResponse,
type AxiosResponseHeaders,
} from "axios";
import {
type HttpHeadersInterface,
type InterceptorManager,
type RequestInterface ,
type MessageInterface,
type ResponseInterface,
MessageException,
} from "@odg/message";
export class AxiosMessage
public interceptors: {
request: InterceptorManager
response: InterceptorManager
};
private readonly client: AxiosInstance;
public constructor() {
this.client = axios.create();
// this.interceptors = implements;
}
public async request<
RequestD = RequestData,
ResponseD = ResponseData,
>(config: RequestInterface
try {
const response = await this.client.request
return {
data: response.data,
status: response.status,
headers: response.headers,
request: response.config,
};
} catch (error: unknown) {
throw new MessageException("Example");
}
}
}
`
To Test execute this command
`bash``
yarn testor
yarn test:watch