ts-ice
v0.1.2
Published
🍨 The easy way to make your clean REST client library.
Downloads
2
Readme
ts-ice
Maybe you need it
Usage
Firstly, set compilerOptions.moduleResolution
be Bundler
to your project tsconfig.json
.
Examples
Easily define your client
type MyRequest = {
<T, H extends Record<string, string>>(data: T, headers: H): Promise<Response>;
};
type MyHeader = {
Authorization: string;
};
class SampleClient extends IceRest<MyRequest, MyHeader> {
async hello(message: string) {
return await this.request({ message }, {});
}
}
Now say 👋
const sampleClient = new SampleClient({
instanceCreateFn(options) {
return async (data) => {
const { baseURL } = options;
return await fetch(baseURL, { body: JSON.stringify(data) });
};
},
baseURL: "http://api.example.com",
});
await sampleClient.hello("");
Contributing
We welcome contributions to enhance the functionality and usability of this utility. Feel free to submit issues for bug reports or feature requests, and create pull requests to suggest improvements or fixes.
License
This project is licensed under the MIT License - see the LICENSE file for details.