Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deployment/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

Expand Down
3 changes: 2 additions & 1 deletion src/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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=''
SCHEDULER_SERVICE_BASE_URL=''
API_DOC_URL='/interface/api-doc'
226 changes: 226 additions & 0 deletions src/api-doc/api-doc.yaml
Original file line number Diff line number Diff line change
@@ -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
2,182 changes: 2,182 additions & 0 deletions src/api-doc/index.html

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ 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
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

Expand All @@ -18,6 +22,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()); */

Expand Down
14 changes: 14 additions & 0 deletions src/utils/packageInitializer.js
Original file line number Diff line number Diff line change
@@ -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 }