diff --git a/elevate-mentoring/constants/routes.js b/elevate-mentoring/constants/routes.js index 9e261bbf..958c12d9 100644 --- a/elevate-mentoring/constants/routes.js +++ b/elevate-mentoring/constants/routes.js @@ -863,36 +863,27 @@ module.exports = { }, }, { - sourceRoute: '/interface/v1/account/create', - type: 'POST', - inSequence: false, - orchestrated: true, - targetRoute: { - path: '/mentoring/v1/profile/create', - type: 'POST', - functionName: 'createProfile', - }, - }, - { - sourceRoute: '/interface/v1/account/update', + sourceRoute: '/interface/v1/entity-type/read', type: 'POST', inSequence: false, orchestrated: true, + service: 'mentoring', targetRoute: { - path: '/mentoring/v1/profile/update/', + path: '/mentoring/v1/entity-type/read', type: 'POST', - functionName: 'updateUser', + functionName: 'entityTypeRead', }, }, { - sourceRoute: '/interface/v1/entity-type/read', + sourceRoute: '/interface/v1/account/login', type: 'POST', - inSequence: false, + inSequence: true, + service: 'user', orchestrated: true, targetRoute: { - path: '/mentoring/v1/entity-type/read', + path: '/user/v1/account/login', type: 'POST', - functionName: 'entityTypeRead', + functionName: 'loginUser', }, }, { @@ -900,6 +891,7 @@ module.exports = { type: 'POST', inSequence: true, orchestrated: true, + service: 'mentoring', targetRoute: { path: '/mentoring/v1/role-permission-mapping/list', type: 'POST', @@ -1557,291 +1549,2078 @@ module.exports = { }, }, { - sourceRoute: '/interface/v1/mentors/details/:id', + sourceRoute: '/interface/v1/account/create', type: 'POST', inSequence: true, + service: 'user', orchestrated: true, targetRoute: { - path: '/mentoring/v1/mentors/details/:id', + path: '/user/v1/account/create', type: 'POST', - functionName: 'mentorDetails', + functionName: 'createUser', }, }, { - sourceRoute: '/interface/v1/profile/read', - type: 'GET', - inSequence: true, + sourceRoute: '/interface/v1/account/update', + type: 'PATCH', + inSequence: false, + service: 'user', orchestrated: true, targetRoute: { - path: '/mentoring/v1/profile/read', - type: 'GET', - functionName: 'mentoringProfile', + service: 'user', + path: '/user/v1/user/update', + type: 'POST', + functionName: 'updateUser', }, }, { - sourceRoute: '/mentoring/v1/reports/filterList', - type: 'GET', + sourceRoute: '/interface/v1/account/update', + type: 'POST', + inSequence: false, + orchestrated: true, + service: 'mentoring', targetRoute: { - path: '/mentoring/v1/reports/filterList ', - type: 'GET', + service: 'mentoring', + path: '/mentoring/v1/profile/update/', + type: 'POST', + functionName: 'updateUser', }, }, { - sourceRoute: '/mentoring/v1/connections/initiate', + sourceRoute: '/interface/user-signup', type: 'POST', + inSequence: true, + service: 'user', + orchestrated: true, targetRoute: { - path: '/mentoring/v1/connections/initiate', + path: '/user/v1/account/create', type: 'POST', + functionName: 'createUser', }, }, { - sourceRoute: '/mentoring/v1/connections/pending', - type: 'GET', + sourceRoute: '/interface/v1/entity-type/read', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: true, targetRoute: { - path: '/mentoring/v1/connections/pending', - type: 'GET', + path: '/user/v1/entity-type/read', + type: 'POST', + functionName: 'entityTypeRead', }, }, { - sourceRoute: '/mentoring/v1/connections/accept', + sourceRoute: '/user/v1/account/login', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/connections/accept', + path: '/user/v1/account/login', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/connections/reject', - type: 'POST', + sourceRoute: '/user/v1/account/acceptTermsAndCondition', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/connections/reject', - type: 'POST', + path: '/user/v1/account/acceptTermsAndCondition', + type: 'PATCH', }, }, { - sourceRoute: '/mentoring/v1/connections/getInfo', + sourceRoute: '/user/v1/account/resetPassword', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/connections/getInfo', + path: '/user/v1/account/resetPassword', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/connections/list', - type: 'GET', + sourceRoute: '/user/v1/account/generateToken', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/connections/list', - - type: 'GET', + path: '/user/v1/account/generateToken', + type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/reports/reportData', + sourceRoute: '/user/v1/account/generateOtp', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/reports/reportData ', + path: '/user/v1/account/generateOtp', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/reports/create', + sourceRoute: '/user/v1/account/logout', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/reports/create', + path: '/user/v1/account/logout', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/reports/read', - type: 'GET', + sourceRoute: '/user/v1/account/delete', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/reports/read', - type: 'GET', + path: '/user/v1/account/delete', + type: 'DELETE', }, }, { - sourceRoute: '/mentoring/v1/reports/update', + sourceRoute: '/user/v1/account/list', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/reports/update', + path: '/user/v1/account/list', type: 'POST', + functionName: 'accountsList', }, }, { - sourceRoute: '/mentoring/v1/reports/delete', - type: 'DELETE', + sourceRoute: '/user/v1/account/registrationOtp', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/reports/delete', - type: 'DELETE', + path: '/user/v1/account/registrationOtp', + type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/report-type/create', - type: 'POST', + sourceRoute: '/user/v1/user/read/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-type/create', - type: 'POST', + path: '/user/v1/user/read/:id', + type: 'GET', + functionName: 'readUser', }, }, { - sourceRoute: '/mentoring/v1/report-type/read', + sourceRoute: '/user/v1/user/read', type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-type/read', + path: '/user/v1/user/read', type: 'GET', + functionName: 'readUser', }, }, { - sourceRoute: '/mentoring/v1/report-type/update', - type: 'POST', + sourceRoute: '/user/v1/user/profileById/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-type/update', - type: 'POST', + path: '/user/v1/user/profileById/:id', + type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/report-type/delete', - type: 'DELETE', + sourceRoute: '/user/v1/user/profileById', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-type/delete', - type: 'DELETE', + path: '/user/v1/user/profileById', + type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/report-mapping/create', - type: 'POST', + sourceRoute: '/user/v1/user/update', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-mapping/create', - type: 'POST', + path: '/user/v1/user/update', + type: 'PATCH', }, }, { - sourceRoute: '/mentoring/v1/report-mapping/read', + sourceRoute: '/user/v1/user/setLanguagePreference', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/user/setLanguagePreference', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/user/share', type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-mapping/read', + path: '/user/v1/user/share', type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/report-mapping/update', - type: 'POST', + sourceRoute: '/user/v1/user/share/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-mapping/update', - type: 'POST', + path: '/user/v1/user/share/:id', + type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/report-mapping/delete', - type: 'DELETE', + sourceRoute: '/user/v1/user-role/list', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-mapping/delete', - type: 'DELETE', + path: '/user/v1/user-role/list', + type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/report-queries/create', + sourceRoute: '/user/v1/user-role/default', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/user-role/default', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/users/add', type: 'POST', + inSequence: false, + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-queries/create', + path: '/mentoring/v1/users/add', type: 'POST', + functionName: 'userAddEvent', }, }, { - sourceRoute: '/mentoring/v1/report-queries/read', - type: 'GET', + sourceRoute: '/user/v1/user-role/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-queries/read', - type: 'GET', + path: '/user/v1/user-role/create', + type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/report-queries/update', + sourceRoute: '/user/v1/user-role/update/:id', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-queries/update', + path: '/user/v1/user-role/update/:id', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/report-queries/delete', + sourceRoute: '/user/v1/user-role/delete/:id', type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/report-queries/delete', + path: '/user/v1/user-role/delete/:id', type: 'DELETE', }, }, { - sourceRoute: '/mentoring/v1/role-extension/create', + sourceRoute: '/user/v1/form/create', type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/role-extension/create', + path: '/user/v1/form/create', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/role-extension/read', - type: 'GET', + sourceRoute: '/user/v1/form/read', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/role-extension/read', - type: 'GET', + path: '/user/v1/form/read', + type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/role-extension/update', + sourceRoute: '/user/v1/form/read/:id', type: 'POST', + service: 'user', targetRoute: { - path: '/mentoring/v1/role-extension/update', + path: '/user/v1/form/read/:id', type: 'POST', }, }, { - sourceRoute: '/mentoring/v1/role-extensions/delete', - type: 'DELETE', + sourceRoute: '/user/v1/form/update', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/role-extension/delete', - type: 'DELETE', + path: '/user/v1/form/update', + type: 'PATCH', }, }, - { - sourceRoute: '/mentoring/v1/profile/getCommunicationToken', + { + sourceRoute: '/user/v1/cloud-services/file/getSignedUrl', type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/profile/getCommunicationToken', + path: '/user/v1/cloud-services/file/getSignedUrl', type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/profile/logout', - type: 'POST', + sourceRoute: '/user/v1/cloud-services/file/getDownloadableUrl', + type: 'GET', + service: 'user', targetRoute: { - path: '/mentoring/v1/profile/logout', - type: 'POST', + path: '/user/v1/cloud-services/file/getDownloadableUrl', + type: 'GET', }, }, { - sourceRoute: '/mentoring/v1/profile/details', - type: 'GET', + sourceRoute: '/user/v1/admin/deleteUser', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/profile/details', - type: 'GET', + path: '/user/v1/admin/deleteUser', + type: 'DELETE', }, }, { - sourceRoute: '/mentoring/v1/profile/details/:id', - type: 'GET', + sourceRoute: '/user/v1/admin/deleteUser/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, targetRoute: { - path: '/mentoring/v1/profile/details/:id', - type: 'GET', + path: '/user/v1/admin/deleteUser/:id', + type: 'DELETE', }, }, { - sourceRoute: "/mentoring/health", - type: "GET", - targetRoute: { - path: "/health", - type: "GET" - }, - }, + sourceRoute: '/user/v1/admin/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/admin/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/admin/login', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/admin/login', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/update', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/update', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization/update/:id', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/update/:id', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization/addRegistrationCode/:id', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/addRegistrationCode/:id', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization/addRegistrationCode', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/addRegistrationCode', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization/removeRegistrationCode/:id', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/removeRegistrationCode/:id', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization/removeRegistrationCode', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/removeRegistrationCode', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization/list', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/list', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/organization/list', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/list', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/details', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/details', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/organization/details/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/details/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/entity-type/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity-type/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/entity-type/update', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity-type/update', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/entity-type/update/:id', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity-type/update/:id', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/entity-type/read', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity-type/read', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/entity-type/delete', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity-type/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/entity-type/delete/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity-type/delete/:id', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/entity/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/entity/update', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity/update', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/entity/update/:id', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity/update/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/entity/delete/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity/delete/:id', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/entity/read', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity/read', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/entity/list', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/entity/list', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/inheritEntityType', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/inheritEntityType', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/read', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/organization/read', + type: 'GET', + functionName: 'readOrganization', + }, + }, + { + sourceRoute: '/user/v1/admin/addOrgAdmin', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/admin/addOrgAdmin', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/admin/assignRole', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/admin/assignRole', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/bulkUserCreate', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/bulkUserCreate', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/getBulkInvitesFilesList', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/getBulkInvitesFilesList', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/org-admin/getRequestDetails/:id', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/getRequestDetails/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/org-admin/deactivateUser', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/deactivateUser', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/getRequests', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/getRequests', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/updateRequestStatus', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/org-admin/updateRequestStatus', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/requestOrgRole', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/organization/requestOrgRole', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/admin/deactivateOrg/:id', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/admin/deactivateOrg/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/admin/executeRawQuery', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/admin/executeRawQuery', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/notification/create', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/notification/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/notification/update/:id', + type: 'PATCH', + service: 'user', + targetRoute: { + path: '/user/v1/notification/update/:id', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/notification/read/:id', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/notification/read/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/notification/read', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/notification/read', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/cloud-services/file/getSampleCSV', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/cloud-services/file/getSampleCSV', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/notification/template', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/notification/template', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/notification/template/:id', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/notification/template/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/notification/template', + type: 'GET', + service: 'user', + targetRoute: { + path: '/user/v1/notification/template', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/notification/template', + type: 'PATCH', + service: 'user', + targetRoute: { + path: '/user/v1/notification/template', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/account/search', + type: 'POST', + service: 'user', + targetRoute: { + path: '/user/v1/account/search', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/permissions/create', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/permissions/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/permissions/update/:id', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/permissions/update/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/permissions/list', + type: 'GET', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/permissions/list', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/permissions/delete/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/permissions/delete/:id', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/modules/create', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/modules/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/modules/update/:id', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/modules/update/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/modules/list', + type: 'GET', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/modules/list', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/modules/delete/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/modules/delete/:id', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/role-permission-mapping/delete/:role_id', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/role-permission-mapping/delete/:role_id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/role-permission-mapping/create/:role_id', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/role-permission-mapping/create/:role_id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/role-permission-mapping/list', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/role-permission-mapping/list', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/addRelatedOrg/:org_id', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/addRelatedOrg/:org_id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization/removeRelatedOrg/:org_id', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization/removeRelatedOrg/:org_id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/account/changePassword', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/account/changePassword', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/account/validatingEmailIds', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/account/validatingEmailIds', + type: 'POST', + functionName: 'validateEmails', + }, + }, + { + sourceRoute: '/user/v1/account/sessions', + type: 'GET', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/account/sessions', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/account/validateUserSession', + type: 'POST', + priority: 'MUST_HAVE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/account/validateUserSession', + type: 'POST', + }, + }, + { + sourceRoute: '/interface/v2/account/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v2/account/create', + type: 'POST', + }, + }, + + { + sourceRoute: '/user/v1/account/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/account/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/updateUser/:id', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/org-admin/updateUser/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/org-admin/updateUser', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/org-admin/updateUser', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/user/read', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/user/read', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/user/read/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/user/read/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/account/searchByEmailIds', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/account/searchByEmailIds', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/admin/triggerViewRebuild', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/admin/triggerViewRebuild', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/admin/triggerPeriodicViewRefresh', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/admin/triggerPeriodicViewRefresh', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/admin/triggerPeriodicViewRefreshInternal', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/admin/triggerPeriodicViewRefreshInternal', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/admin/triggerViewRebuildInternal', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/admin/triggerViewRebuildInternal', + type: 'GET', + }, + }, + { + sourceRoute: '/scheduler/jobs/create', + type: 'POST', + service: 'scheduler', + targetRoute: { + path: '/scheduler/jobs/create', + type: 'POST', + }, + }, + { + sourceRoute: '/scheduler/jobs/updateDelay', + type: 'POST', + service: 'scheduler', + targetRoute: { + path: '/scheduler/jobs/updateDelay', + type: 'POST', + }, + }, + { + sourceRoute: '/scheduler/jobs/remove', + type: 'POST', + service: 'scheduler', + targetRoute: { + path: '/scheduler/jobs/remove', + type: 'POST', + }, + }, + { + sourceRoute: '/scheduler/jobs/list', + type: 'GET', + service: 'scheduler', + targetRoute: { + path: '/scheduler/jobs/list', + type: 'GET', + }, + }, + { + sourceRoute: '/scheduler/jobs/purge', + type: 'POST', + service: 'scheduler', + targetRoute: { + path: '/scheduler/jobs/purge', + type: 'POST', + }, + }, + { + sourceRoute: '/notification/v1/email/send', + type: 'POST', + service: 'notification', + targetRoute: { + path: '/notification/v1/email/send', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/initiate', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/connections/initiate', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/pending', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/connections/pending', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/accept', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/connections/accept', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/reject', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/connections/reject', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/getInfo', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/connections/getInfo', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/checkConnection', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/connections/checkConnection', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/connections/list', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/connections/list', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/profile/externalIdMapping', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/profile/externalIdMapping', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/profile/getCommunicationToken', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/profile/getCommunicationToken', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/profile/logout', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/profile/logout', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/profile/details', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/profile/details', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/profile/details/:id', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/profile/details/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/interface/v1/mentors/details/:id', + type: 'POST', + inSequence: true, + orchestrated: true, + service: 'mentoring', + targetRoute: { + path: '/mentoring/v1/mentors/details/:id', + type: 'POST', + functionName: 'mentorDetails', + }, + }, + { + sourceRoute: '/interface/v1/profile/read', + type: 'GET', + inSequence: true, + orchestrated: true, + service: 'mentoring', + targetRoute: { + path: '/mentoring/v1/profile/read', + type: 'GET', + functionName: 'mentoringProfile', + }, + }, + { + sourceRoute: '/interface/v1/mentors/details/:id', + type: 'POST', + inSequence: true, + orchestrated: true, + service: 'user', + targetRoute: { + path: '/user/v1/user/read', + type: 'GET', + functionName: 'getUserDetailsFromExternal', + }, + }, + { + sourceRoute: '/interface/v1/profile/read', + type: 'GET', + inSequence: true, + orchestrated: true, + service: 'user', + targetRoute: { + path: '/user/v1/user/read', + type: 'GET', + functionName: 'userDetails', + }, + }, + { + sourceRoute: '/interface/v1/profile/details/:id', + type: 'POST', + inSequence: true, + orchestrated: true, + service: 'mentoring', + targetRoute: { + path: '/mentoring/v1/mentors/details/:id', + type: 'POST', + functionName: 'mentorDetails', + }, + }, + { + sourceRoute: '/interface/v1/profile/details/:id', + type: 'POST', + inSequence: true, + orchestrated: true, + service: 'mentoring', + targetRoute: { + path: '/mentoring/v1/mentors/details/:id', + type: 'POST', + functionName: 'mentorDetails', + }, + }, + { + sourceRoute: '/interface/v1/profile/get/:id', + type: 'POST', + inSequence: true, + orchestrated: true, + service: 'mentoring', + targetRoute: { + path: '/mentoring/v1/profile/details/:id', + type: 'POST', + functionName: 'mentorDetails', + }, + }, + { + sourceRoute: '/interface/v1/profile/get/:id', + type: 'POST', + inSequence: true, + orchestrated: true, + service: 'user', + targetRoute: { + path: '/user/v1/user/read', + type: 'POST', + functionName: 'getUserDetailsFromExternal', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/reportData', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/reports/reportData ', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/reports/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/reports/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/reports/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/reports/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/filterList', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/reports/filterList ', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-type/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/report-type/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-type/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/report-type/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-mapping/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/report-mapping/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-mapping/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/report-mapping/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-queries/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/report-queries/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-queries/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/report-queries/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extension/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/role-extension/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extension/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/role-extension/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extension/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/role-extension/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extensions/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/role-extension/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/requestSessions/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/requestSessions/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/requestSessions/list', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/requestSessions/list', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/requestSessions/getDetails', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/requestSessions/getDetails', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/requestSessions/userAvailability', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/requestSessions/userAvailability', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/requestSessions/accept', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/requestSessions/accept', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/requestSessions/reject', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/requestSessions/reject', + type: 'POST', + }, + }, + { + "sourceRoute": "/mentoring/v1/org-admin/themeDetails", + "type": "GET", + targetRoute: { + path: '/mentoring/v1/org-admin/themeDetails', + type: 'GET' + } + }, + { + "sourceRoute": "/mentoring/v1/org-admin/updateTheme", + "type": "POST", + targetRoute: { + path: '/mentoring/v1/org-admin/updateTheme', + type: 'POST' + } + }, + { + sourceRoute: '/user/v1/public/branding', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/public/branding', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/tenant/update', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/update', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/update/:id', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/update/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/bulkUserCreate', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/bulkUserCreate', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/addDomain', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/addDomain', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/addDomain/:id', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/addDomain/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/removeDomain', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/removeDomain', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/removeDomain/:id', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/removeDomain/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/tenant/read', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/read', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/tenant/read/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/read/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/tenant/readInternal', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/readInternal', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/tenant/readInternal/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/readInternal/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/tenant/list', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/tenant/list', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/resources/delete/:id', + type: 'GET', + inSequence: false, + service: 'mentoring', + orchestrated: false, + targetRoute: { + path: '/mentoring/v1/resources/delete/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/public/checkUsername', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/public/checkUsername', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/users/delete', + type: 'POST', + inSequence: false, + service: 'mentoring', + orchestrated: false, + targetRoute: { + path: '/mentoring/v1/users/delete', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/create', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/create', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/read', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/read', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/read/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/read/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/update', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/update', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/update/:id', + type: 'PATCH', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/update/:id', + type: 'PATCH', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/update', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/update', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/organization-feature/update/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/organization-feature/update/:id', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/feature/update', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/feature/update', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/feature/update/:id', + type: 'POST', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/feature/update/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/user/v1/feature/list', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/feature/list', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/feature/list/:id', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/feature/list/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/user/v1/feature/delete', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/feature/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/feature/delete/:id', + type: 'DELETE', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/feature/delete/:id', + type: 'DELETE', + }, + }, + { + sourceRoute: '/user/v1/public/userInvites', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/user/v1/public/userInvites', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/health', + type: 'GET', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/health', + type: 'GET', + }, + }, + { + sourceRoute: '/user/health', + type: 'GET', + inSequence: false, + service: 'user', + orchestrated: false, + targetRoute: { + path: '/health', + type: 'GET', + }, + }, + { + sourceRoute: '/scheduler/health', + type: 'GET', + service: 'scheduler', + targetRoute: { + path: '/health', + type: 'GET', + }, + }, + { + sourceRoute: '/interface/scheduler/health', + type: 'GET', + service: 'scheduler', + targetRoute: { + path: '/health', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/users/requestCount', + type: 'GET', + service: 'mentoring', + targetRoute: { + path: '/mentoring/v1/users/requestCount', + type: 'GET', + }, + } + ], } diff --git a/elevate-mentoring/controllers/customHandler.js b/elevate-mentoring/controllers/customHandler.js new file mode 100644 index 00000000..441b378a --- /dev/null +++ b/elevate-mentoring/controllers/customHandler.js @@ -0,0 +1,16 @@ +const routesConfig = require('../constants/routes') +const mentorController = require('./mentoring') + +const customHandler = async (req, res) => { + const selectedRouteConfig = routesConfig.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + + if(selectedRouteConfig && selectedRouteConfig.service){ + req['baseUrl'] = process.env[`${selectedRouteConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + return await mentorController[selectedRouteConfig.targetRoute.functionName](req, res, selectedRouteConfig) +} + +const customHandlerController = { + customHandler, +} +module.exports = customHandlerController \ No newline at end of file diff --git a/elevate-mentoring/controllers/mentoring.js b/elevate-mentoring/controllers/mentoring.js index bb23dc52..b41d9e20 100644 --- a/elevate-mentoring/controllers/mentoring.js +++ b/elevate-mentoring/controllers/mentoring.js @@ -1,16 +1,21 @@ const requesters = require('../utils/requester') const routeConfigs = require('../constants/routes') const requestParser = require('../utils/requestParser') +const {convertIdsToString} = require('../utils/integerToStringConverter') + const createProfile = async (req, res, responses) => { - const selectedConfig = routeConfigs.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) req.body.skipValidation = true + + console.log("--------- createProfile -------",req.headers); return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { - 'X-auth-token': `bearer ${responses.user.result.access_token}`, + 'origin': req.headers['origin'], + 'X-auth-token': `${responses.user.result.access_token}`, // override or add this header }) } const updateUser = async (req, res, responses) => { - const selectedConfig = routeConfigs.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) //const filteredRequestBody = requestParser.transformUpdateUserBody(req.body) console.log(req.baseUrl, selectedConfig.targetRoute.path, req.headers, req.body, 'mentoring request') @@ -18,21 +23,189 @@ const updateUser = async (req, res, responses) => { } const entityTypeRead = async (req, res, responses) => { - const selectedConfig = routeConfigs.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { 'X-auth-token': req.headers['x-auth-token'], }) } +const userAddEvent = async (req, res, responses) => { + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + const allowedEventTypes = ['bulk-create'] + if(allowedEventTypes.includes(req.body.eventType)){ + + req.body.organization_id = req.body.organizations[0].id + req.body.roles = req.body.organizations[0].roles.map((role) => { + return { + title : role.title + } + }) + + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { + 'internal_access_token': req.headers['internal_access_token'], + }) + } else { + // Return a resolved Promise with a success response + return Promise.resolve({ + success: true, + message: 'No Action taken.', + data: {}, + }); + } + +} + const rolePermissions = async (req, res, responses) => { - const selectedConfig = routeConfigs.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + console.log("selected config",selectedConfig); + + console.log("selected req.baseUrl",req.baseUrl); + + console.log("selected req.responses",JSON.stringify(responses)); + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path,req.body,{ - 'X-auth-token': `bearer ${responses.user.result.access_token}`, + 'X-auth-token': `${responses.user.result.access_token}`, }) } +const createUser = async (req, res, responses) => { + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + console.log("--------- createUser -------",req.headers); + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body,{ + 'origin': req.headers['origin'], + 'device-info': req.headers['device-info'], + }) +} + + +const loginUser = async (req, res, responses) => { + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + + let data = await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body,{ + 'captcha-token': req.headers['captcha-token'], + 'device-info': req.headers['device-info'], + }) + return data +} + +const readOrganization = async (req, res, selectedConfig) => { + try { + const parameterisedRoute = req.query.organisation_code ? selectedConfig.targetRoute.path + `?organisation_code=${req.query.organisation_code}` : selectedConfig.targetRoute.path + `?organisation_id=${req.query.organisation_id}` + let response = await requesters.get(req.baseUrl, parameterisedRoute , { + 'internal_access_token': req.headers['internal_access_token'], + 'Content-Type':'application/json' + }) + response.result = convertIdsToString(response.result) + return res.json(response) + } catch (error) { + console.error('Error fetching organization details:', error) + return res.status(500).json({ error: 'Internal Server Error' }) + } +} + +const readUser = async (req, res, selectedConfig) => { + try { + const parameterisedRoute = req.params.id ? selectedConfig.targetRoute.path.replace('/:id', `/${req.params.id}`) : selectedConfig.targetRoute.path; + let headers + + if (req.params.id) { + + if(req.headers['x-auth-token']){ + headers = { + 'Content-Type': 'application/json', + 'X-auth-token': req.headers['x-auth-token'], + } + } else { + headers = { + 'internal_access_token': req.headers['internal_access_token'], + 'Content-Type': 'application/json', + } + } + + } else { + headers = { + 'X-auth-token': req.headers['x-auth-token'], + 'Content-Type': 'application/json', + } + } + + let response = await requesters.get(req.baseUrl, parameterisedRoute, headers) + + + if(response && response.result){ + response.result = convertIdsToString(response.result) + return res.json(response) + } else { + + let data ={ + error: 'Internal Server Error' + } + + return res.status(response.status? response.status: 500).json(response.data ? response.data : data) + // return res.json(response); + } + + // Extract only the relevant data + + // return res.json(return) + } catch (error) { + console.error('Error fetching user details:', error); + return res.status(500).json({ error: 'Internal Server Error' }) + } + }; + + + const accountsList = async (req, res, selectedConfig) => { + try { + const userIds = req.body.userIds // Extract userIds from the request body + const excludeDeletedRecords = req.query.exclude_deleted_records === 'true' + + const parameterisedRoute = excludeDeletedRecords + ? `${selectedConfig.targetRoute.path}?exclude_deleted_records=true` + : selectedConfig.targetRoute.path + + const headers = { + 'internal_access_token': req.headers['internal_access_token'], + 'Content-Type': 'application/json', + } + + const requestBody = { userIds } // Pass the request body + const accountsListResponse = await requesters.get(req.baseUrl, parameterisedRoute, headers, requestBody) + + accountsListResponse.result = await convertIdsToString(accountsListResponse.result) + + return res.json(accountsListResponse) + } catch (error) { + console.error('Error fetching list of user details:', error); + return res.status(500).json({ error: 'Internal Server Error' }); + } +} + + +const validateEmails = async (req, res , selectedConfig) => { + try{ + const emailIds = req.body.emailIds + + const headers = { + 'internal_access_token': req.headers['internal_access_token'], + 'Content-Type': 'application/json', + } + + const requestBody = { emailIds } // Pass the request body + + const userListResponse = await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, requestBody, headers) + userListResponse.result = await convertIdsToString(userListResponse.result) + return res.json(userListResponse) + } catch (error) { + console.error('Error fetching user details by email :', error) + return res.status(500).json({ error: 'Internal Server Error' }) + } +} const mentorDetails = async (req, res, responses) => { - const selectedConfig = routeConfigs.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) const parameterisedRoute = req.params.id ? selectedConfig.targetRoute.path.replace('/:id', `/${req.params.id}`) : selectedConfig.targetRoute.path; let headers @@ -52,7 +225,7 @@ const mentorDetails = async (req, res, responses) => { } const mentoringProfile = async (req, res, responses) => { - const selectedConfig = routeConfigs.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) const parameterisedRoute = selectedConfig.targetRoute.path; let headers @@ -61,8 +234,59 @@ const mentoringProfile = async (req, res, responses) => { 'Content-Type': 'application/json', 'X-auth-token': req.headers['x-auth-token'], } + + console.error("------------------mentoringProfile ----------") let response = await requesters.get(req.baseUrl, parameterisedRoute,headers,{}) + console.error("------------------response in mentoring profile ----------",response) + return response + +} +const getUserDetailsFromExternal = async (req, res, responses) => { + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + let parameterisedRoute = selectedConfig.targetRoute.path; + + if(req.params.id){ + parameterisedRoute = parameterisedRoute+'/'+req.params.id; + } + let headers = { + 'Content-Type': 'application/json', + 'X-auth-token': req.headers['x-auth-token'], + } + + console.log("parameterisedRoute ---------------",parameterisedRoute); + + + let response = await requesters.get(req.baseUrl, parameterisedRoute,headers,{}) + return response + +} + +const userDetails = async (req, res, responses) => { + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + const parameterisedRoute = selectedConfig.targetRoute.path; + + console.error("============== cllaing user details") + let headers + if (req.params.id) { + headers = { + 'internal_access_token': req.headers['internal_access_token'], + 'Content-Type': 'application/json', + } + } else { + headers = { + 'Content-Type': 'application/json', + 'X-auth-token': req.headers['x-auth-token'], + } + } + console.log("parameterisedRoute API =========",parameterisedRoute); + console.error(" ----------- parameterisedRoute API =========",parameterisedRoute); + + + let response = await requesters.get(req.baseUrl, parameterisedRoute,headers,{}) + console.log(req.baseUrl,"parameterisedRoute API =========",response); return response } @@ -72,8 +296,19 @@ mentoringController = { updateUser, entityTypeRead, rolePermissions, + createUser, + updateUser, + entityTypeRead, + loginUser, + readOrganization, + readUser, + accountsList, + validateEmails, mentorDetails, - mentoringProfile + mentoringProfile, + userDetails, + getUserDetailsFromExternal, + userAddEvent } module.exports = mentoringController diff --git a/elevate-mentoring/controllers/orchestrationController.js b/elevate-mentoring/controllers/orchestrationController.js index 3135a021..fa19a997 100644 --- a/elevate-mentoring/controllers/orchestrationController.js +++ b/elevate-mentoring/controllers/orchestrationController.js @@ -1,9 +1,18 @@ const routesConfig = require('../constants/routes') const mentoringController = require('../controllers/mentoring') const orchestrationHandler = async (req, res, responses) => { - console.log(req.targetPackages, req.inSequence, req.orchestrated, req.sourceRoute, responses) + + console.log(req.service,req.targetPackages, req.inSequence, req.orchestrated, req.sourceRoute, responses) console.log(req.body) - const selectedRouteConfig = routesConfig.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + + const selectedRouteConfig = routesConfig.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + + console.log(" selectedRouteConfig ---------- ",selectedRouteConfig); + + if(selectedRouteConfig && selectedRouteConfig.service){ + req['baseUrl'] = process.env[`${selectedRouteConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } return await mentoringController[selectedRouteConfig.targetRoute.functionName](req, res, responses) } diff --git a/elevate-mentoring/helpers/dependencyManager.js b/elevate-mentoring/helpers/dependencyManager.js new file mode 100644 index 00000000..d2f97ec7 --- /dev/null +++ b/elevate-mentoring/helpers/dependencyManager.js @@ -0,0 +1,13 @@ +const kafkaManager = require('./kafkaManager') + +const dependencyManager = (dependencyMap, environmentVariables) =>{ + try{ + console.log("--------------- dependencyManager elevate-kafka-- "); + kafkaManager(dependencyMap.get('kafka'),environmentVariables) + }catch(error){ + console.log(error) + throw error + } +} + +module.exports = dependencyManager \ No newline at end of file diff --git a/elevate-mentoring/helpers/kafkaManager.js b/elevate-mentoring/helpers/kafkaManager.js new file mode 100644 index 00000000..d533fb5b --- /dev/null +++ b/elevate-mentoring/helpers/kafkaManager.js @@ -0,0 +1,75 @@ +const { post } = require('../utils/requester') + +const kafkaManager = async (kafkaPackage, environmentVariables) => { + try { + + const { ElevateKafka } = kafkaPackage + + const kafka = new ElevateKafka( + environmentVariables.ELEVATE_NOTIFICATION_KAFKA_BROKERS, + environmentVariables.ELEVATE_NOTIFICATION_KAFKA_BROKERS, + { + packageName: 'elevate-mentoring', + } + ) + + + const topics = [environmentVariables.ELEVATE_NOTIFICATION_KAFKA_TOPIC] + const consumer = await kafka.createConsumer(environmentVariables.ELEVATE_NOTIFICATION_KAFKA_GROUP_ID, topics) + await kafka.runConsumer(consumer, async (topic, message) => { + + if(process.env.DEBUG_MODE == "true"){ + console.log(topic," ------------- kafka-message ------",message) + } + + if (topic == environmentVariables.ELEVATE_NOTIFICATION_KAFKA_TOPIC) { + + if(process.env.DEBUG_MODE == "true"){ + console.log("-------------------- message",message.value); + } + const body = (JSON.parse(message.value)); + if(process.env.DEBUG_MODE == "true"){ + console.log("-------------------- body ",body); + } + if(body && body.type=="email"){ + try { + + const emailContent = body.email; + const to = emailContent.to.split(',') + const requestBody = { + email: { + to: to, + // email : emailContent.cc ? emailContent.cc.split(',') : null, + // sender: environmentVariables.SUNBIRD_NOTIFICATION_SENDER_EMAIL, + subject: emailContent.subject, + body: emailContent.body + } + } + + if(process.env.DEBUG_MODE == "true"){ + console.log("---------- API request",JSON.stringify(requestBody)); + } + + post( + environmentVariables.SAAS_NOTIFICATION_BASE_URL, + environmentVariables.SAAS_NOTIFICATION_SEND_EMAIL_ROUTE, + requestBody, + {} + ) + + } catch (error) { + console.log("------------- kafka-error --",error) + } + + } + + } + }) + } catch (error) { + console.log("=========== kfak-error ==========") + console.log(error) + throw error + } +} + +module.exports = kafkaManager diff --git a/elevate-mentoring/index.js b/elevate-mentoring/index.js index 2796c86f..8d245176 100644 --- a/elevate-mentoring/index.js +++ b/elevate-mentoring/index.js @@ -1,6 +1,7 @@ const express = require('express') const routes = require('./constants/routes') const packageRouter = require('./router') +const dependencyManager = require('./helpers/dependencyManager') const getDependencies = () => { return ['kafka', 'kafka-connect', 'redis'] @@ -12,6 +13,14 @@ const getPackageMeta = () => { packageName: 'elevate-mentoring', } } +const getRequiredDependencies = () => { + return [ + { + "packageName": 'elevate-mentoring', + "dependencies": [{ "name": "kafka" }] + } + ] +} const createPackage = (options) => { const { kafkaClient, redisClient } = options @@ -39,11 +48,41 @@ const createPackage = (options) => { router, } } +const kafkaPackageName = "MENTORING NOTIFICATION" + +const environmentVariablePrefix = "ELEVATE_NOTIFICATION"; +const requiredEnvs = { + [`${environmentVariablePrefix}_KAFKA_BROKERS`]: { + message: `[${kafkaPackageName}] Required Kafka Brokers Hosts`, + optional: false, + }, + [`${environmentVariablePrefix}_KAFKA_GROUP_ID`]: { + message: `[${kafkaPackageName}] Required Kafka Group ID`, + optional: false, + }, + [`${environmentVariablePrefix}_KAFKA_TOPIC`]: { + message: `[${kafkaPackageName}] Required Kafka Topics`, + optional: false, + }, + SAAS_NOTIFICATION_BASE_URL: { + message: `[${kafkaPackageName}] Saas Notification Service Base Required`, + optional: false, + }, + SAAS_NOTIFICATION_SEND_EMAIL_ROUTE: { + message: `[${kafkaPackageName}] Saas Notification Send Email Route Required`, + optional: false, + } +} module.exports = { dependencies: getDependencies(), routes, createPackage, + requiredEnvs, packageMeta: getPackageMeta(), packageRouter, + dependencyManager, + requiredDependencies:getRequiredDependencies } + + diff --git a/elevate-mentoring/package-lock.json b/elevate-mentoring/package-lock.json index 12d56c81..556d4be0 100644 --- a/elevate-mentoring/package-lock.json +++ b/elevate-mentoring/package-lock.json @@ -1,16 +1,18 @@ { "name": "elevate-mentoring", - "version": "1.0.13", + "version": "1.1.95257", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "elevate-mentoring", - "version": "1.0.13", + "version": "1.1.95257", "license": "ISC", "dependencies": { "axios": "^1.4.0", "express": "^4.18.2", + "lodash": "^4.17.21", + "node-fetch": "^2.7.0", "path-to-regexp": "^6.2.1" } }, @@ -393,6 +395,12 @@ "node": ">= 0.10" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "license": "MIT" + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -457,6 +465,26 @@ "node": ">= 0.6" } }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/object-inspect": { "version": "1.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", @@ -642,6 +670,12 @@ "node": ">=0.6" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -677,6 +711,22 @@ "engines": { "node": ">= 0.8" } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } } } } diff --git a/elevate-mentoring/package.json b/elevate-mentoring/package.json index ff378c14..8328c74c 100644 --- a/elevate-mentoring/package.json +++ b/elevate-mentoring/package.json @@ -1,6 +1,6 @@ { "name": "elevate-mentoring", - "version": "1.1.95257", + "version": "1.2.93", "description": "Npm package for Elevate-Mentoring service integration with Interface service. ", "main": "index.js", "scripts": { diff --git a/elevate-mentoring/router/index.js b/elevate-mentoring/router/index.js index a8b43a85..c2f4bc55 100644 --- a/elevate-mentoring/router/index.js +++ b/elevate-mentoring/router/index.js @@ -1,10 +1,15 @@ const { passThroughRequester } = require('../utils/requester') const { orchestrationHandler } = require('../controllers/orchestrationController') + +const { customHandler } = require('../controllers/customHandler') const packageRouter = async (req, res, responses) => { - const response = req.orchestrated - ? await orchestrationHandler(req, res, responses) - : await passThroughRequester(req, res) + let response + if (req.orchestrated) response = await orchestrationHandler(req, res, responses) + else if (req.requiresCustomHandling) { + response = await customHandler(req, res) + } else response = await passThroughRequester(req, res) return response } + module.exports = packageRouter diff --git a/elevate-mentoring/utils/integerToStringConverter.js b/elevate-mentoring/utils/integerToStringConverter.js new file mode 100644 index 00000000..6d6746a3 --- /dev/null +++ b/elevate-mentoring/utils/integerToStringConverter.js @@ -0,0 +1,37 @@ +const convertIdsToString = (obj) => { + // Check if the input is an array of integers + if (Array.isArray(obj) && obj.every(item => typeof item === 'number')) { + return obj.map(item => item.toString()) + } + + // If not an array or not all elements are numbers, proceed with the existing logic + if (typeof obj !== 'object' || obj === null) { + return obj + } + + if (Array.isArray(obj)) { + return obj.map(convertIdsToString) + } + + const relevantKeys = ['id', 'organization_id', 'related_orgs'] + const hasRelevantKeys = relevantKeys.some(key => key in obj) + + if (!hasRelevantKeys) { + return obj + } + + return Object.keys(obj).reduce((result, key) => { + if (relevantKeys.includes(key)) { + if (key === 'related_orgs' && Array.isArray(obj[key])) { + result[key] = obj[key].map(item => typeof item === 'number' ? item.toString() : item) + } else { + result[key] = typeof obj[key] === 'number' ? obj[key].toString() : obj[key] + } + } else { + result[key] = convertIdsToString(obj[key]) + } + return result + }, {}) + }; + + exports.convertIdsToString = convertIdsToString \ No newline at end of file diff --git a/elevate-mentoring/utils/requester.js b/elevate-mentoring/utils/requester.js index 55b2e027..9be9a765 100644 --- a/elevate-mentoring/utils/requester.js +++ b/elevate-mentoring/utils/requester.js @@ -18,6 +18,10 @@ const passThroughRequester = async (req, res) => { const sourceUrl = new URL(req.originalUrl, sourceBaseUrl) const route = routesConfig.routes.find((route) => route.sourceRoute === req.sourceRoute) + + if(route.service){ + req['baseUrl'] = process.env[`${route.service.toUpperCase()}_SERVICE_BASE_URL`] + } const params = matchPathsAndExtractParams(route.sourceRoute, req.originalUrl) const targetRoute = pathParamSetter(route.targetRoute.path, params) const parsedUrl = new URL(targetRoute, req.baseUrl) @@ -46,6 +50,7 @@ const passThroughRequester = async (req, res) => { }) req.pipe(proxyReq, { end: true }) } catch (err) { + console.log() handleInterfaceError(res, err) } } @@ -93,7 +98,8 @@ const patch = async (baseUrl, route, requestBody, headers) => { const get = (baseUrl, route, headers, requestBody = {}) => { const url = baseUrl + route const options = { - headers + headers, + data: requestBody }; return axios @@ -107,7 +113,6 @@ const get = (baseUrl, route, headers, requestBody = {}) => { return error }) } - const requesters = { passThroughRequester, post, diff --git a/elevate-project/constants/routes.js b/elevate-project/constants/routes.js index d7f527ee..0445028f 100644 --- a/elevate-project/constants/routes.js +++ b/elevate-project/constants/routes.js @@ -474,6 +474,17 @@ module.exports = { }, service: "project" }, + { + sourceRoute: "/project/v1/project/templates/createChildProjectTemplate", + type: "POST", + inSequence: false, + orchestrated: false, + targetRoute: { + path: "/project/v1/project/templates/createChildProjectTemplate", + type: "POST" + }, + service: "project" + }, { sourceRoute: "/project/v1/project/templates/bulkUpdate", type: "POST", @@ -705,6 +716,39 @@ module.exports = { }, service: "project" }, + { + sourceRoute: "/project/v1/programs/publishToLibrary", + type: "POST", + inSequence: false, + orchestrated: false, + targetRoute: { + path: "/project/v1/programs/publishToLibrary", + type: "POST" + }, + service: "project" + }, + { + sourceRoute: "/project/v1/programs/ProgramUpdateForLibrary", + type: "POST", + inSequence: false, + orchestrated: false, + targetRoute: { + path: "/project/v1/programs/ProgramUpdateForLibrary", + type: "POST" + }, + service: "project" + }, + { + sourceRoute: "/project/v1/programs/ProgramUpdateForLibrary/:id", + type: "POST", + inSequence: false, + orchestrated: false, + targetRoute: { + path: "/project/v1/programs/ProgramUpdateForLibrary/:id", + type: "POST" + }, + service: "project" + }, { sourceRoute: "/project/v1/programs/update", type: "POST", @@ -1079,6 +1123,28 @@ module.exports = { }, service: "project" }, + { + sourceRoute: "/project/v1/solutions/fetchLinkInternal", + type: "GET", + inSequence: false, + orchestrated: false, + targetRoute: { + path: "/project/v1/solutions/fetchLinkInternal", + type: "GET" + }, + service: "project" + }, + { + sourceRoute: "/project/v1/solutions/fetchLinkInternal/:id", + type: "GET", + inSequence: false, + orchestrated: false, + targetRoute: { + path: "/project/v1/solutions/fetchLinkInternal/:id", + type: "GET" + }, + service: "project" + }, { sourceRoute: "/project/v1/solutions/verifyLink", type: "POST", diff --git a/elevate-project/package.json b/elevate-project/package.json index 02c59b7c..0815b5fb 100644 --- a/elevate-project/package.json +++ b/elevate-project/package.json @@ -1,6 +1,6 @@ { "name": "elevate-project", - "version": "1.1.50", + "version": "1.1.52", "description": "Npm package for Elevate-Project service integration with Interface service", "main": "index.js", "scripts": { diff --git a/elevate-self-creation-portal/constants/routes.js b/elevate-self-creation-portal/constants/routes.js index 08016c70..1741ab2e 100644 --- a/elevate-self-creation-portal/constants/routes.js +++ b/elevate-self-creation-portal/constants/routes.js @@ -470,13 +470,13 @@ module.exports = { }, }, { - sourceRoute: '/scp/v1/role-permission-mapping/create/:role_id', + sourceRoute: '/scp/v1/role-permission-mapping/create', type: 'POST', priority: 'MUST_HAVE', inSequence: false, orchestrated: false, targetRoute: { - path: '/scp/v1/role-permission-mapping/create/:role_id', + path: '/scp/v1/role-permission-mapping/create', type: 'POST', }, }, @@ -802,5 +802,65 @@ module.exports = { }, service:"scp" }, + { + sourceRoute: '/scp/v1/resource/getDeepLink', + type: 'GET', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/scp/v1/resource/getDeepLink', + type: 'GET', + }, + }, + { + sourceRoute: '/scp/v1/projects/republish/:id', + type: 'POST', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/scp/v1/projects/republish/:id', + type: 'POST', + }, + }, + { + sourceRoute: '/scp/v1/targeting/hierarchy/:id', + type: 'GET', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/scp/v1/targeting/hierarchy/:id', + type: 'GET', + }, + }, + { + sourceRoute: '/scp/v1/targeting/subEntityList', + type: 'POST', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/scp/v1/targeting/subEntityList', + type: 'POST', + }, + }, + { + sourceRoute: '/scp/v1/config/createOrUpdate', + type: 'POST', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/scp/v1/config/createOrUpdate', + type: 'POST', + }, + }, + { + sourceRoute: '/scp/v1/config/updateRelatedOrgs', + type: 'POST', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/scp/v1/config/updateRelatedOrgs', + type: 'POST', + }, + }, ], } diff --git a/elevate-self-creation-portal/package.json b/elevate-self-creation-portal/package.json index 87996184..f7f23892 100644 --- a/elevate-self-creation-portal/package.json +++ b/elevate-self-creation-portal/package.json @@ -1,6 +1,6 @@ { "name": "elevate-self-creation-portal", - "version": "1.0.63", + "version": "1.0.69", "description": "Npm package for Elevate-self-creation-portal service integration with Interface service", "main": "index.js", "dependencies": { diff --git a/elevate-survey/constants/routes.js b/elevate-survey/constants/routes.js index 10a324af..403d626d 100644 --- a/elevate-survey/constants/routes.js +++ b/elevate-survey/constants/routes.js @@ -198,6 +198,28 @@ module.exports = { }, service:"survey" }, + { + sourceRoute: '/survey/v1/solutions/fetchLinkInternal', + type: 'GET', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/survey/v1/solutions/fetchLinkInternal', + type: 'GET' + }, + service:"survey" + }, + { + sourceRoute: '/survey/v1/solutions/fetchLinkInternal/:id', + type: 'GET', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/survey/v1/solutions/fetchLinkInternal/:id', + type: 'GET' + }, + service:"survey" + }, { sourceRoute: '/survey/v1/solutions/update', type: 'POST', @@ -418,6 +440,17 @@ module.exports = { }, service:"survey" }, + { + sourceRoute: '/survey/v1/programs/fetchProgramDetails', + type: 'POST', + inSequence: false, + orchestrated: false, + targetRoute: { + path: '/survey/v1/programs/fetchProgramDetails', + type: 'POST' + }, + service:"survey" + }, { sourceRoute: '/survey/v1/programs/addEntitiesInScope/:id', type: 'POST', @@ -2989,6 +3022,26 @@ module.exports = { }, service:"survey" }, + { + sourceRoute: "/survey/v1/admin/deleteSolutionResource", + type: "POST", + inSequence: false, + targetRoute: { + path: "/survey/v1/admin/deleteSolutionResource", + type: "POST" + }, + service: "survey" + }, + { + sourceRoute: "/survey/v1/admin/deleteSolutionResource/:id", + type: "POST", + inSequence: false, + targetRoute: { + path: "/survey/v1/admin/deleteSolutionResource/:id", + type: "POST" + }, + service: "survey" + }, { sourceRoute: "/survey/v1/admin/deleteResource", type: "POST", @@ -3130,6 +3183,16 @@ module.exports = { }, service: "survey" }, + { + sourceRoute: "/survey/v1/userExtension/mapUsersToPrograms", + type: "POST", + inSequence: false, + targetRoute: { + path: "/survey/v1/userExtension/mapUsersToPrograms", + type: "POST" + }, + service: "survey" + } ], } diff --git a/elevate-survey/package.json b/elevate-survey/package.json index 0426c2b8..908f212e 100644 --- a/elevate-survey/package.json +++ b/elevate-survey/package.json @@ -1,6 +1,6 @@ { "name": "elevate-survey-observation", - "version": "1.0.18", + "version": "1.0.22", "description": "Npm package for Elevate-survey-observation service integration with Interface service", "main": "index.js", "scripts": { diff --git a/health-check/index.js b/health-check/index.js index 91fc9caa..f444efdf 100644 --- a/health-check/index.js +++ b/health-check/index.js @@ -16,7 +16,7 @@ const httpService = require('./services/httpService') * @param {string} [currentServiceName=''] - Optional. Name of the current service to avoid self-check. * @returns {Promise} - A formatted response with health check results. */ -async function healthCheckHandler(config, basicCheck = false, currentServiceName = '') { +async function healthCheckHandler(config, basicCheck = false, currentServiceName = '', serviceVersion) { validateHealthConfig(config) const checks = [] @@ -102,7 +102,7 @@ async function healthCheckHandler(config, basicCheck = false, currentServiceName checks, } - return formatResponse(result) + return formatResponse(result,serviceVersion) } /** @@ -193,10 +193,10 @@ function validateHealthConfig(config) { * @param {Object} result - The object containing service name, version, healthy status, and checks. * @returns {Object} - The formatted response object. */ -function formatResponse(result) { +function formatResponse(result,serviceVersion) { return { id: 'service.health.api', - ver: '1.0', + version: serviceVersion, ts: new Date(), params: { resmsgid: uuidv1(), diff --git a/health-check/package.json b/health-check/package.json index e496d08e..72839545 100644 --- a/health-check/package.json +++ b/health-check/package.json @@ -1,6 +1,6 @@ { "name": "elevate-services-health-check", - "version": "0.0.5", + "version": "0.0.8", "description": "Package that can be used for service health check", "main": "index.js", "scripts": { diff --git a/health-check/services/kafka.js b/health-check/services/kafka.js index f1728ac7..b9c4e6c7 100644 --- a/health-check/services/kafka.js +++ b/health-check/services/kafka.js @@ -5,133 +5,156 @@ * Description : Kafka health check functionality (send + receive). */ -const kafka = require('kafka-node'); -const { v4: uuidv4 } = require('uuid'); +const kafka = require('kafka-node') +const { v4: uuidv4 } = require('uuid') -function ensureTopicExists(client, topicName) { +// Use environment variable or default to false +const DEBUG_MODE = process.env.HEALTH_CHECK_DEBUG_MODE === 'true' ? true : false + +/** + * Ensure the given Kafka topic exists or create it. + */ +async function ensureTopicExists(client, topicName) { return new Promise((resolve, reject) => { client.loadMetadataForTopics([], (error, results) => { if (error) { - console.error('[Kafka Health Check] Failed to load topic metadata:', error); - return reject(error); + if (DEBUG_MODE) { + console.error('[Kafka Health Check] Metadata load error:', error) + } + return reject(error) } - const topics = results[1]?.metadata || {}; - const existingTopics = Object.keys(topics); - - if (existingTopics.includes(topicName)) { - console.log(`[Kafka Health Check] Topic '${topicName}' already exists.`); - return resolve(); + const topics = results?.[1]?.metadata || {} + if (topics[topicName]) { + if (DEBUG_MODE) { + console.log(`[Kafka Health Check] Topic '${topicName}' exists ✅`) + } + return resolve(true) } - console.log(`[Kafka Health Check] Topic '${topicName}' not found. Creating...`); - client.createTopics( - [ - { - topic: topicName, - partitions: 1, - replicationFactor: 1, - }, - ], - (error, result) => { - if (error) { - console.error('[Kafka Health Check] Topic creation failed:', error); - return reject(error); - } - console.log('[Kafka Health Check] Topic created:', result); - resolve(); + if (DEBUG_MODE) { + console.log(`[Kafka Health Check] Topic '${topicName}' not found. Creating... ⏳`) + } + client.createTopics([{ topic: topicName, partitions: 1, replicationFactor: 1 }], (err) => { + if (err) return reject(err) + if (DEBUG_MODE) { + console.log(`[Kafka Health Check] Topic '${topicName}' created ✅`) } - ); - }); - }); + resolve(true) + }) + }) + }) } -async function check(kafkaUrl,topicName,groupId) { +/** + * Kafka health check + * @param {string} kafkaUrl Kafka bootstrap server + * @param {string} topicName Topic to check/create + * @param {string} groupId Consumer group (used if sendReceive=true) + * @param {boolean} sendReceive Optional: send and receive a message + */ +async function check(kafkaUrl, topicName, groupId, sendReceive = false) { return new Promise(async (resolve) => { - const pidSuffix = `-${process.pid}`; - const uniqueTopicName = `${topicName}${pidSuffix}`; - const uniqueGroupId = `${groupId}${pidSuffix}`; - console.log(`[Kafka Health Check] Connecting to Kafka at ${kafkaUrl}`); - const client = new kafka.KafkaClient({ kafkaHost: kafkaUrl }); - - try { - await ensureTopicExists(client, uniqueTopicName); - } catch (err) { - client.close(); - return resolve(false); + const pidSuffix = `-${process.pid}` + const uniqueTopicName = `${topicName}${pidSuffix}` + const uniqueGroupId = `${groupId}${pidSuffix}` + + let client + let producer + let consumer + let resolved = false + + const cleanup = (val) => { + if (resolved) return + resolved = true + try { + if (consumer) consumer.close(true) + if (client) client.close() + } catch (e) { + if (DEBUG_MODE) { + console.error('[Kafka Health Check] Cleanup error:', e.message) + } + } + resolve(val) } - const messageId = `health-check-${uuidv4()}`; - const payloads = [ - { - topic: uniqueTopicName, - messages: messageId, - }, - ]; - - const producer = new kafka.Producer(client); + try { + if (DEBUG_MODE) { + console.log(`[Kafka Health Check] Connecting to Kafka at ${kafkaUrl}`) + } + client = new kafka.KafkaClient({ kafkaHost: kafkaUrl }) - producer.on('ready', () => { - console.log(`[Kafka Health Check] Producer ready. Sending message: ${messageId}`); + // Step 1: Ensure topic exists + await ensureTopicExists(client, uniqueTopicName) - producer.send(payloads, (err, data) => { - if (err) { - console.error('[Kafka Health Check] Error sending message:', err); - client.close(); - return resolve(false); + if (!sendReceive) { + if (DEBUG_MODE) { + console.log('[Kafka Health Check] Topic check complete.') } + return cleanup(true) + } - console.log('[Kafka Health Check] Message sent:', data); - - const consumer = new kafka.Consumer( - client, - [{ topic: uniqueTopicName, partition: 0 }], - { - groupId: uniqueGroupId, - fromOffset: false, + // Step 2: Setup producer + producer = new kafka.Producer(client) + await new Promise((res, rej) => { + producer.on('ready', res) + producer.on('error', rej) + }) + + // Step 3: Send message + const messageId = `health-check-${uuidv4()}` + const payloads = [{ topic: uniqueTopicName, messages: messageId }] + await new Promise((res, rej) => { + producer.send(payloads, (err) => { + if (err) return rej(err) + if (DEBUG_MODE) { + console.log(`[Kafka Health Check] Sent message: ${messageId}`) } - ); - - const timeout = setTimeout(() => { - console.error('[Kafka Health Check] Timed out waiting for message'); - consumer.close(true, () => { - client.close(); - resolve(false); - }); - }, 10000); - - consumer.on('message', (message) => { - console.log('[Kafka Health Check] Received message:', message.value); - if (message.value === messageId) { - clearTimeout(timeout); - consumer.close(true, () => { - client.close(); - resolve(true); - }); + res() + }) + }) + + // Step 4: Setup consumer and receive + consumer = new kafka.Consumer(client, [{ topic: uniqueTopicName, partition: 0 }], { + groupId: uniqueGroupId, + autoCommit: true, + fromOffset: false, + }) + + let received = false + const receiveTimeout = setTimeout(() => { + if (!received) { + if (DEBUG_MODE) { + console.error('[Kafka Health Check] Message not received in time') } - }); - - consumer.on('error', (err) => { - console.error('[Kafka Health Check] Consumer error:', err); - clearTimeout(timeout); - consumer.close(true, () => { - client.close(); - resolve(false); - }); - }); - }); - }); - - producer.on('error', (err) => { - console.error('[Kafka Health Check] Producer error:', err); - client.close(); - return resolve(false); - }); - }); -} + cleanup(false) + } + }, 5000) -module.exports = { - check, -}; + consumer.on('message', (message) => { + if (message.value === messageId) { + clearTimeout(receiveTimeout) + if (DEBUG_MODE) { + console.log('[Kafka Health Check] Message received') + } + cleanup(true) + } + }) + consumer.on('error', (err) => { + if (DEBUG_MODE) { + console.error('[Kafka Health Check] Consumer error:', err.message) + } + clearTimeout(receiveTimeout) + cleanup(false) + }) + } catch (err) { + if (DEBUG_MODE) { + console.error('[Kafka Health Check] Health check failed:', err.message) + } + cleanup(false) + } + }) +} +module.exports = { check } diff --git a/interface-routes/elevate-qa-routes.json b/interface-routes/elevate-qa-routes.json index 701e789c..bc6d49d2 100644 --- a/interface-routes/elevate-qa-routes.json +++ b/interface-routes/elevate-qa-routes.json @@ -3477,6 +3477,19 @@ } ] }, + { + "sourceRoute": "/mentoring/v1/connections/checkConnection", + "type": "POST", + "priority": "MUST_HAVE", + "inSequence": false, + "orchestrated": false, + "targetPackages": [ + { + "basePackageName": "mentoring", + "packageName": "elevate-mentoring" + } + ] + }, { "sourceRoute": "/mentoring/v1/profile/externalIdMapping", "type": "POST", @@ -11531,23 +11544,8 @@ "targetField": "user.user_updated_at" } ] - }, - { - "service": "mentoring", - "basePackageName": "mentoring", - "packageName": "elevate-mentoring", - "targetBody": [], - "responseBody": [ - { - "sourceField": "created_at", - "targetField": "profile_created_at" - }, - { - "sourceField": "updated_at", - "targetField": "profile_updated_at" - } - ] } + ] }, { @@ -11606,6 +11604,7 @@ } ] } + ] }, { @@ -12660,4 +12659,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/interface-routes/elevate-routes.json b/interface-routes/elevate-routes.json index 853a26cb..4955e5bd 100644 --- a/interface-routes/elevate-routes.json +++ b/interface-routes/elevate-routes.json @@ -11696,22 +11696,6 @@ "targetField": "user.user_updated_at" } ] - }, - { - "service": "mentoring", - "basePackageName": "mentoring", - "packageName": "elevate-mentoring", - "targetBody": [], - "responseBody": [ - { - "sourceField": "created_at", - "targetField": "profile_created_at" - }, - { - "sourceField": "updated_at", - "targetField": "profile_updated_at" - } - ] } ] }, @@ -14229,6 +14213,19 @@ "packageName": "elevate-self-creation-portal" } ] + }, + { + "sourceRoute": "/mentoring/v1/connections/checkConnection", + "type": "POST", + "priority": "MUST_HAVE", + "inSequence": false, + "orchestrated": false, + "targetPackages": [ + { + "basePackageName": "mentoring", + "packageName": "elevate-mentoring" + } + ] } ] -} \ No newline at end of file +} diff --git a/sunbird-mentoring/constants/routes.js b/sunbird-mentoring/constants/routes.js index fc00b30a..16b4ccc5 100644 --- a/sunbird-mentoring/constants/routes.js +++ b/sunbird-mentoring/constants/routes.js @@ -867,6 +867,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: true, + service:"mentoring", targetRoute: { path: '/mentoring/v1/profile/create', type: 'POST', @@ -878,6 +879,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: true, + service:"mentoring", targetRoute: { path: '/mentoring/v1/entity-type/read', type: 'POST', @@ -889,6 +891,7 @@ module.exports = { type: 'POST', inSequence: true, orchestrated: true, + service:"mentoring", targetRoute: { path: '/mentoring/v1/role-permission-mapping/list', type: 'POST', @@ -900,6 +903,7 @@ module.exports = { type: 'POST', inSequence: true, orchestrated: true, + service:"mentoring", targetRoute: { paths: [ { path: '/mentoring/v1/users/create', type: 'POST' }, @@ -1509,6 +1513,7 @@ module.exports = { type: 'POST', inSequence: true, orchestrated: true, + service:"user", targetRoute: { path: '/user/v1/account/create', type: 'POST', @@ -1520,6 +1525,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: true, + service:"user", targetRoute: { path: '/user/v1/entity-type/read', type: 'POST', @@ -1531,6 +1537,7 @@ module.exports = { type: 'POST', inSequence: true, orchestrated: true, + service:"user", targetRoute: { path: '/user/v1/account/login', type: 'POST', @@ -1542,6 +1549,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/account/login', type: 'POST', @@ -1552,6 +1560,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/account/acceptTermsAndCondition', type: 'PATCH', @@ -1562,6 +1571,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/account/resetPassword', type: 'POST', @@ -1572,6 +1582,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/account/generateToken', type: 'POST', @@ -1582,6 +1593,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/account/logout', type: 'POST', @@ -1592,6 +1604,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/private/user/v1/search', type: 'POST', @@ -1603,6 +1616,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { paths: [ { path: '/private/user/v1/read/:id', type: 'GET' }, @@ -1620,6 +1634,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { paths: [ { @@ -1640,6 +1655,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user/update', type: 'PATCH', @@ -1650,6 +1666,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user/share', type: 'GET', @@ -1660,6 +1677,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user/share/:id', type: 'GET', @@ -1670,6 +1688,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user-role/list', type: 'GET', @@ -1680,6 +1699,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user-role/default', type: 'GET', @@ -1690,6 +1710,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user-role/create', type: 'POST', @@ -1700,6 +1721,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user-role/update/:id', type: 'POST', @@ -1710,6 +1732,7 @@ module.exports = { type: 'DELETE', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/user-role/delete/:id', type: 'DELETE', @@ -1720,6 +1743,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/form/create', type: 'POST', @@ -1730,6 +1754,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/form/read', type: 'POST', @@ -1738,6 +1763,7 @@ module.exports = { { sourceRoute: '/user/v1/form/read/:id', type: 'POST', + service: "user", targetRoute: { path: '/user/v1/form/read/:id', type: 'POST', @@ -1748,6 +1774,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/form/update', type: 'PATCH', @@ -1758,6 +1785,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/cloud-services/file/getSignedUrl', type: 'GET', @@ -1766,6 +1794,7 @@ module.exports = { { sourceRoute: '/user/v1/cloud-services/file/getDownloadableUrl', type: 'GET', + service: "user", targetRoute: { path: '/user/v1/cloud-services/file/getDownloadableUrl', type: 'GET', @@ -1776,6 +1805,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/organization/create', type: 'POST', @@ -1786,6 +1816,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/organization/update', type: 'PATCH', @@ -1795,6 +1826,7 @@ module.exports = { sourceRoute: '/user/v1/organization/update/:id', type: 'PATCH', inSequence: false, + service: "user", orchestrated: false, targetRoute: { path: '/user/v1/organization/update/:id', @@ -1806,6 +1838,7 @@ module.exports = { type: 'GET', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/v1/org/search', type: 'GET', @@ -1817,6 +1850,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity-type/create', type: 'POST', @@ -1827,6 +1861,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity-type/update', type: 'PATCH', @@ -1837,6 +1872,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity-type/update/:id', type: 'PATCH', @@ -1847,6 +1883,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity-type/read', type: 'POST', @@ -1857,6 +1894,7 @@ module.exports = { type: 'DELETE', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity-type/delete', type: 'DELETE', @@ -1867,6 +1905,7 @@ module.exports = { type: 'DELETE', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity-type/delete/:id', type: 'DELETE', @@ -1877,6 +1916,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity/create', type: 'POST', @@ -1887,6 +1927,7 @@ module.exports = { type: 'PATCH', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity/update', type: 'PATCH', @@ -1897,6 +1938,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity/update/:id', type: 'POST', @@ -1907,6 +1949,7 @@ module.exports = { type: 'DELETE', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity/delete/:id', type: 'DELETE', @@ -1917,6 +1960,7 @@ module.exports = { type: 'POST', inSequence: false, orchestrated: false, + service: "user", targetRoute: { path: '/user/v1/entity/read', type: 'POST', @@ -1925,6 +1969,7 @@ module.exports = { { sourceRoute: '/user/v1/org-admin/inheritEntityType', type: 'POST', + service: "user", targetRoute: { path: '/user/v1/org-admin/inheritEntityType', type: 'POST', @@ -1933,6 +1978,7 @@ module.exports = { { sourceRoute: '/user/v1/organization/read', type: 'GET', + service: "user", targetRoute: { path: '/v1/org/read', type: 'POST', @@ -1942,6 +1988,7 @@ module.exports = { { sourceRoute: '/user/v1/admin/addOrgAdmin', type: 'POST', + service: "user", targetRoute: { path: '/user/v1/admin/addOrgAdmin', type: 'POST', @@ -1950,6 +1997,7 @@ module.exports = { { sourceRoute: '/user/v1/org-admin/bulkUserCreate', type: 'POST', + service: "user", targetRoute: { path: '/user/v1/org-admin/bulkUserCreate', type: 'POST', @@ -1958,6 +2006,7 @@ module.exports = { { sourceRoute: '/user/v1/org-admin/getBulkInvitesFilesList', type: 'GET', + service: "user", targetRoute: { path: '/user/v1/org-admin/getBulkInvitesFilesList', type: 'GET', @@ -1966,6 +2015,7 @@ module.exports = { { sourceRoute: '/user/v1/notification/read', type: 'GET', + service: "user", targetRoute: { path: '/user/v1/notification/read', type: 'GET', @@ -1974,6 +2024,7 @@ module.exports = { { sourceRoute: '/user/v1/account/search', type: 'POST', + service: "user", targetRoute: { path: '/user/v1/account/search', type: 'POST', @@ -1982,6 +2033,7 @@ module.exports = { { sourceRoute: '/user/v1/permissions/list', type: 'GET', + service: "user", priority: 'MUST_HAVE', inSequence: false, orchestrated: false, @@ -1993,6 +2045,7 @@ module.exports = { { sourceRoute: '/user/v1/account/validatingEmailIds', type: 'POST', + service: "user", inSequence: false, orchestrated: false, targetRoute: { @@ -2002,6 +2055,7 @@ module.exports = { { sourceRoute: '/user/v1/account/sessions', type: 'GET', + service: "user", priority: 'MUST_HAVE', inSequence: false, orchestrated: false, @@ -2014,6 +2068,7 @@ module.exports = { sourceRoute: '/user/v1/account/validateUserSession', type: 'POST', priority: 'MUST_HAVE', + service: "user", inSequence: false, orchestrated: false, targetRoute: { @@ -2044,6 +2099,7 @@ module.exports = { { sourceRoute: '/scheduler/jobs/create', type: 'POST', + service: "scheduler", targetRoute: { path: '/scheduler/jobs/create', type: 'POST', @@ -2052,6 +2108,7 @@ module.exports = { { sourceRoute: '/scheduler/jobs/updateDelay', type: 'POST', + service: "scheduler", targetRoute: { path: '/scheduler/jobs/updateDelay', type: 'POST', @@ -2060,6 +2117,7 @@ module.exports = { { sourceRoute: '/scheduler/jobs/remove', type: 'POST', + service: "scheduler", targetRoute: { path: '/scheduler/jobs/remove', type: 'POST', @@ -2068,6 +2126,7 @@ module.exports = { { sourceRoute: '/scheduler/jobs/list', type: 'GET', + service: "scheduler", targetRoute: { path: '/scheduler/jobs/list', type: 'GET', @@ -2076,10 +2135,201 @@ module.exports = { { sourceRoute: '/scheduler/jobs/purge', type: 'POST', + service: "scheduler", targetRoute: { path: '/scheduler/jobs/purge', type: 'POST', }, + }, + { + sourceRoute: '/interface/v1/mentors/details/:id', + type: 'GET', + priority: 'MUST_HAVE', + inSequence: false, + orchestrated: false, + service:"mentoring", + targetRoute: { + path: '/mentoring/v1/mentors/details/:id', + type: 'GET', + functionName:'mentorDetails' + + }, + }, + { + sourceRoute: '/mentoring/v1/reports/reportData', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/reports/reportData ', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/reports/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/reports/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/reports/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/reports/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-type/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/report-type/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-type/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-type/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/report-type/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-mapping/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/report-mapping/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-mapping/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-mapping/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/report-mapping/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-queries/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/report-queries/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/report-queries/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/report-queries/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/report-queries/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extension/create', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/role-extension/create', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extension/read', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/role-extension/read', + type: 'GET', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extension/update', + type: 'POST', + targetRoute: { + path: '/mentoring/v1/role-extension/update', + type: 'POST', + }, + }, + { + sourceRoute: '/mentoring/v1/role-extensions/delete', + type: 'DELETE', + targetRoute: { + path: '/mentoring/v1/role-extension/delete', + type: 'DELETE', + }, + }, + { + sourceRoute: '/mentoring/v1/reports/filterList', + type: 'GET', + targetRoute: { + path: '/mentoring/v1/reports/filterList ', + type: 'GET', + }, } ], } diff --git a/sunbird-mentoring/controllers/customHandler.js b/sunbird-mentoring/controllers/customHandler.js index 22421532..d40e465f 100644 --- a/sunbird-mentoring/controllers/customHandler.js +++ b/sunbird-mentoring/controllers/customHandler.js @@ -3,6 +3,9 @@ const mentoringController = require('../controllers/mentoring') const customHandler = async (req, res) => { const selectedRouteConfig = routesConfig.routes.find((obj) => obj.sourceRoute === req.sourceRoute) + if(selectedRouteConfig.service){ + req['baseUrl'] = process.env[`${selectedRouteConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } return await mentoringController[selectedRouteConfig.targetRoute.functionName](req, res, selectedRouteConfig) } diff --git a/sunbird-mentoring/controllers/mentoring.js b/sunbird-mentoring/controllers/mentoring.js index d2359478..b132c5b3 100644 --- a/sunbird-mentoring/controllers/mentoring.js +++ b/sunbird-mentoring/controllers/mentoring.js @@ -3,6 +3,11 @@ const routeConfigs = require('../constants/routes.js') const requestParser = require('../utils/requestParser') const createProfile = async (req, res, responses, selectedConfig) => { + + await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { + 'X-auth-token': `bearer ${responses.user.result.access_token}`, + }) + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { 'X-auth-token': `bearer ${responses.user.result.access_token}`, }) @@ -15,35 +20,62 @@ const createProfile = async (req, res, responses, selectedConfig) => { // 'X-auth-token': req.headers['x-auth-token'], // }) -const rolePermissions = async (req, res, responses, selectedConfig) => +const rolePermissions = async (req, res, responses, selectedConfig) =>{ + + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { 'X-auth-token': `bearer ${responses.user.result.access_token}`, }) +} + const profileRead = async (req, res, selectedConfig) => { try { const targetRoute1 = selectedConfig.targetRoute.paths[0].path const targetRoute2 = selectedConfig.targetRoute.paths[1].path - const userCreateResponse = await requesters.post(req.baseUrl, targetRoute1, {}, req.headers) - + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + + const mentoringResponse = await requesters.get(req.baseUrl, targetRoute2, { + 'x-authenticated-user-token': req.headers['x-authenticated-user-token'], + }) if(process.env.DEBUG_MODE == "true"){ - - console.log("userCreateResponse api respo",userCreateResponse); - console.log("profileRead create json",JSON.stringify(userCreateResponse)); + + console.log("mentoringResponse api respo",mentoringResponse); + console.log("mentoringResponse read json",JSON.stringify(mentoringResponse)); } - if (userCreateResponse.responseCode == 'OK') { - const mentoringResponse = await requesters.get(req.baseUrl, targetRoute2, { - 'x-authenticated-user-token': req.headers['x-authenticated-user-token'], - }) + if(mentoringResponse && mentoringResponse.result['user_id']){ + + console.log("mentoringResponse return userId",mentoringResponse.result['user_id']); + + mentoringResponse.result['id'] = mentoringResponse.result?.user_id; res.json(mentoringResponse) + } else { - if(process.env.DEBUG_MODE == "true"){ - console.log("profileRead error create",JSON.stringify(userCreateResponse)); - } - res.json(userCreateResponse) - + const userCreateResponse = await requesters.post(req.baseUrl, targetRoute1, {}, req.headers) + if(process.env.DEBUG_MODE == "true"){ + + console.log("userCreateResponse api respo",userCreateResponse); + console.log("profileRead create json",JSON.stringify(userCreateResponse)); + } + if (userCreateResponse.responseCode == 'OK') { + let profleResponse = await requesters.get(req.baseUrl, targetRoute2, { + 'x-authenticated-user-token': req.headers['x-authenticated-user-token'], + }) + profleResponse.result['id'] = userCreateResponse.result?.user_id; + res.json(profleResponse) + } else { + + if(process.env.DEBUG_MODE == "true"){ + console.log("profileRead error create",JSON.stringify(userCreateResponse)); + } + res.json(userCreateResponse) + } } } catch (error) { @@ -55,18 +87,32 @@ const profileRead = async (req, res, selectedConfig) => { } const createUser = async (req, res, responses, selectedConfig) => { + + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { 'device-info': req.headers['device-info'], }) } const entityTypeRead = async (req, res, responses, selectedConfig) => { + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { 'X-auth-token': req.headers['x-auth-token'], }) } const loginUser = async (req, res, responses, selectedConfig) => { + + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + return await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, req.body, { 'captcha-token': req.headers['captcha-token'], 'device-info': req.headers['device-info'], @@ -74,12 +120,18 @@ const loginUser = async (req, res, responses, selectedConfig) => { } const readOrganization = async (req, res, selectedConfig) => { + + console.log("------- org read config -------",selectedConfig); const body = { request: { organisationId: req.query.organisation_id || req.query.organisation_code, }, } try { + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + const response = await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, body, { 'device-info': req.headers['device-info'], }) @@ -153,9 +205,17 @@ const readUserById = async (req, res, selectedConfig) => { const userId = req.params.id try { console.log('read by userid'); - const targetRoute1 = selectedConfig.targetRoute.paths[0].path + let targetRoute1 = selectedConfig.targetRoute.paths[0].path const targetRoute2 = selectedConfig.targetRoute.paths[1] + + targetRoute1 = req.params.id ? targetRoute1.replace('/:id', `/${req.params.id}`) : targetRoute1; + + console.log("-------------- targetRoute1 -------",targetRoute1); + + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } const userResponse = await requesters.get(req.baseUrl, targetRoute1, req.headers, { id: userId, }) @@ -192,6 +252,8 @@ const readUserById = async (req, res, selectedConfig) => { console.log("userResponse profile response ",userResponse); } const responseData = processUserResponse(userResponse) + + console.log("responseDataresponseDataresponseDataresponseData responseData -------",responseData); responseData.result.competency = competencyIds if(process.env.DEBUG_MODE == "true"){ @@ -211,7 +273,7 @@ const readUserWithToken = async (req, res, selectedConfig) => { try { if(process.env.DEBUG_MODE == "true"){ - console.log("================== readUserWithToken =======") + console.log("================== readUserWithToken =======") } const targetRoute1 = selectedConfig.targetRoute.paths[0].path const targetRoute2 = selectedConfig.targetRoute.paths[1] @@ -220,8 +282,19 @@ const readUserWithToken = async (req, res, selectedConfig) => { if (token && token.toLowerCase().startsWith('bearer ')) token = token.slice(7) const tokenClaims = jwt.decode(token) - const userId = tokenClaims.sub.split(':').pop() + + let userId = tokenClaims.sub.split(':').pop() + if(req.params.id){ + userId = req.params.id + } + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + console.log("----- req - header",req.headers['x-auth-token']); + + console.log("req.baseUrl of" ,targetRoute1.path) + console.log("targetRoute1.pathtargetRoute1.pathtargetRoute1.path ========= " ,targetRoute1.path) const userResponse = await requesters.get(req.baseUrl,targetRoute1.path, req.headers, { id: userId, }) @@ -283,10 +356,19 @@ const accountList = async (req, res, selectedConfig) => { try { const userIds = req.body.userIds if(process.env.DEBUG_MODE == "true"){ + console.log("------------selectedConfig --------",selectedConfig); + console.log("------------req.baseUrl --------",req.baseUrl); console.log("------- ================ -------",req.body); } // if (Array.isArray(userIds)) throw Error('req.body.userIds is not an array.') body.request.filters.userId = userIds + + + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + + const userSearchResponse = await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, body, {}) return res.json(processUserSearchResponse(userSearchResponse.result.response.content)) } catch (error) { @@ -314,6 +396,10 @@ const listOrganisation = async (req, res, selectedConfig) => { } try { + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + const response = await requesters.post(req.baseUrl, selectedConfig.targetRoute.path, body, { 'device-info': req.headers['device-info'], }) @@ -347,6 +433,99 @@ const listOrganisation = async (req, res, selectedConfig) => { return res.status(500).json({ error: 'Internal Server Error' }) } } +const mentorDetails = async (req, res, responses) => { + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + const parameterisedRoute = req.params.id ? selectedConfig.targetRoute.path.replace('/:id', `/${req.params.id}`) : selectedConfig.targetRoute.path; + let headers + + if (req.params.id) { + headers = { + 'Content-Type': 'application/json', + // 'X-auth-token': req.headers['x-authenticated-user-token'], + 'x-authenticated-user-token': req.headers['x-authenticated-user-token'], + } + } + + console.log("response ============ headers ",headers); + + let response = await requesters.get(req.baseUrl, parameterisedRoute,headers,{}) + return response + +} + + +const readUserOrchastration = async (req, res, response) => { + + const selectedConfig = routeConfigs.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + const userId = req.params.id + try { + // console.log('read by readUserOrchastration'); + let targetRoute1 = selectedConfig.targetRoute.paths[0].path + const targetRoute2 = selectedConfig.targetRoute.paths[1] + + + targetRoute1 = req.params.id ? targetRoute1.replace('/:id', `/${req.params.id}`) : targetRoute1; + + + if(selectedConfig.service){ + req['baseUrl'] = process.env[`${selectedConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + const userResponse = await requesters.get(req.baseUrl, targetRoute1, req.headers, { + id: userId, + }) + + if(process.env.DEBUG_MODE == "true"){ + console.log("READ API response status:",userResponse.params.status); + console.log(" user read API resp == ",JSON.stringify(userResponse)); + console.log(" API Response",JSON.stringify(userResponse)); + } + if (userResponse.params.status == 'FAILED') { + + if(process.env.DEBUG_MODE == "true"){ + console.log("userResponse.params.status ",userResponse.params.status); + console.log("userResponse.params.status ",JSON.stringify(userResponse)); + } + return res.send(userResponse) + } + const enrollmentResponse = await requesters.get(targetRoute2.baseUrl, targetRoute2.path, req.headers, { + id: userId, + }) + + if(process.env.DEBUG_MODE == "true"){ + console.log('CALLING COMPETENCY ') + } + + let competencyIds = [] + if(enrollmentResponse.result && enrollmentResponse.result.courses){ + competencyIds = getCompetencyIds(enrollmentResponse.result.courses || []) + + } + + if(process.env.DEBUG_MODE == "true"){ + console.log('competencyIds ==',competencyIds) + console.log("userResponse profile response ",userResponse); + } + const responseData = processUserResponse(userResponse) + responseData.result.competency = competencyIds + + if(process.env.DEBUG_MODE == "true"){ + console.log('RESPONSE DATA: ', JSON.stringify(responseData, null, 3)) + } + // responseData.responseCode = 'OK' + return (responseData) + } catch (error) { + if(process.env.DEBUG_MODE == "true"){ + console.error('Error fetching user details:', error) + } + return ({ error: 'Internal Server Error' }) + } +} + + + + mentoringController = { createProfile, @@ -361,7 +540,9 @@ mentoringController = { readUserById, readUserWithToken, accountList, - listOrganisation + listOrganisation, + mentorDetails, + readUserOrchastration } module.exports = mentoringController diff --git a/sunbird-mentoring/controllers/orchestrationController.js b/sunbird-mentoring/controllers/orchestrationController.js index 615ff0e5..fa19a997 100644 --- a/sunbird-mentoring/controllers/orchestrationController.js +++ b/sunbird-mentoring/controllers/orchestrationController.js @@ -1,15 +1,19 @@ const routesConfig = require('../constants/routes') const mentoringController = require('../controllers/mentoring') const orchestrationHandler = async (req, res, responses) => { - console.log(req.targetPackages, req.inSequence, req.orchestrated, req.sourceRoute, responses) + + console.log(req.service,req.targetPackages, req.inSequence, req.orchestrated, req.sourceRoute, responses) console.log(req.body) - const selectedRouteConfig = routesConfig.routes.find((obj) => obj.sourceRoute === req.sourceRoute) - return await mentoringController[selectedRouteConfig.targetRoute.functionName]( - req, - res, - responses, - selectedRouteConfig - ) + + const selectedRouteConfig = routesConfig.routes.find((obj) => req.service === obj.service && obj.sourceRoute === req.sourceRoute) + + + console.log(" selectedRouteConfig ---------- ",selectedRouteConfig); + + if(selectedRouteConfig && selectedRouteConfig.service){ + req['baseUrl'] = process.env[`${selectedRouteConfig.service.toUpperCase()}_SERVICE_BASE_URL`] + } + return await mentoringController[selectedRouteConfig.targetRoute.functionName](req, res, responses) } const orchestrationController = { diff --git a/sunbird-mentoring/helpers/dependencyManager.js b/sunbird-mentoring/helpers/dependencyManager.js index 475476dc..baf29266 100644 --- a/sunbird-mentoring/helpers/dependencyManager.js +++ b/sunbird-mentoring/helpers/dependencyManager.js @@ -1,7 +1,9 @@ const kafkaManager = require('./kafkaManager') +const kafkaUserManager = require('./userKafkaManager') const dependencyManager = (dependencyMap, environmentVariables) =>{ try{ + kafkaUserManager(dependencyMap.get('kafka'),environmentVariables) kafkaManager(dependencyMap.get('kafka'),environmentVariables) }catch(error){ console.log(error) diff --git a/sunbird-mentoring/helpers/kafkaManager.js b/sunbird-mentoring/helpers/kafkaManager.js index 31a30562..97e544c5 100644 --- a/sunbird-mentoring/helpers/kafkaManager.js +++ b/sunbird-mentoring/helpers/kafkaManager.js @@ -5,17 +5,17 @@ const kafkaManager = async (kafkaPackage, environmentVariables) => { const { ElevateKafka } = kafkaPackage const kafka = new ElevateKafka( - environmentVariables.KB_MENTORING_NOTIFICATION_KAFKA_BROKERS, - environmentVariables.KB_MENTORING_NOTIFICATION_KAFKA_BROKERS, + environmentVariables.SUNBIRD_MENTORING_NOTIFICATION_KAFKA_BROKERS, + environmentVariables.SUNBIRD_MENTORING_NOTIFICATION_KAFKA_BROKERS, { packageName: 'kb-mentoring-notification', } ) - const topics = [environmentVariables.KB_MENTORING_NOTIFICATION_KAFKA_TOPIC] - const consumer = await kafka.createConsumer(environmentVariables.KB_MENTORING_NOTIFICATION_KAFKA_GROUP_ID, topics) + const topics = [environmentVariables.SUNBIRD_MENTORING_NOTIFICATION_KAFKA_TOPIC] + const consumer = await kafka.createConsumer(environmentVariables.SUNBIRD_MENTORING_NOTIFICATION_KAFKA_GROUP_ID, topics) await kafka.runConsumer(consumer, async (topic, message) => { - if (topic == environmentVariables.KB_MENTORING_NOTIFICATION_KAFKA_TOPIC) { + if (topic == environmentVariables.SUNBIRD_MENTORING_NOTIFICATION_KAFKA_TOPIC) { if(process.env.DEBUG_MODE == "true"){ console.log("-------------------- message",message.value); diff --git a/sunbird-mentoring/helpers/userKafkaManager.js b/sunbird-mentoring/helpers/userKafkaManager.js new file mode 100644 index 00000000..50e3cc83 --- /dev/null +++ b/sunbird-mentoring/helpers/userKafkaManager.js @@ -0,0 +1,45 @@ +const { post } = require('../utils/requester') + +const kafkaManager = async (kafkaPackage, environmentVariables) => { + try { + const { ElevateKafka } = kafkaPackage + + const kafka = new ElevateKafka( + environmentVariables.SUNBIRD_USER_KAFKA_BROKERS, + environmentVariables.SUNBIRD_USER_KAFKA_BROKERS, + { + packageName: 'sunbird-user', + } + ) + + const topics = [environmentVariables.SUNBIRD_USER_USER_UPDATE_KAFKA_TOPIC] + const consumer = await kafka.createConsumer(environmentVariables.SUNBIRD_USER_KAFKA_GROUP_ID, topics) + await kafka.runConsumer(consumer, async (topic, message) => { + if (topic == environmentVariables.SUNBIRD_USER_USER_UPDATE_KAFKA_TOPIC) { + + if(process.env.DEBUG_MODE == "true"){ + console.log(" user kafka -------------------- message",message.value); + } + + let body = (JSON.parse(message.value)); + if(process.env.DEBUG_MODE == "true"){ + console.log(" user kafka -------------------- body ",body); + } + + post( + environmentVariables.MENTORING_SERVICE_BASE_URL, + environmentVariables.MENTORING_SERVICE_USER_UPDATE_ROUTE, + JSON.parse(message.value), + { + INTERNAL_ACCESS_TOKEN: environmentVariables.MENTORING_INTERNAL_ACCESS_TOKEN, + } + ) + } + }) + } catch (error) { + console.log(error) + throw error + } +} + +module.exports = kafkaManager diff --git a/sunbird-mentoring/index.js b/sunbird-mentoring/index.js index 07cd2a87..1aac3916 100644 --- a/sunbird-mentoring/index.js +++ b/sunbird-mentoring/index.js @@ -92,7 +92,35 @@ const requiredEnvs = { SUNBIRD_AUTHORIZATION_TOKEN : { message: `[${kafkaPackageName}] Required authorization token with bearer`, optional: false, - } + }, + [`SUNBIRD_USER_KAFKA_CLIENT_ID`]: { + message: `[SUNBIRD_USER_KAFKA_CLIENT_ID] Required Kafka Brokers Hosts`, + optional: false, + }, + [`SUNBIRD_USER_KAFKA_BROKERS`]: { + message: `[SUNBIRD_USER_KAFKA_BROKERS] Required Kafka Brokers Hosts`, + optional: false, + }, + [`SUNBIRD_USER_KAFKA_GROUP_ID`]: { + message: `[SUNBIRD_USER_KAFKA_GROUP_ID] Required Kafka Group ID`, + optional: false, + }, + [`SUNBIRD_USER_USER_UPDATE_KAFKA_TOPIC`]: { + message: `[SUNBIRD_USER_USER_UPDATE_KAFKA_TOPIC] Required Kafka Topics`, + optional: false, + }, + MENTORING_SERVICE_BASE_URL: { + message: `[MENTORING_SERVICE_BASE_URL] Required Base URL for the Mentoring Service`, + optional: false, + }, + MENTORING_SERVICE_USER_UPDATE_ROUTE: { + message: `[MENTORING_SERVICE_USER_UPDATE_ROUTE] Required Route for User Update in the Mentoring Service`, + optional: false, + }, + MENTORING_INTERNAL_ACCESS_TOKEN: { + message: `[MENTORING_INTERNAL_ACCESS_TOKEN] Required Internal Access Token of the Mentoring Service`, + optional: false, + }, } diff --git a/sunbird-mentoring/package.json b/sunbird-mentoring/package.json index 9cf8fdee..1657f2df 100644 --- a/sunbird-mentoring/package.json +++ b/sunbird-mentoring/package.json @@ -1,6 +1,6 @@ { "name": "sunbird-mentoring", - "version": "2.3.1", + "version": "3.1.33.2", "description": "Npm package for sunbird-mentoring service integration with Interface service. ", "main": "index.js", "scripts": { diff --git a/sunbird-mentoring/utils/requester.js b/sunbird-mentoring/utils/requester.js index 6b4a6afb..58db913f 100644 --- a/sunbird-mentoring/utils/requester.js +++ b/sunbird-mentoring/utils/requester.js @@ -17,6 +17,11 @@ const passThroughRequester = async (req, res) => { const sourceBaseUrl = req.protocol + '://' + req.headers.host + '/' const sourceUrl = new URL(req.originalUrl, sourceBaseUrl) const route = routesConfig.routes.find((route) => route.sourceRoute === req.sourceRoute) + + if(route.service){ + req['baseUrl'] = process.env[`${route.service.toUpperCase()}_SERVICE_BASE_URL`] + } + const params = matchPathsAndExtractParams(route.sourceRoute, req.originalUrl) const targetRoute = pathParamSetter(route.targetRoute.path, params) const parsedUrl = new URL(targetRoute, req.baseUrl) @@ -124,27 +129,28 @@ const patch = async (baseUrl, route, requestBody, headers) => { } } -const get = async (baseUrl, route, headers) => { - try { - const url = baseUrl + route - if(process.env.DEBUG_MODE == "true"){ - console.log('__GET REQUEST__') - console.log('REQUEST URL: ', url) - console.log('REQUEST HEADERS: ', headers) - } - return axios - .get(url, { headers }) - .then((response) => response.data) - .catch((error) => { - if (error.response) { - return error.response.data - } - return error - }) - } catch (error) { - console.error(error) - throw error // Re-throw the error to be caught by the caller +const get = (baseUrl, route, headers, requestBody = {}) => { + const url = baseUrl + route + if(process.env.DEBUG_MODE == "true"){ + console.log('__GET REQUEST__') + console.log('REQUEST URL: ', url) + console.log('REQUEST HEADERS: ', headers) } + const options = { + headers, + data: requestBody + }; + + return axios + .get(url, options) // Use POST to send body data + .then((response) => response.data) + .catch((error) => { + console.error('Error fetching data:', error) + if (error.response) { + return error.response + } + return error + }) } const requesters = { diff --git a/sunbird-user/package.json b/sunbird-user/package.json index 38192ee0..390a8892 100644 --- a/sunbird-user/package.json +++ b/sunbird-user/package.json @@ -1,6 +1,6 @@ { "name": "sunbird-user", - "version": "1.6.3", + "version": "1.6.4", "description": "Npm package for Elevate-User service integration with Interface service. ", "main": "index.js", "scripts": {