@heliyos/heliyos-api-core 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -104,17 +104,14 @@ Pre-configured Axios instances for internal services.
104
104
  import { axios } from "@heliyos/heliyos-api-core";
105
105
 
106
106
  // Available instances:
107
- await axios.auth_server.get("/endpoint");
108
- await axios.billing_server.post("/endpoint", data);
109
- await axios.event_server.put("/endpoint", data);
110
- await axios.notification_server.delete("/endpoint");
111
- await axios.user_server.patch("/endpoint", data);
107
+ await axios.authServer.get("/endpoint");
108
+ await axios.platformServer.post("/endpoint", data);
109
+ await axios.agentServer.put("/endpoint", data);
112
110
 
113
111
  // Required environment variables for each server:
114
112
  // BASE_URL_AUTH_SERVER + SECRET_OF_AUTH_SERVER
115
- // BASE_URL_BILLING_SERVER + SECRET_OF_BILLING_SERVER
116
- // BASE_URL_EVENT_API_SERVER + SECRET_OF_EVENT_API_SERVER
117
- // BASE_URL_NOTIFICATION_SERVER + SECRET_OF_NOTIFICATION_SERVER
113
+ // BASE_URL_PLATFORM_SERVER + SECRET_OF_PLATFORM_SERVER
114
+ // BASE_URL_AGENT_SERVER + SECRET_OF_AGENT_SERVER
118
115
  // BASE_URL_USERS_SERVER + SECRET_OF_USERS_SERVER
119
116
  ```
120
117
 
@@ -1,9 +1,7 @@
1
1
  import { AxiosInstance, AxiosStatic } from "axios";
2
2
  export interface AxiosServers {
3
- auth_server: AxiosInstance;
4
- billing_server: AxiosInstance;
5
- event_server: AxiosInstance;
6
- notification_server: AxiosInstance;
7
- user_server: AxiosInstance;
3
+ authServer: AxiosInstance;
4
+ agentServer: AxiosInstance;
5
+ platformServer: AxiosInstance;
8
6
  axios: AxiosStatic;
9
7
  }
@@ -253,7 +253,7 @@ const setLoggedInUser = function (container, req) {
253
253
  const callAuthApiServer = (token) => __awaiter(void 0, void 0, void 0, function* () {
254
254
  var _a, _b;
255
255
  try {
256
- const authResult = yield _1.axios.auth_server.post("/v1/auth/verify_token_v2", {
256
+ const authResult = yield _1.axios.authServer.post("/v1/auth/verify_token_v2", {
257
257
  token: token,
258
258
  });
259
259
  if ((_b = (_a = authResult.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.isValid) {
@@ -282,7 +282,7 @@ const verifyApiKey = (apiKey) => __awaiter(void 0, void 0, void 0, function* ()
282
282
  var _a, _b, _c, _d;
283
283
  try {
284
284
  // Call api key service to verify api key
285
- const apiRes = yield _1.axios.auth_server.post(`/v2/auth/api_key/verify`, {
285
+ const apiRes = yield _1.axios.authServer.post(`/v2/auth/api_key/verify`, {
286
286
  apiKey,
287
287
  });
288
288
  if ((_b = (_a = apiRes.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.isValid) {
@@ -22,7 +22,7 @@ const axios_1 = require("./axios");
22
22
  // eslint-disable-next-line import/prefer-default-export, @typescript-eslint/naming-convention
23
23
  const authorizeUser = (organizationId, userId, resourceAction) => __awaiter(void 0, void 0, void 0, function* () {
24
24
  try {
25
- const authenticationResponse = yield axios_1.coreAxios.auth_server.post(`v1/auth/user/${userId}`, { resourceAction, organizationId });
25
+ const authenticationResponse = yield axios_1.coreAxios.authServer.post(`v1/auth/user/${userId}`, { resourceAction, organizationId });
26
26
  return authenticationResponse.data.data;
27
27
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
28
28
  }
package/dist/axios.js CHANGED
@@ -52,29 +52,19 @@ const handleAxiosError = (err) => {
52
52
  // Axios server configs
53
53
  const servers = {
54
54
  // Auth server
55
- auth_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AUTH_SERVER, auth: {
56
- username: "",
55
+ authServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AUTH_SERVER, auth: {
56
+ username: "auth",
57
57
  password: process.env.SECRET_OF_AUTH_SERVER,
58
58
  } })),
59
- // Billing server
60
- billing_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_BILLING_SERVER, auth: {
61
- username: "",
62
- password: process.env.SECRET_OF_BILLING_SERVER,
59
+ // Agent server
60
+ agentServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_AGENT_SERVER, auth: {
61
+ username: "agent",
62
+ password: process.env.SECRET_OF_AGENT_SERVER,
63
63
  } })),
64
- // Events server
65
- event_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_EVENT_API_SERVER, auth: {
66
- username: "",
67
- password: process.env.SECRET_OF_EVENT_API_SERVER,
68
- } })),
69
- // Notifications server
70
- notification_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_NOTIFICATION_SERVER, auth: {
71
- username: "",
72
- password: process.env.SECRET_OF_NOTIFICATION_SERVER,
73
- } })),
74
- // Users server
75
- user_server: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_USERS_SERVER, auth: {
76
- username: "",
77
- password: process.env.SECRET_OF_USERS_SERVER,
64
+ // Platform server
65
+ platformServer: axios_1.default.create(Object.assign(Object.assign({}, config), { baseURL: process.env.BASE_URL_PLATFORM_SERVER, auth: {
66
+ username: "platform",
67
+ password: process.env.SECRET_OF_PLATFORM_SERVER,
78
68
  } })),
79
69
  // Export axios plain object to call some third party external calls
80
70
  axios: axios_1.default,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliyos/heliyos-api-core",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Heliyos's core api functions and middlewares. Its a private package hosted on npm.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {