node_connector_library
v1.0.1
Published
This Node.js library provides integration with the **ABDM Connector** for key functionalities like **M1**, **M2**, and **Scan & Share** workflows. It supports both **SQL-based databases** and **MongoDB** for flexible backend storage.
Downloads
10
Readme
Argusoft Node Gateway Library
This Node.js library provides integration with the ABDM Connector for key functionalities like M1, M2, and Scan & Share workflows. It supports both SQL-based databases and MongoDB for flexible backend storage.
📦 Installation
1. Install Gateway Library
To add The library run following command in your project:
npm install argusoft-node_gateway_library
## 🔧 Environment Setup
Create a `.env` file in your project root directory and add the following fields. These details will be provided by the **ABDM Connector**:
.env
CLIENT_ENVIRONMENT = (staging or prod) GATEWAY_CLIENT_ID = Your Cliend id GATEWAY_CLIENT_SECRET = Your Clinet Secret GATEWAY_USERNAME = Client username GATEWAY_PASSWORD = Client password
### 📌 Reference Image

---
## 🗄️ Database Integration for Scan and Share
This library supports both SQL-based databases and MongoDB for **Scan and Share** functionality.
### 🏗️ Table Creation
#### For SQL Databases (PostgreSQL Example)
> The provided SQL script is designed for **PostgreSQL**. If you're using **MySQL**, **SQL Server**, **Oracle**, or **MongoDB**, kindly adjust the script to fit your database syntax.
```sql
CREATE SCHEMA gateway;
CREATE TABLE gateway.abdm_scan_and_share_patient_registration (
id INT AUTO_INCREMENT PRIMARY KEY,
token_number INT,
created_on TIMESTAMP,
hfr_id VARCHAR(255),
custom_id VARCHAR(255),
patient_name VARCHAR(255),
patient_dob DATE,
patient_gender VARCHAR(50),
abha_address VARCHAR(50) NULL,
abha_number VARCHAR(50) NULL,
patient_address TEXT,
phone_number TEXT
);
CREATE TABLE gateway.abdm_token_details (
id INT AUTO_INCREMENT PRIMARY KEY,
hfr_id VARCHAR(255),
last_generated_token_number INT,
last_generated_token_date DATE,
counter_id VARCHAR(255)
);🛠️ Database Initialization
Before using Scan and Share features, initialize the database connection as shown below:
For MongoDB
await gatewayLibrary.dbConfig.initialize({
dbType: "mongodb",
dbConfig: {
uri: "mongodb://localhost:27017",
dbName: "gateway"
}
});For SQL Databases
(PostgreSQL, MySQL, SQL Server, Oracle)
await gatewayLibrary.dbConfig.initialize({
dbType: "postgres", // or "mysql", "oracle", "sqlserver"
dbConfig: {
host: "localhost",
user: "postgres",
database: "gateway",
password: "",
port: 5432, // specify appropriate port
}
});📦 Usage Examples
const gatewayLibrary = require('@argusoft/node_gateway_library');
// 🔍 M1 Usage Example
const result = await gatewayLibrary.m1Service.searchAbha({
mobileNumber: "8824827401",
benefitName: ""
});
// 🔗 M2 Usage Example
const result = await gatewayLibrary.m2Service.getRecordLinkingStatus(
"90902966-1fde-4bc2-a1fe-75f9d8645687"
);
// 📱 Scan and Share Example
const result = await gatewayLibrary.scanAndShareService.getQRCode(
"IN2410099120_1",
"842d61c9-8f24-4245-94ea-37c43ede781c",
"89289",
parseInt("900"),
parseInt("700")
);💡 Developer Tip
For all functions, clear parameter recommendations are provided via Type Safety and runtime validation. If incorrect or missing parameters are passed, the library will provide descriptive error messages to guide you.
