Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor.interface.conflict fix #155

Open
wants to merge 44 commits into
base: develop-3.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4f798fb
Merge pull request #46 from ELEVATE-Project/develop
rakeshSgr Jan 12, 2024
d43b570
Merge pull request #55 from ELEVATE-Project/develop
rakeshSgr Jan 22, 2024
9a2bbd6
Merge pull request #61 from ELEVATE-Project/develop
rakeshSgr Jan 25, 2024
403a12f
Merge pull request #66 from ELEVATE-Project/develop
rakeshSgr Feb 1, 2024
38d3235
Merge pull request #68 from ELEVATE-Project/develop
joffinjoy Feb 8, 2024
e5bbee1
Merge pull request #71 from ELEVATE-Project/staging
rakeshSgr Feb 27, 2024
85fbc9d
Merge pull request #75 from ELEVATE-Project/develop
rakeshSgr Mar 19, 2024
204392e
Merge pull request #77 from ELEVATE-Project/develop
rakeshSgr Mar 22, 2024
167a3ec
Merge pull request #83 from ELEVATE-Project/develop
joffinjoy Mar 26, 2024
16846db
Merge pull request #85 from ELEVATE-Project/develop
joffinjoy Mar 26, 2024
67de9b8
Merge pull request #87 from ELEVATE-Project/develop
joffinjoy Mar 26, 2024
6ad5a7e
Merge pull request #89 from ELEVATE-Project/develop
joffinjoy Mar 27, 2024
6864228
Updated 2.5 README
joffinjoy Mar 27, 2024
b729486
Merge pull request #90 from ELEVATE-Project/main-doc
joffinjoy Mar 27, 2024
e7b7ce6
Merge pull request #92 from ELEVATE-Project/develop
rakeshSgr Mar 28, 2024
8ea3736
Merge pull request #95 from ELEVATE-Project/develop
rakeshSgr Apr 5, 2024
c747300
Merge pull request #98 from ELEVATE-Project/staging
rakeshSgr Apr 8, 2024
ec8d09f
Added .env.sample File & Minor Changes To READMEs
joffinjoy Apr 15, 2024
209f9d7
Merge pull request #99 from ELEVATE-Project/env.sample
joffinjoy Apr 15, 2024
32010bb
added build file
Jun 5, 2024
b0e2374
Create Jenkinsfile added
Haritest Jun 10, 2024
c2162d2
Create build.sh added
Haritest Jun 10, 2024
7489ad3
Update Dockerfile node version changes for test
Haritest Jun 10, 2024
fa5d56c
Update Dockerfile
Haritest Jun 25, 2024
96cbfe1
docker fix
Jun 26, 2024
3fe34d8
Merge pull request #1 from sunbird-cb/deploy
Haritest Jun 26, 2024
a9ba7d9
Update Dockerfile
Haritest Jun 26, 2024
f568ef9
Update Dockerfile
Haritest Jun 26, 2024
be692b3
Update Dockerfile
Haritest Jun 26, 2024
b5b8776
KB Specific Changes
joffinjoy Jun 27, 2024
93c4a77
Fixed Package Names
joffinjoy Jun 27, 2024
52d42a0
Refactored Code For Improved Structuring & Configuration
joffinjoy Jul 11, 2024
0a83a4a
Added Dependency Config
joffinjoy Jul 12, 2024
7ae017c
Added Dependency Manager
joffinjoy Jul 12, 2024
ba8aee9
User Update Partial
joffinjoy Jul 17, 2024
81e4c23
Uncommented Package Installer
joffinjoy Jul 17, 2024
547a2e7
Upgraded Package Versions
joffinjoy Jul 17, 2024
acf2b8b
Conflict Fixes
joffinjoy Jul 18, 2024
8a9877d
Modified Router To Specifically Handle CustomHandler APIs
joffinjoy Jul 18, 2024
ca955c9
Minor Formatting Changes
joffinjoy Jul 18, 2024
a2358cd
Added KB-Mentoring-Notification Dependency Config
joffinjoy Jul 19, 2024
30be238
Set CustomHandler For user/v1/account/list API
joffinjoy Jul 31, 2024
69d0653
Formatted Sunbird-Mentoring Config File
joffinjoy Aug 2, 2024
2784add
Added Entity List API
joffinjoy Aug 8, 2024
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ uploads
# Ignore Mac DS_Store files
*.DS_Store


