Initial commit

This commit is contained in:
2026-07-29 11:38:27 +05:30
commit a01a4c5d82
45 changed files with 6728 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
async function testAPI() {
console.log("1. Requesting Token for jayam_web_ai...");
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
grant_type: "client_credentials",
client_id: "jayam_web_ai",
client_secret: "my_secret_key"
})
});
const tokenData = await tokenResponse.json();
if (!tokenData.access_token) {
console.error("Failed to get token!", tokenData);
return;
}
console.log("✅ Successfully received real JWT token!");
console.log("Token:", tokenData.access_token.substring(0, 30) + "...\n");
console.log("2. Using Token to search for drugs (Catalogue API)...");
const searchResponse = await fetch("http://localhost:8080/v1/drugs/search?q=Losartan", {
method: "GET",
headers: {
"Authorization": `Bearer ${tokenData.access_token}`,
"X-Actor-Id": "usr_ph_1234"
}
});
const searchData = await searchResponse.json();
console.log(`✅ API Response Status: ${searchResponse.status}`);
console.log("Drug Search Results:");
console.log(JSON.stringify(searchData, null, 2));
}
testAPI();