forked from Shared/esg
documentation
This commit is contained in:
@@ -9,6 +9,7 @@ Complete API reference for the ESG Inquiry Gateway with request/response example
|
||||
- [Shahkar Inquiry](#shahkar-inquiry)
|
||||
- [Postal Code Inquiry](#postal-code-inquiry)
|
||||
- [Sheba Inquiry](#sheba-inquiry)
|
||||
- [Health and Diagnostic Checks](#health-and-diagnostic-checks)
|
||||
- [Error Responses](#error-responses)
|
||||
|
||||
## Base URL
|
||||
@@ -32,6 +33,83 @@ X-API-Key: your-api-key-here
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
|
||||
```
|
||||
|
||||
## Health and Diagnostic Checks
|
||||
|
||||
### Liveness and readiness
|
||||
|
||||
`GET /health/live` reports whether the process is responding. `GET /health/ready`
|
||||
checks PostgreSQL connectivity, heap usage, and disk usage. A failed readiness
|
||||
check returns HTTP `503`; both probes are intended for deployment monitoring and
|
||||
do not require a user JWT.
|
||||
|
||||
### Run one diagnostic inquiry
|
||||
|
||||
These administrative endpoints make a real request to the configured provider
|
||||
using the supplied sample payload. They require a JWT for a user with the
|
||||
`ADMIN` or `SUPER_ADMIN` role. Use the request body expected by the selected
|
||||
inquiry type. The report includes provider, duration, tracking code, attempt
|
||||
summary, and error details, but does not include the inquiry response data.
|
||||
|
||||
```http
|
||||
POST /health/inquiries/check
|
||||
Authorization: Bearer <accessToken>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"inquiryType": "SHAHKAR",
|
||||
"sampleData": {
|
||||
"nationalCode": "4311402422",
|
||||
"mobileNo": "09226187419"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The response reports `healthy: true` for a successful lookup or a valid no-match
|
||||
result. Provider or operational errors report `healthy: false`.
|
||||
|
||||
### Run a batch of diagnostic inquiries
|
||||
|
||||
Submit between 1 and 50 checks. They run sequentially in the background. The
|
||||
endpoint immediately returns a report with a `jobId`; poll that job to see
|
||||
progress and the final per-check results.
|
||||
|
||||
```http
|
||||
POST /health/inquiries/check/batch
|
||||
Authorization: Bearer <accessToken>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"caseId": "shahkar-row-1",
|
||||
"inquiryType": "SHAHKAR",
|
||||
"sampleData": {
|
||||
"nationalCode": "4311402422",
|
||||
"mobileNo": "09226187419"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The start request returns HTTP `202 Accepted`. Only one batch may be queued or
|
||||
running at a time; another start request receives `409 Conflict`. Batch state is
|
||||
held in process memory, and completed reports expire after one hour.
|
||||
|
||||
```http
|
||||
GET /health/inquiries/check/batch/{jobId}
|
||||
Authorization: Bearer <accessToken>
|
||||
```
|
||||
|
||||
The report contains `status` (`QUEUED`, `RUNNING`, `COMPLETED`, or `FAILED`),
|
||||
`totalChecks`, `completedChecks`, healthy/failed counts, a percentage, timestamps,
|
||||
and per-check outcomes (`SUCCESS`, `NO_MATCH`, or `FAILURE`). A missing or expired
|
||||
job returns `404 Not Found`.
|
||||
|
||||
## Person Inquiry
|
||||
|
||||
Query person information using national code and birth date.
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
This guide explains all environment variables used in the ESG Inquiry Gateway system.
|
||||
|
||||
All local settings are in `.local.env`, organized into shared settings, routing,
|
||||
AMITIS authentication, and sections for Asia, Hamta, Moallem, Parsian and Tejaratnou.
|
||||
Copy `.env.example` to `.local.env` for a new installation.
|
||||
|
||||
The app and CLI commands load the file from the project root. Shell/container
|
||||
variables override `.local.env`, which overrides `.env` as a legacy fallback.
|
||||
Split files under `env/` and `.env.local` are no longer loaded. Restart after changes.
|
||||
|
||||
Docker Compose uses the single `.production.env` file and does not mount `env/`.
|
||||
|
||||
## Table of Contents
|
||||
- [Application Settings](#application-settings)
|
||||
- [Database Configuration](#database-configuration)
|
||||
@@ -27,11 +37,15 @@ OTEL_NODE_RESOURCE_DETECTORS=env,host,os
|
||||
|
||||
## Database Configuration
|
||||
|
||||
### MongoDB
|
||||
### PostgreSQL
|
||||
```env
|
||||
MONGODB_URI=mongodb://localhost:27017/inquiry-gateway
|
||||
DATABASE_URL=postgresql://esg:esg@localhost:5432/inquiry_gateway
|
||||
```
|
||||
|
||||
The application, TypeORM data source, and readiness probe use PostgreSQL. Run
|
||||
pending TypeORM migrations with `npm run migration:run`; use
|
||||
`npm run migration:revert` to revert the most recent migration.
|
||||
|
||||
## Authentication & Security
|
||||
|
||||
### API Authentication
|
||||
@@ -458,7 +472,7 @@ REAL_ESTATE_FALLBACK_ENABLED=false
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
1. **Never commit `.env` to git** - Use `.env.example` as template
|
||||
1. **Never commit environment files containing secrets** - Use `.env.example` as template
|
||||
2. **Rotate credentials regularly** - Update passwords every 90 days
|
||||
3. **Use strong secrets** - Generate random strings for JWT secrets
|
||||
4. **Limit API key distribution** - One key per client application
|
||||
|
||||
Reference in New Issue
Block a user