public/assessment/web
public/assessment/web2
public/tmp
Expand All @@ -77,4 +76,6 @@ src/globalConfig.json

dev-ops/report

src/package-lock.json
src/package-lock.json

src/configs/.config.json
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18
FROM node:17

#Set working directory
WORKDIR /var/src/
Expand All @@ -7,7 +7,7 @@ WORKDIR /var/src/
COPY ./src/package.json .

#Install node packages
RUN npm install && npm install -g [email protected]
RUN npm install --unsafe-perm
#Copy all files
COPY ./src .

Expand Down
47 changes: 47 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
node('build-slave') {
try {
String ANSI_GREEN = "\u001B[32m"
String ANSI_NORMAL = "\u001B[0m"
String ANSI_BOLD = "\u001B[1m"
String ANSI_RED = "\u001B[31m"
String ANSI_YELLOW = "\u001B[33m"

ansiColor('xterm') {
stage('Checkout') {
if (!env.hub_org) {
println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL)
error 'Please resolve the errors and rerun..'
} else
println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL)
}

cleanWs()
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
build_tag = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim()
echo "build_tag: " + build_tag


stage('Build') {
env.NODE_ENV = "build"
print "Environment will be : ${env.NODE_ENV}"
sh('chmod 777 build.sh')
sh("bash -x build.sh ${build_tag} ${env.NODE_NAME} ${docker_server}")
}


stage('ArchiveArtifacts') {
sh ("echo ${build_tag} > build_tag.txt")
archiveArtifacts "metadata.json"
archiveArtifacts "build_tag.txt"
currentBuild.description = "${build_tag}"
}

}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}

}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ interface-service/src$ sudo nano .env
APPLICATION_PORT=3569
API_DOC_URL= /interface/api-doc
APPLICATION_ENV= development
INSTALLED_PACKAGES= "elevate-user elevate-mentoring elevate-scheduler"
MENTORING_SERVICE_BASE_URL= http://localhost:3000
NOTIFICATION_SERVICE_BASE_URL= http://localhost:7201
REQUIRED_PACKAGES= "[email protected] [email protected] [email protected]"
Expand Down
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

echo "Docker build script"

# Build script
set -eo pipefail

build_tag=$1
name=mentoring-interface-service
node=$2
org=$3

docker build -f ./Dockerfile --label commitHash=$(git rev-parse --short HEAD) -t ${org}/${name}:${build_tag} .

