Fix API authentication and identity service updates
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const collection = {
|
||||
info: {
|
||||
name: "Pharmacy Core API",
|
||||
description: "API collection for Pharmacy Core API",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
variable: [
|
||||
{
|
||||
key: "baseUrl",
|
||||
value: "http://localhost:8080",
|
||||
type: "string"
|
||||
},
|
||||
{
|
||||
key: "token",
|
||||
value: "",
|
||||
type: "string"
|
||||
}
|
||||
],
|
||||
auth: {
|
||||
type: "bearer",
|
||||
bearer: [
|
||||
{
|
||||
key: "token",
|
||||
value: "{{token}}",
|
||||
type: "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
item: []
|
||||
};
|
||||
|
||||
function createFolder(name, endpoints, prefix) {
|
||||
const items = endpoints.map(ep => {
|
||||
const method = ep.method.toUpperCase();
|
||||
const fullPath = (prefix + ep.path).replace(/\/$/, "");
|
||||
const urlParts = fullPath.split('/').filter(p => p !== '');
|
||||
|
||||
const request = {
|
||||
method: method,
|
||||
header: [],
|
||||
url: {
|
||||
raw: `{{baseUrl}}${fullPath}`,
|
||||
host: ["{{baseUrl}}"],
|
||||
path: urlParts
|
||||
}
|
||||
};
|
||||
|
||||
if (['POST', 'PUT', 'PATCH'].includes(method)) {
|
||||
request.body = {
|
||||
mode: "raw",
|
||||
raw: "{}",
|
||||
options: {
|
||||
raw: {
|
||||
language: "json"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
name: ep.name || `${method} ${ep.path}`,
|
||||
request: request
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
name: name,
|
||||
item: items
|
||||
};
|
||||
}
|
||||
|
||||
const modules = [
|
||||
{
|
||||
name: "Auth / Identity",
|
||||
prefix: "/v1/auth",
|
||||
endpoints: [
|
||||
{ method: "GET", path: "/me", name: "Get Current User" },
|
||||
{ method: "PUT", path: "/me", name: "Update Current User" },
|
||||
{ method: "POST", path: "/register", name: "Register" },
|
||||
{ method: "POST", path: "/login", name: "Login" },
|
||||
{ method: "POST", path: "/logout", name: "Logout" },
|
||||
{ method: "POST", path: "/token", name: "Refresh Token" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Catalogue",
|
||||
prefix: "/v1",
|
||||
endpoints: [
|
||||
{ method: "GET", path: "/drugs", name: "Get Drugs" },
|
||||
{ method: "POST", path: "/drugs", name: "Create Drug" },
|
||||
{ method: "GET", path: "/drugs/search", name: "Search Drugs" },
|
||||
{ method: "GET", path: "/products/:product_id/batches", name: "Get Product Batches" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Inventory",
|
||||
prefix: "/v1/inventory",
|
||||
endpoints: [
|
||||
{ method: "POST", path: "/grn", name: "Create GRN" },
|
||||
{ method: "GET", path: "/expiring", name: "Get Expiring Stock" },
|
||||
{ method: "GET", path: "/low-stock", name: "Get Low Stock" },
|
||||
{ method: "POST", path: "/adjustments", name: "Stock Adjustment" },
|
||||
{ method: "GET", path: "/recall/:batch_no", name: "Recall Batch" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Dispensing (Orders)",
|
||||
prefix: "/v1/orders",
|
||||
endpoints: [
|
||||
{ method: "GET", path: "/history", name: "Get Order History" },
|
||||
{ method: "GET", path: "/h1-register", name: "Get H1 Register" },
|
||||
{ method: "GET", path: "/:id/invoice/pdf", name: "Get Invoice PDF" },
|
||||
{ method: "POST", path: "/", name: "Create Order" },
|
||||
{ method: "PATCH", path: "/:id/items", name: "Update Order Items" },
|
||||
{ method: "POST", path: "/:id/precheck", name: "Precheck Order" },
|
||||
{ method: "POST", path: "/:id/dispense", name: "Dispense Order" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Audit",
|
||||
prefix: "/v1/audit",
|
||||
endpoints: [
|
||||
{ method: "GET", path: "/ai-calls", name: "Get AI Calls" },
|
||||
{ method: "GET", path: "/overrides", name: "Get Overrides" },
|
||||
{ method: "GET", path: "/h1-register", name: "Get H1 Register Audit" },
|
||||
{ method: "GET", path: "/sales-register", name: "Get Sales Register" },
|
||||
{ method: "GET", path: "/dashboard-metrics", name: "Get Dashboard Metrics" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Prescription",
|
||||
prefix: "/v1/rx",
|
||||
endpoints: [
|
||||
{ method: "POST", path: "/", name: "Upload Prescription" },
|
||||
{ method: "GET", path: "/", name: "Get Prescriptions" },
|
||||
{ method: "GET", path: "/:id", name: "Get Prescription by ID" },
|
||||
{ method: "POST", path: "/:id/confirm", name: "Confirm Prescription" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "AI",
|
||||
prefix: "/v1/ai",
|
||||
endpoints: [
|
||||
{ method: "POST", path: "/voice", name: "Voice AI" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Integration",
|
||||
prefix: "/v1/integration",
|
||||
endpoints: [
|
||||
{ method: "POST", path: "/hospital/patient-sync", name: "Sync Hospital Patient" },
|
||||
{ method: "GET", path: "/hospital/patients", name: "Get Hospital Patients" },
|
||||
{ method: "POST", path: "/telegaruda/prescription", name: "Receive Telegaruda Rx" },
|
||||
{ method: "GET", path: "/telegaruda/patient/:patientId", name: "Fetch Telegaruda Patient" },
|
||||
{ method: "GET", path: "/hospital/prescriptions", name: "Get Hospital Prescriptions" }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Upload",
|
||||
prefix: "/v1/upload",
|
||||
endpoints: [
|
||||
{ method: "POST", path: "/", name: "Upload File" },
|
||||
{ method: "GET", path: "/presigned", name: "Get Presigned URL" }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
modules.forEach(mod => {
|
||||
collection.item.push(createFolder(mod.name, mod.endpoints, mod.prefix));
|
||||
});
|
||||
|
||||
// Write to file
|
||||
fs.writeFileSync('postman_collection.json', JSON.stringify(collection, null, 2));
|
||||
console.log('Collection generated at postman_collection.json');
|
||||
Reference in New Issue
Block a user