@samet-it/be-api-common
v1.0.6
Published
API Common
Downloads
679
Readme
Samet IT : API Common
ts backend component
_
____ _____ (_) _________ ____ ___ ____ ___ ____ ____
/ __ `/ __ \/ / / ___/ __ \/ __ `__ \/ __ `__ \/ __ \/ __ \
/ /_/ / /_/ / / / /__/ /_/ / / / / / / / / / / / /_/ / / / /
\__,_/ .___/_/ \___/\____/_/ /_/ /_/_/ /_/ /_/\____/_/ /_/
/_/ EN: It should be used for service projectsTR: Tüm servis, entegrasyon vs projelerinde kullanılmalıdır
Prerequisite
- Help
- 1 - Install Git
- 2 - Build Up a Git Connection
- 3 - Install Node/NPM
- 4 - Create Project Folder
- 5 - Bind Projects Folder to Git
Usage
EN: How to add into your project?TR: Projene nasıl eklersin?
npm i @samet-it/be-api-commonEnvironments
| Name | Type | Default | Required | Secret | Description |
|-----------------------|----------|---------------------------------------|----------|--------|---------------------------------------|
| HTTP_PORT | integer | | | | Http port |
| SMT_ORGANIZATION | string | Samet Global | | | Organization name |
| DEF_LANGUAGE | string | tr | | | Default language code |
| DEF_COUNTRY | string | TR | | | Default country code |
| HDR_AUTHORIZATION | string[] | authorization, api-key | | | Headers - authorization keys |
| HDR_APPLICATION | string[] | x-application | | | Headers - application keys for mobile |
| HDR_CORRELATION_ID | string[] | x-correlation, ... | | | Headers - correlation id keys |
| HDR_REFERER | string[] | x-fwd-referer, ... | | | Headers - referer keys |
| HDR_USER_AGENT | string[] | x-fwd-user-agent, ... | | | Headers - user agent keys |
| HDR_ACCEPT_LANGUAGE | string[] | x-fwd-accept-language, ... | | | Headers - accept language keys |
| HDR_IP_ADDRESS | string[] | x-real-ip, ... | | | Headers - ip address keys |
| API_DOCS | string | docs | | | OpenAPI folder |
| API_HEALTH | string | healthz | | | Kubernetes health endpoint |
| API_STATUS | string | infra/status | | | Status endpoint |
| API_METRICS | string | infra/metrics | | | Prometheus metrics endpoint |
| GW_HOST | string | https://gateway.dev.sametglobal.com | | | Gateway host |
| PRJ_NAME | string | | | | Project name |
| PRJ_CONTEXT_PATH | string | | | | Project context path |
| PRJ_HOST | string | http://localhost:{HTTP_PORT} | | | Project host name |
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
Step 2
EN: Clone the projectTR: Projeyi bilgisiyarına çek
git clone https://github.com/samet-digital/be-api-common.git -b developmentDependencies
@samet-it/be-base-common: samet base common@leyyo/*: leyyo utilities@nestjs/*: nestjs frameworkgeoip-lite: locations from ip-addressua-parser-js: user agent info for client data, ie: browser, os, devicehelmet: header security checks
Commands
Standards
+ 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~~ | | 2026-01-10 | Mustafa Yelmer | Refactored | ~~none~~ |
