@samet-digital/be-client-common
v1.0.4
Published
Http client operations
Downloads
108
Readme
Samet Digital : Client Common [Component]
▗▄▄▖▗▖ ▗▄▄▄▖▗▄▄▄▖▗▖ ▗▖▗▄▄▄▖ ▗▄▄▖ ▗▄▖ ▗▖ ▗▖▗▖ ▗▖ ▗▄▖ ▗▖ ▗▖
▐▌ ▐▌ █ ▐▌ ▐▛▚▖▐▌ █ ▐▌ ▐▌ ▐▌▐▛▚▞▜▌▐▛▚▞▜▌▐▌ ▐▌▐▛▚▖▐▌
▐▌ ▐▌ █ ▐▛▀▀▘▐▌ ▝▜▌ █ ▐▌ ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▝▜▌
▝▚▄▄▖▐▙▄▄▖▗▄█▄▖▐▙▄▄▖▐▌ ▐▌ █ ▝▚▄▄▖▝▚▄▞▘▐▌ ▐▌▐▌ ▐▌▝▚▄▞▘▐▌ ▐▌EN: It should be used when you needs to connect another service via http connectionTR: Diğer sunucuya http katmanı ile bağlanacaksanız, bu bileşeni kullanınız
Usage
EN: How to add into your project?TR: Projene nasıl eklersin?
npm i @samet-digital/client-commonimport {HttpClient} from "./http.client";
import {HttpInstanceLike} from "./index.types";
class ProductService {
private _get: HttpInstanceLike;
private _delete: HttpInstanceLike;
private _update: HttpInstanceLike;
constructor(private httpClient: HttpClient) {
// give name for logging
this._get = this.httpClient.instance({name: 'get-product'});
this._delete = this.httpClient.instance({name: 'delete-product'});
this._update = this.httpClient.instance({name: 'update-product'});
}
async get(id: string): Promise<ClientResponse> {
return this._get.get(
`http://domain.com/api/products/${id}`,
{headers: {'token': 'csaa'}}
);
}
async delete(id: string): Promise<ClientResponse> {
return this._delete.del(
`http://domain.com/api/products/${id}`,
{headers: {'token': 'csaa'}}
);
}
async update(id: string, data: any): Promise<ClientResponse> {
return this._update.put(
`http://domain.com/api/products/${id}`,
data,
{headers: {'token': 'csaa'}}
);
}
}Environments
- ~~none~~
Contents
- HttpClient
- HttpModule
- ClientResponse - result of http call
- ClientResponseSystem - result of http system data
- ClientResponseException - result of http error object
Development
You can start to develop on it
Step 1
EN: Go to your project folderTR: Bilgisayarında proje klasörüne git
# Windows
cd C:\\projects\samet-digital# Mac
cd /Users/{user}/projects/samet-digitalStep 2
EN: Clone the projectTR: Projeyi bilgisiyarına çek
git clone https://github.com/samet-digital/client-common.git -b developmentDependencies
- base-common -
samet-digital - axios -
axioshttp request engine
Commands
# Collects all dependencies
npm i
# Builds project dist (TS -> JS, src -> dist)
npm run build
# Publishes component on http://npmjs.com/
npm run publish:public
# Clears `dist` and `coverage` folders
npm run clear
# Clear `node_modules` folder
npm run clear:nm
# Validates lint for only errors @see (./eslint.config.mjs) for rules
npm run lint
# Validates lint with warnings
npm run lint:verbose
# Runs test cases
npm run test
# Exports coverage report, @see (./coverage/lcov-report/index.html)
npm run coverage
# Finds outdated/legacy dependencies
npm outdatedStandards
+ language: TS
+ lint: eslint
+ inspections: intelli-j code inspections
+ ddd: domain driven development
+ edd: exception driven development
! tdd: test driven development
+ ldd: log driven development
+ ddd: document driven developmentHistory
| Date | Developer | Info | Ticket | |------------|----------------|--------------|----------------| | 2025-04-05 | Mustafa Yelmer | Created | ~~none~~ | | 2025-08-09 | Mustafa Yelmer | Refactored | ~~none~~ | | 2025-08-14 | Mustafa Yelmer | Documented | ~~none~~ |
