From 838a3a1b3ac2457bf06e0504c9954fc0489de4ab Mon Sep 17 00:00:00 2001 From: joffinjoy Date: Fri, 22 Sep 2023 16:00:12 +0530 Subject: [PATCH 1/5] Added Api-doc --- deployment/ansible.yml | 7 +- src/.env | 3 +- src/api-doc/api-doc.yaml | 226 ++++ src/api-doc/index.html | 2182 ++++++++++++++++++++++++++++++++++++++ src/app.js | 6 + 5 files changed, 2422 insertions(+), 2 deletions(-) create mode 100644 src/api-doc/api-doc.yaml create mode 100644 src/api-doc/index.html diff --git a/deployment/ansible.yml b/deployment/ansible.yml index baac60b..f5fb07d 100644 --- a/deployment/ansible.yml +++ b/deployment/ansible.yml @@ -41,7 +41,7 @@ update: yes version: "{{ gitBranch }}" - name: Update npm - shell: cd {{release_path}}/src && npm i + shell: cd {{release_path}}/src && npm i && npm i redoc-cli - name: Delete Old Folder & create folder shell: rm -rf {{ current_path }} && cd {{ project_path }} && mkdir interface @@ -64,6 +64,11 @@ - name: move gcp credentials shell: mv {{ project_path }}/gcp.json {{ current_path }}/src/ + - name: generate api-doc + shell: cd {{current_path}}/src && redoc-cli build -o ./api-doc/index.html ./api-doc/api-doc.yaml + register: apiDocResponse + - debug: msg=" Api-doc {{ apiDocResponse }} " + - name: Delete release folder shell: rm -rf {{ release_path }} diff --git a/src/.env b/src/.env index 2ec202c..53f4311 100644 --- a/src/.env +++ b/src/.env @@ -5,4 +5,5 @@ SUPPORTED_HTTP_TYPES="GET POST PUT PATCH DELETE" USER_SERVICE_BASE_URL='http://localhost:4567' MENTORING_SERVICE_BASE_URL='' NOTIFICATION_SERVICE_BASE_URL='' -SCHEDULER_SERVICE_BASE_URL='' \ No newline at end of file +SCHEDULER_SERVICE_BASE_URL='' +API_DOC_URL='/interface/api-doc' \ No newline at end of file diff --git a/src/api-doc/api-doc.yaml b/src/api-doc/api-doc.yaml new file mode 100644 index 0000000..ede9e70 --- /dev/null +++ b/src/api-doc/api-doc.yaml @@ -0,0 +1,226 @@ +openapi: 3.0.0 +info: + title: Interface Service APIs + version: 1.0.0 +servers: + - url: https://localhost:3567 +tags: + - name: Orchestration + description: Orchestration APIs of Interface Service +paths: + /interface/v1/account/create: + post: + summary: Create User Account + tags: + - Orchestration + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + example: 'user' + email: + type: string + format: email + example: 'user@shikshalokam.org' + password: + type: string + example: 'passwordofuser' + otp: + type: string + example: '672854' + has_accepted_terms_and_conditions: + type: boolean + example: true + required: + - name + - email + - password + - otp + - has_accepted_terms_and_conditions + responses: + '200': + description: User Account Created Successfully + content: + application/json: + example: + access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' + refresh_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' + user: + id: 8 + email: user@shikshalokam.org + email_verified: 'false' + name: user + status: ACTIVE + has_accepted_terms_and_conditions: true + preferred_language: + value: english + label: English + organization_id: 1 + roles: + - 2 + user_created_at: '2023-09-20T11:59:37.871Z' + user_updated_at: '2023-09-20T11:59:37.871Z' + user_roles: + - id: 2 + title: mentor + user_type: 0 + status: ACTIVE + profile_updated_at: '2023-09-20T12:00:46.533Z' + profile_created_at: '2023-09-20T12:00:46.533Z' + /interface/v1/account/update: + post: + summary: Update User Profile + tags: + - Orchestration + parameters: + - name: X-auth-token + in: header + description: Bearer JWT token for authentication + required: true + schema: + type: string + format: JWT + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + example: 'ShikshaLokam User' + location: + type: array + items: + type: string + example: + - 'AP' + - 'KL' + about: + type: string + example: 'This is test about of mentee' + gender: + type: string + example: 'male' + image: + type: string + example: 'https://cloudstorage.com/container/abc.png' + languages: + type: array + items: + type: string + example: + - 'english' + - 'hindi' + designation: + type: string + example: 'Lead Mentor' + area_of_expertise: + type: array + items: + type: string + example: + - 'technology' + - 'leadership' + education_qualification: + type: array + items: + type: string + example: + - 'MBA' + - 'B.Tech' + age: + type: integer + example: 35 + experience: + type: string + example: '10 years' + tags: + type: array + items: + type: string + example: + - 'Experienced' + - 'Technical' + configs: + type: object + properties: + notification: + type: boolean + example: true + visibility: + type: string + enum: + - public + - private + example: 'public' + required: + - name + responses: + '200': + description: User Profile Updated Successfully + content: + application/json: + example: + id: '8' + name: ShikshaLokam User + location: + - value: AP + label: Andhra Pradesh + - value: KL + label: Kerala + about: This is test about of mentee + has_accepted_terms_and_conditions: true + gender: + value: male + label: Male + image: 'https://cloudstorage.com/container/abc.png' + languages: + - value: english + label: English + user_created_at: '2023-09-20T11:59:37.871Z' + user_updated_at: '2023-09-20T11:59:37.871Z' + designation: Lead Mentor + area_of_expertise: + - value: technology + label: Technology + - value: leadership + label: Leadership + education_qualification: + - value: mba + label: MBA + - value: btech + label: B.Tech + rating: + average: 5 + count: 20 + age: 35 + experience: 10 years + stats: + sessions_attended: 50 + students_mentored: 30 + tags: + - experienced + - technical + configs: + notification: true + visibility: public + visibility: visible + organisation_ids: + - 1 + - 2 + external_session_visibility: limited + external_mentor_visibility: hidden + profile_created_at: '2023-09-20T12:00:46.533Z' + profile_updated_at: '2023-09-20T12:17:12.316Z' + +components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer + bearerFormat: JWT diff --git a/src/api-doc/index.html b/src/api-doc/index.html new file mode 100644 index 0000000..7064cb3 --- /dev/null +++ b/src/api-doc/index.html @@ -0,0 +1,2182 @@ + + + + + + Interface Service APIs + + + + + + + + + +

