@samet-digital/api-common
v1.0.3
Published
API Common
Readme
Samet Digital : API Common [Component]
▗▄▖ ▗▄▄▖▗▄▄▄▖ ▗▄▄▖ ▗▄▖ ▗▖ ▗▖▗▖ ▗▖ ▗▄▖ ▗▖ ▗▖
▐▌ ▐▌▐▌ ▐▌ █ ▐▌ ▐▌ ▐▌▐▛▚▞▜▌▐▛▚▞▜▌▐▌ ▐▌▐▛▚▖▐▌
▐▛▀▜▌▐▛▀▘ █ ▐▌ ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌▐▌ ▝▜▌
▐▌ ▐▌▐▌ ▗▄█▄▖ ▝▚▄▄▖▝▚▄▞▘▐▌ ▐▌▐▌ ▐▌▝▚▄▞▘▐▌ ▐▌EN: It should be used for service projectsTR: Tüm servis, entegrasyon vs projelerinde kullanılmalıdır
Usage
EN: How to add into your project?TR: Projene nasıl eklersin?
npm i @samet-digital/api-commonEnvironments
@see Config
| Name | Type | Default |
|---------------------------|----------|--------------------------------------------------------------------------------------------------------------------|
| HTTP_PORT | integer | REQUIRED |
| SMT_GNL_ORGANIZATION | string | Samet Digital |
| SMT_GNL_DOCS | string | docs |
| SMT_GNL_GATEWAY | string | REQUIRED |
| SMT_DEF_LANGUAGE | string | tr |
| SMT_DEF_COUNTRY | string | TR |
| SMT_PRJ_APP_NAME | string | REQUIRED |
| SMT_PRJ_CONTEXT_PATH | string | REQUIRED |
| SMT_PRJ_HOST_NAME | string | SMT_GNL_GATEWAY:HTTP_PORT |
| SMT_HDR_AUTHORIZATION | string[] | authorization, api-key |
| SMT_HDR_APPLICATION | string[] | x-application |
| SMT_HDR_CORRELATION_ID | string[] | x-correlation, x-correlation-id |
| SMT_HDR_REFERER | string[] | x-fwd-referer, x-fwd-referrer, x-referer, x-referrer, referer, referrer |
| SMT_HDR_USER_AGENT | string[] | x-fwd-user-agent, x-user-agent, user-agent |
| SMT_HDR_ACCEPT_LANGUAGE | string[] | x-fwd-accept-language, x-accept-language, accept-language |
| SMT_HDR_IP_ADDRESS | string[] | x-real-ip, x-client-ip, fastly-client-ip, true-client-ip, cf-connecting-ip, x-cluster-client-ip, x-forwarded-for |
Contents
- apiCommonConfig - API configuration
- context - context handler
- contextMiddleware - context middleware which parses headers
- errorResponseHandler - manages error responses
- HttpExceptionFilter - catches nest errors
Dependency Injection - NotFoundExceptionFilter - catches non-nest error
Dependency Injection - ErrorDto - error swagger document
- swaggerBuilder - manages swagger
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/api-common.git -b developmentDependencies
- base-common -
samet-digital - geoip-lite -
geoipfor locations from ip-address - ua-parser-js -
ua-parserfor browser info from user-agent
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-03 | Mustafa Yelmer | Created | ~~none~~ | | 2025-08-05 | Mustafa Yelmer | Refactored | ~~none~~ | | 2025-08-14 | Mustafa Yelmer | Documented | ~~none~~ |