echo {\"image_name\" : \"${name}\", \"image_tag\" : \"${build_tag}\", \"node_name\" : \"$node\"} > metadata.json
6 changes: 0 additions & 6 deletions package-lock.json

This file was deleted.

53 changes: 53 additions & 0 deletions src/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# CORS allowed host, optional with default value "*"
ALLOWED_HOST=*

# Base URL for API documentation access, optional
API_DOC_URL=/interface/api-doc

# Required node environment (e.g., development, production)
APPLICATION_ENV=development

# Required application port number for running the server
APPLICATION_PORT=3567

# Required base URL for the mentoring service
MENTORING_SERVICE_BASE_URL=http://localhost:7101

# Required base URL for the notification service
NOTIFICATION_SERVICE_BASE_URL=http://localhost:7201

# Global flag to enable rate limiting, required
RATE_LIMITER_ENABLED=true

# Required limit for general type rate limiting
RATE_LIMITER_GENERAL_LIMIT=50

# Required window duration for general type rate limiting (milliseconds)
RATE_LIMITER_GENERAL_WINDOW=60000

# Required limit for internal type rate limiting
RATE_LIMITER_INTERNAL_LIMIT=50

# Required window duration for internal type rate limiting (milliseconds)
RATE_LIMITER_INTERNAL_WINDOW=60000

# Required number of proxies to consider for rate limiting
RATE_LIMITER_NUMBER_OF_PROXIES=3

# Required limit for public-low type rate limiting
RATE_LIMITER_PUBLIC_LOW_LIMIT=5

# Required window duration for public-low type rate limiting (milliseconds)
RATE_LIMITER_PUBLIC_LOW_WINDOW=120000

# Required packages for the application
REQUIRED_PACKAGES="[email protected] [email protected] [email protected]"

# Required base URL for the scheduler service
SCHEDULER_SERVICE_BASE_URL=http://localhost:7401

# Required supported HTTP types for the server
SUPPORTED_HTTP_TYPES="GET POST PUT PATCH DELETE"

# Required base URL for the user service
USER_SERVICE_BASE_URL=http://localhost:7001
1 change: 0 additions & 1 deletion src/api-doc/interface-2.5-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ interface-service/src$ sudo nano .env
APPLICATION_PORT=3569
API_DOC_URL= /interface/api-doc
APPLICATION_ENV= development
INSTALLED_PACKAGES= "elevate-user elevate-mentoring elevate-scheduler"
MENTORING_SERVICE_BASE_URL= http://localhost:3000
NOTIFICATION_SERVICE_BASE_URL= http://localhost:7201
REQUIRED_PACKAGES= "[email protected] [email protected] [email protected]"
Expand Down
16 changes: 11 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ const cors = require('cors')
require('dotenv').config({ path: './.env' })
const packageInstaller = require('./utils/packageInstaller')

packageInstaller(process.env.REQUIRED_PACKAGES).catch((error) => {
console.error(`An error occurred in package installer: ${error}`)
process.exit()
})

const { runCombineRoutes } = require('./scripts/combineRoutesConfigs')
runCombineRoutes()

const dependencyManager = require('@helpers/dependencyManager')
dependencyManager()

let environmentData = require('./envVariables')()
if (!environmentData.success) {
console.error('Server could not start . Not all environment variable is provided')
process.exit()
}
require('./init')

packageInstaller(process.env.REQUIRED_PACKAGES).catch((error) => {
console.error(`An error occurred in package installer: ${error}`)
process.exit()
})

const app = express()
const path = require('path')
app.set('trust proxy', parseInt(process.env.RATE_LIMITER_NUMBER_OF_PROXIES))
Expand Down
18 changes: 18 additions & 0 deletions src/configs/dependencyConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"requiredDependencies": [
{
"packageName": "sunbird-user",
"dependencies": [{ "name": "kafka" }]
},
{
"packageName": "kb-mentoring-notification",
"dependencies": [{ "name": "kafka" }]
}
],
"supportedDependencies": [
{
"name": "kafka",
"packageName": "elevate-kafka"
}
]
}
12 changes: 12 additions & 0 deletions src/configs/requiredEnvs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"requiredEnvs": {
"USER_SERVICE_BASE_URL": {
"message": "Required user service base URL",
"optional": false
},
"MENTORING_SERVICE_BASE_URL": {
"message": "Required mentoring service base URL",
"optional": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const config = require('@constants/config.json')
const config = require('@configs/.config.json')

exports.routesConfigs = {
services: ['user', 'mentoring', 'notification', 'scheduler'],
Expand Down
84 changes: 84 additions & 0 deletions src/configs/routesConfigs/elevate-scheduler.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"routes": [
{
"sourceRoute": "/scheduler/jobs/create",
"type": "POST",
"priority": "MUST_HAVE",
"inSequence": false,
"orchestrated": false,
"targetPackages": [
{
"basePackageName": "scheduler",
"packageName": "elevate-scheduler"
}
],
"rateLimit": {
"type": "none"
}
},
{
"sourceRoute": "/scheduler/jobs/updateDelay",
"type": "POST",
"priority": "MUST_HAVE",
"inSequence": false,
"orchestrated": false,
"targetPackages": [
{
"basePackageName": "scheduler",
"packageName": "elevate-scheduler"
}
],
"rateLimit": {
"type": "none"
}
},
{
"sourceRoute": "/scheduler/jobs/remove",
"type": "POST",
"priority": "MUST_HAVE",
"inSequence": false,
"orchestrated": false,
"targetPackages": [
{
"basePackageName": "scheduler",
"packageName": "elevate-scheduler"
}
],
"rateLimit": {
"type": "none"
}
},
{
"sourceRoute": "/scheduler/jobs/list",
"type": "GET",
"priority": "MUST_HAVE",
"inSequence": false,
"orchestrated": false,
"targetPackages": [
{
"basePackageName": "scheduler",
"packageName": "elevate-scheduler"
}
],
"rateLimit": {
"type": "none"
}
},
{
"sourceRoute": "/scheduler/jobs/purge",
"type": "POST",
"priority": "MUST_HAVE",
"inSequence": false,
"orchestrated": false,
"targetPackages": [
{
"basePackageName": "scheduler",
"packageName": "elevate-scheduler"
}
],
"rateLimit": {
"type": "none"
}
}
]
}
Loading