Interface Service APIs (1.0.0)

Download OpenAPI specification:Download

Orchestration

Orchestration APIs of Interface Service

+

Create User Account

Request Body schema: application/json
name
required
string
email
required
string <email>
password
required
string
otp
required
string
has_accepted_terms_and_conditions
required
boolean

Responses

Request samples

Content type
application/json
{
  • "name": "user",
  • "email": "user@shikshalokam.org",
  • "password": "passwordofuser",
  • "otp": "672854",
  • "has_accepted_terms_and_conditions": true
}

Response samples

Content type
application/json
{
  • "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  • "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  • "user": {
    }
}

Update User Profile

header Parameters
X-auth-token
required
string <JWT>

Bearer JWT token for authentication

+
Request Body schema: application/json
name
required
string
location
Array of strings
about
string
gender
string
image
string
languages
Array of strings
designation
string
area_of_expertise
Array of strings
education_qualification
Array of strings
age
integer
experience
string
tags
Array of strings
object

Responses

Request samples

Content type
application/json
{
  • "name": "ShikshaLokam User",
  • "location": [
    ],
  • "about": "This is test about of mentee",
  • "gender": "male",
  • "languages": [
    ],
  • "designation": "Lead Mentor",
  • "area_of_expertise": [
    ],
  • "education_qualification": [
    ],
  • "age": 35,
  • "experience": "10 years",
  • "tags": [
    ],
  • "configs": {
    }
}

Response samples

Content type
application/json
{
  • "id": "8",
  • "name": "ShikshaLokam User",
  • "location": [
    ],
  • "about": "This is test about of mentee",
  • "has_accepted_terms_and_conditions": true,
  • "gender": {
    },
  • "languages": [
    ],
  • "user_created_at": "2023-09-20T11:59:37.871Z",
  • "user_updated_at": "2023-09-20T11:59:37.871Z",
  • "designation": "Lead Mentor",
  • "area_of_expertise": [
    ],
  • "education_qualification": [
    ],
  • "rating": {
    },
  • "age": 35,
  • "experience": "10 years",
  • "stats": {
    },
  • "tags": [
    ],
  • "configs": {
    },
  • "visibility": "visible",
  • "organisation_ids": [
    ],
  • "external_session_visibility": "limited",
  • "external_mentor_visibility": "hidden",
  • "profile_created_at": "2023-09-20T12:00:46.533Z",
  • "profile_updated_at": "2023-09-20T12:17:12.316Z"
}
+ + + + \ No newline at end of file diff --git a/src/app.js b/src/app.js index 5cdc7bd..f55f442 100644 --- a/src/app.js +++ b/src/app.js @@ -8,6 +8,9 @@ const app = express() //Package Loader & Validation const routerPackages = require('@utils/packageLoader').packageLoader() + +//Package Initializer With Changes +require('@utils/packageInitializer').packageInitializer() //const validatedPackages = packageValidator(routerPackages); const validatedPackages = routerPackages //Bypassing the validator for now @@ -18,6 +21,9 @@ app.use(bodyParser.json({ limit: '50MB' })); */ //Router const { initializeRouter } = require('@router') app.use(initializeRouter(validatedPackages)) +app.get(process.env.API_DOC_URL, function (req, res) { + res.sendFile(path.join(__dirname, './api-doc/index.html')) +}) /* const { initializeOrchestrationRouter } = require('./router/orchestrationRouter'); app.use('/interface', initializeOrchestrationRouter()); */ From 1eb1a5b89e68c23e5d511270ccd09b24d099d755 Mon Sep 17 00:00:00 2001 From: joffinjoy Date: Fri, 22 Sep 2023 16:07:40 +0530 Subject: [PATCH 2/5] Added Path --- src/app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app.js b/src/app.js index f55f442..abfd57b 100644 --- a/src/app.js +++ b/src/app.js @@ -4,6 +4,7 @@ const express = require('express') const cors = require('cors') require('dotenv').config({ path: './.env' }) const app = express() +const path = require('path') //const packageValidator = require('./utils/packageValidator'); //Package Loader & Validation From 738061c255d3ca7417aa3d969cb356372f8ddd65 Mon Sep 17 00:00:00 2001 From: joffinjoy Date: Fri, 22 Sep 2023 16:10:51 +0530 Subject: [PATCH 3/5] Added Package Initializer Placeholder --- src/utils/packageInitializer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/utils/packageInitializer.js diff --git a/src/utils/packageInitializer.js b/src/utils/packageInitializer.js new file mode 100644 index 0000000..6600f76 --- /dev/null +++ b/src/utils/packageInitializer.js @@ -0,0 +1,14 @@ +'use strict' +const packageInitializer = () => { + const packageNames = process.env.INSTALLED_PACKAGES.split(' ') + const packages = [] + for (const servicePackage of packageNames) { + const _package = require(servicePackage) + console.log(_package.dependencies) + //inject dependencies here by calling Initializer() + } + console.log(packages) + return packages +} + +module.exports = { packageInitializer } From 9491f24f21b3234bdafbd2b57e8580e7cd705e35 Mon Sep 17 00:00:00 2001 From: joffinjoy Date: Mon, 18 Dec 2023 15:23:02 +0530 Subject: [PATCH 4/5] Event fixes --- src/constants/config.json | 26 ++++++++++++++++++++++++ src/package-lock.json | 42 +++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/constants/config.json b/src/constants/config.json index 2859e3a..78079c0 100644 --- a/src/constants/config.json +++ b/src/constants/config.json @@ -1773,6 +1773,19 @@ } ] }, + { + "sourceRoute": "/mentoring/v1/org-admin/deactivateUpcomingSession", + "type": "POST", + "priority": "MUST_HAVE", + "inSequence": false, + "orchestrated": false, + "targetPackages": [ + { + "basePackageName": "mentoring", + "packageName": "elevate-mentoring" + } + ] + }, { "sourceRoute": "/mentoring/v1/organization/update", "type": "PATCH", @@ -2293,6 +2306,19 @@ } ] }, + { + "sourceRoute": "/mentoring/v1/org-admin/updateOrganization", + "type": "POST", + "priority": "MUST_HAVE", + "inSequence": false, + "orchestrated": false, + "targetPackages": [ + { + "basePackageName": "mentoring", + "packageName": "elevate-mentoring" + } + ] + }, { "sourceRoute": "/user/v1/account/search", "type": "POST", diff --git a/src/package-lock.json b/src/package-lock.json index e3dddac..515bd72 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -12,10 +12,10 @@ "cli-table": "^0.3.11", "cors": "^2.8.5", "dotenv": "^16.3.1", - "elevate-mentoring": "^1.1.20", + "elevate-mentoring": "^1.1.23", "elevate-package-validator": "^1.0.0", - "elevate-scheduler": "^1.0.3", - "elevate-user": "^1.1.4", + "elevate-scheduler": "^1.0.4", + "elevate-user": "^1.1.30", "express": "^4.18.2", "module-alias": "^2.2.3" }, @@ -2298,9 +2298,9 @@ "dev": true }, "node_modules/elevate-mentoring": { - "version": "1.1.20", - "resolved": "https://registry.npmjs.org/elevate-mentoring/-/elevate-mentoring-1.1.20.tgz", - "integrity": "sha512-PnHGTPs5XhDMUfktdRSJ3+GqEWGlUoAZT0T6FW3hfroy8JEBYPd+KGImCwKMR82A7U7RFPLyJJiu2Pmg+SShvg==", + "version": "1.1.23", + "resolved": "https://registry.npmjs.org/elevate-mentoring/-/elevate-mentoring-1.1.23.tgz", + "integrity": "sha512-1DVhcc4mA6+YM9yxvo+b9TNHxdO6961gO/I3Enj3wO/iLr5LCh5mS2x1nPmIrhJqtcZjGQ/zeJ8gS9geCCVroA==", "dependencies": { "axios": "^1.4.0", "express": "^4.18.2", @@ -2323,9 +2323,9 @@ } }, "node_modules/elevate-scheduler": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/elevate-scheduler/-/elevate-scheduler-1.0.3.tgz", - "integrity": "sha512-zqLJmI4JLQDwEMaqk6+8cQoqowOaYNGw6YhhK13VqYU4+5pZ0g16sGpw5mJE60J0n5+egT/BcAJ6ekntXDg/lQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/elevate-scheduler/-/elevate-scheduler-1.0.4.tgz", + "integrity": "sha512-/UkR8INbOO673OFGdspp/n3BT5uLh/UHsqiB6g2B9TU07gXow8TefXEnD+TaYPf0hW2v8v6bJrCGJGtG4loXLw==", "dependencies": { "axios": "^1.4.0", "express": "^4.18.2", @@ -2340,9 +2340,9 @@ "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==" }, "node_modules/elevate-user": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/elevate-user/-/elevate-user-1.1.4.tgz", - "integrity": "sha512-/rVA2du0eMJGH3ueRYgHCcWHFlU6lZEYkNFmhGulYpdKz1JyO3mE0NzZZpNPkKpTRiBcHMqItmRy4ZSXuip8sg==", + "version": "1.1.30", + "resolved": "https://registry.npmjs.org/elevate-user/-/elevate-user-1.1.30.tgz", + "integrity": "sha512-kTMPsQ1ywrK1zt4vo2EK0cfkTiL9RALOg+IOFEh0MPgqflXVdQFqYYZawLEFTOrE/OeAeuyp1pdf43ZEqnEGHA==", "dependencies": { "axios": "^1.4.0", "express": "^4.18.2", @@ -7805,9 +7805,9 @@ "dev": true }, "elevate-mentoring": { - "version": "1.1.20", - "resolved": "https://registry.npmjs.org/elevate-mentoring/-/elevate-mentoring-1.1.20.tgz", - "integrity": "sha512-PnHGTPs5XhDMUfktdRSJ3+GqEWGlUoAZT0T6FW3hfroy8JEBYPd+KGImCwKMR82A7U7RFPLyJJiu2Pmg+SShvg==", + "version": "1.1.23", + "resolved": "https://registry.npmjs.org/elevate-mentoring/-/elevate-mentoring-1.1.23.tgz", + "integrity": "sha512-1DVhcc4mA6+YM9yxvo+b9TNHxdO6961gO/I3Enj3wO/iLr5LCh5mS2x1nPmIrhJqtcZjGQ/zeJ8gS9geCCVroA==", "requires": { "axios": "^1.4.0", "express": "^4.18.2", @@ -7832,9 +7832,9 @@ } }, "elevate-scheduler": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/elevate-scheduler/-/elevate-scheduler-1.0.3.tgz", - "integrity": "sha512-zqLJmI4JLQDwEMaqk6+8cQoqowOaYNGw6YhhK13VqYU4+5pZ0g16sGpw5mJE60J0n5+egT/BcAJ6ekntXDg/lQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/elevate-scheduler/-/elevate-scheduler-1.0.4.tgz", + "integrity": "sha512-/UkR8INbOO673OFGdspp/n3BT5uLh/UHsqiB6g2B9TU07gXow8TefXEnD+TaYPf0hW2v8v6bJrCGJGtG4loXLw==", "requires": { "axios": "^1.4.0", "express": "^4.18.2", @@ -7851,9 +7851,9 @@ } }, "elevate-user": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/elevate-user/-/elevate-user-1.1.4.tgz", - "integrity": "sha512-/rVA2du0eMJGH3ueRYgHCcWHFlU6lZEYkNFmhGulYpdKz1JyO3mE0NzZZpNPkKpTRiBcHMqItmRy4ZSXuip8sg==", + "version": "1.1.30", + "resolved": "https://registry.npmjs.org/elevate-user/-/elevate-user-1.1.30.tgz", + "integrity": "sha512-kTMPsQ1ywrK1zt4vo2EK0cfkTiL9RALOg+IOFEh0MPgqflXVdQFqYYZawLEFTOrE/OeAeuyp1pdf43ZEqnEGHA==", "requires": { "axios": "^1.4.0", "express": "^4.18.2", From 989e81a320aa86fbd56b3ccdc5dbf48036fb973b Mon Sep 17 00:00:00 2001 From: joffinjoy Date: Mon, 18 Dec 2023 18:28:21 +0530 Subject: [PATCH 5/5] Uncommented Package Installer --- src/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index 113c7d0..67fe1e5 100644 --- a/src/app.js +++ b/src/app.js @@ -11,10 +11,10 @@ if (!environmentData.success) { process.exit() } -/* packageInstaller(process.env.REQUIRED_PACKAGES).catch((error) => { +packageInstaller(process.env.REQUIRED_PACKAGES).catch((error) => { console.error(`An error occurred in package installer: ${error}`) process.exit() -}) */ +}) const app = express() //const packageValidator = require('./utils/packageValidator');