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

4.8.13 dev v2 #355

Open
wants to merge 30 commits into
base: cbrelease-4.8.13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
05e36a9
Added the calendar API (#328)
Sahil-tarento Apr 12, 2024
730c3dc
Merged from cbrelease-4.8.13
karthik-tarento Apr 15, 2024
40270d7
Added the calendar API for bulkUpload (#329)
Sahil-tarento Apr 16, 2024
a34e324
Career UI proxy (#332)
ruksana2808 Apr 17, 2024
c8fce0e
Added public API to get Carrer listings
karthik-tarento Apr 17, 2024
082e578
Handling error cases for careers list API
karthik-tarento Apr 18, 2024
a5c03a6
Added facets to careers list api
karthik-tarento Apr 18, 2024
a52fe9d
Updated facet attribute name
karthik-tarento Apr 18, 2024
febc5c5
Merge branch 'cbrelease-4.8.13' into 4.8.13-dev
SaipradeepR Apr 18, 2024
3fbf4be
Changed the role access for career event and removed the retire API f…
ruksana2808 Apr 20, 2024
7896952
Merge branch 'cbrelease-4.8.13' into 4.8.13-dev
SaipradeepR Apr 20, 2024
4b905bd
4.8.13 dev (#338)
ravisaurav-tarento Apr 23, 2024
119e7cd
KB - 3844, KB-3843 (#337)
dkttarento Apr 25, 2024
9813f0e
/ added on microsite insights and trending (#339)
dkttarento Apr 25, 2024
d09f5be
API for topReviews for org
Sahil-tarento Apr 25, 2024
1090a46
Merge pull request #340 from Sahil-tarento/upstream/4.8.13-dev-v1
Haritest Apr 25, 2024
72997ba
4.8.13 dev microsites (#342)
dkttarento Apr 25, 2024
6beb9af
4.8.13 dev microsites (#343)
dkttarento Apr 25, 2024
b5daa03
Update proxies_v8.ts (#344)
dkttarento Apr 26, 2024
e38564b
Adding orgId for topReviews. (#346)
Sahil-tarento May 2, 2024
622612e
Cbrelease 4.8.13 ext (#347)
christyfernandes May 9, 2024
e2f5287
Form read API is added as public
karthik-tarento May 10, 2024
acad24a
New Endpoint for Microsite Top Content UI Proxy (#351)
dkttarento May 10, 2024
c4c965b
Adding the APi fields for user Create. (#352)
Sahil-tarento May 10, 2024
bccb3e4
update the fields. (#353)
Sahil-tarento May 10, 2024
c88a8b5
update the fields for user create (#356)
Sahil-tarento May 13, 2024
dceaaa5
proxies_v8 , Whitelist url changed fot Top Content msite. (#358)
dkttarento May 13, 2024
f22bc96
demand create, read, delete, search api's. (#354)
shankaragoudab May 13, 2024
5770d40
Merge branch 'cbrelease-4.8.14' into 4.8.13-dev-v2
karthik-tarento May 14, 2024
32db7ce
build auto changes
karthik-tarento May 14, 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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"author": "Christopher Fernandes",
"license": "MIT",
"dependencies": {
"@project-sunbird/ext-framework-server": "^0.1.28",
"@project-sunbird/form-service": "0.0.15",
"@types/cors": "^2.8.6",
"@types/node-xlsx": "^0.15.0",
"async": "^3.2.0",
Expand Down
70 changes: 70 additions & 0 deletions src/configs/framework.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

const fs = require('fs')
const expressCassandra = require('express-cassandra')
import { CONSTANTS } from '../utils/env'
const _ = require('lodash')
const packageObj = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const uuidv1 = require('uuid/v1')

const consistency = getConsistencyLevel(CONSTANTS.PORTAL_CASSANDRA_CONSISTENCY_LEVEL)
const replicationStrategy = {class: 'SimpleStrategy', replication_factor: 1}
function getIPList() {
return CONSTANTS.CASSANDRA_IP.split(',')
}

// tslint:disable-next-line: no-any
function getConsistencyLevel(consistencyParam: any) {
// tslint:disable-next-line: max-line-length
return (consistencyParam && _.get(expressCassandra, `consistencies.${consistencyParam}`) ? _.get(expressCassandra, `consistencies.${consistencyParam}`) : expressCassandra.consistencies.one)
}
// tslint:disable-next-line: no-console
console.log('getIPList method : ', getIPList())
module.exports = {
db: {
cassandra: {
contactPoints: getIPList(),
defaultKeyspaceSettings: {
replication: replicationStrategy,
},
queryOptions: {
consistency,
// prepare: true,
},
},
couchdb: {
url: '',
},
elasticsearch: {
disabledApis: [],
host: '',
},
pouchdb: {
path: '',
},
},
logLevel: 'error',
pluginBasePath: __dirname + '/../node_modules/',
plugins: [
{ id: '@project-sunbird/form-service', ver: '1.0'},
// { id: '@project-sunbird/review-comment', ver: '1.0' },
// { id: '@project-sunbird/discussion-service', ver: '1.0' }
// { id: '@project-sunbird/program', ver: '1.0' }
],
telemetry: {
authtoken: 'Bearer ' + CONSTANTS.SB_API_KEY,
batchsize: 1,
channel: '', // should fetch default channel by making api call
dispatcher: 'http', // default
endpoint: 'v1/telemetry',
env: process.env.sunbird_environment,
host: CONSTANTS.TELEMETRY_SB_BASE,
pdata: {
id: CONSTANTS.CORS_ENVIRONMENT + '-sunbird-cb-uiproxy',
pid: 'sunbird-cb-uiproxy',
ver: packageObj.version,
},
runningEnv: 'server',
// apislug: '', // not needed in portal
uid: uuidv1(),
},
}
56 changes: 51 additions & 5 deletions src/protectedApi_v8/user/profile-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
const sbphoneVerified_ = false
const sbfirstName_ = req.body.personalDetails.firstName
const sbphone_ = req.body.personalDetails.phone
const sbdob_ = req.body.personalDetails.dob
const sbdomicileMedium_ = req.body.personalDetails.domicileMedium
const sbgender_ = req.body.personalDetails.gender
const sbpincode_ = req.body.personalDetails.pincode
const sbcategory_ = req.body.personalDetails.category
const sbgroup_ = req.body.personalDetails.group
const sbdesignation_ = req.body.personalDetails.designation
const isEmailRequired = (req.body.personalDetails.isEmailRequired) ? req.body.personalDetails.isEmailRequired : true
const userRoles = (req.body.personalDetails.roles) ? req.body.personalDetails.roles : undefined
let sbUserProfile: Partial<ISBUser> = {
Expand Down Expand Up @@ -360,12 +367,17 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
},
mandatoryFieldsExists: false,
personalDetails: {
category : sbcategory_,
dob: sbdob_,
domicileMedium: sbdomicileMedium_,
firstname: sbfirstName_,
gender: sbgender_,
mobile: Number(sbphone_),
phoneVerified: sbphoneVerified_,
pinCode: Number(sbpincode_),
primaryEmail: sbemail_,
},
verifiedKarmayogi: false,
profileStatus: 'NOT-VERIFIED',
},
userId: sbUserId,
}
Expand All @@ -376,14 +388,48 @@ profileDeatailsApi.post('/createUser', async (req, res) => {
sbProfileUpdateReq.profileDetails.personalDetails = _.omit(sbProfileUpdateReq.profileDetails.personalDetails, 'mobile')
}

if (req.body.personalDetails.designation) {
if (sbdob_ === undefined || sbdob_ === '') {
// tslint:disable-next-line: all
sbProfileUpdateReq.profileDetails.personalDetails = _.omit(sbProfileUpdateReq.profileDetails.personalDetails, 'dob')
}
if (sbdomicileMedium_ === undefined || sbdomicileMedium_ === '') {
// tslint:disable-next-line: all
sbProfileUpdateReq.profileDetails.personalDetails = _.omit(sbProfileUpdateReq.profileDetails.personalDetails, 'domicileMedium')
}
if (sbpincode_ === undefined || sbpincode_ === '') {
// tslint:disable-next-line: all
sbProfileUpdateReq.profileDetails.personalDetails = _.omit(sbProfileUpdateReq.profileDetails.personalDetails, 'pinCode')
}
if (sbgender_ === undefined || sbgender_ === '') {
// tslint:disable-next-line: all
sbProfileUpdateReq.profileDetails.personalDetails = _.omit(sbProfileUpdateReq.profileDetails.personalDetails, 'gender')
}
if (sbcategory_ === undefined || sbcategory_ === '') {
// tslint:disable-next-line: all
sbProfileUpdateReq.profileDetails.personalDetails = _.omit(sbProfileUpdateReq.profileDetails.personalDetails, 'category')
}
if (req.body.personalDetails.designation || req.body.personalDetails.group) {
const arrDesignation = []
const objDesignation = {
designation: (req.body.personalDetails.designation) ? req.body.personalDetails.designation : '',
let objDesignation = {
designation: sbdesignation_,
group: sbgroup_,
}
if (sbdesignation_ === undefined || sbdesignation_ === '') {
objDesignation = _.omit(objDesignation, 'designation')
}
if (sbgroup_ === undefined || sbgroup_ === '') {
objDesignation = _.omit(objDesignation, 'group')
}
arrDesignation.push(objDesignation)
const profDetailsPropertyName = 'professionalDetails'
sbProfileUpdateReq[profDetailsPropertyName] = arrDesignation
sbProfileUpdateReq.profileDetails[profDetailsPropertyName] = arrDesignation
}
if (req.body.personalDetails.tags) {
const objAdditionalProperties = {
tag: (req.body.personalDetails.tags) ? req.body.personalDetails.tags : '',
}
const additionalPropertiesPropertyName = 'additionalProperties'
sbProfileUpdateReq.profileDetails[additionalPropertiesPropertyName] = objAdditionalProperties
}

const sbUserProfileUpdateResp = await axios({
Expand Down
23 changes: 22 additions & 1 deletion src/proxies_v8/proxies_v8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
proxyAssessmentRead,
proxyContent,
proxyContentLearnerVM,
proxyCreatorForms,
proxyCreatorKnowledge,
proxyCreatorLearner,
proxyCreatorQML,
Expand Down Expand Up @@ -258,6 +259,17 @@ proxiesV8.use('/halloffame/learnerleaderboard',
// tslint:disable-next-line: max-line-length
proxyCreatorSunbirdSearch(express.Router(), `${CONSTANTS.KONG_API_BASE}/halloffame/learnerleaderboard`)
)

proxiesV8.use('/microsite/read/insights',
// tslint:disable-next-line: max-line-length
proxyCreatorSunbirdSearch(express.Router(), `${CONSTANTS.KONG_API_BASE}/microsite/read/insights`)
)

proxiesV8.use('/msite/content/aggregation/search',
// tslint:disable-next-line: max-line-length
proxyCreatorSunbirdSearch(express.Router(), `${CONSTANTS.KONG_API_BASE}/msite/content/aggregation/search`)
)

proxiesV8.get(['/api/user/v2/read', '/api/user/v2/read/:id'], async (req, res) => {
const host = req.get('host')
const originalUrl = req.originalUrl
Expand Down Expand Up @@ -379,7 +391,7 @@ proxiesV8.use('/dashboard/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)
// tslint:disable-next-line:max-line-length
proxiesV8.post(['/user/v1/bulkupload', '/storage/profilePhotoUpload/*', '/workflow/admin/transition/bulkupdate', '/cloud-services/mlcore/v1/files/upload', '/calendar/v1/bulkUpload'], (req, res) => {
proxiesV8.post(['/user/v1/bulkupload', '/storage/profilePhotoUpload/*', '/workflow/admin/transition/bulkupdate', '/cloud-services/mlcore/v1/files/upload', '/calendar/v1/bulkUpload', '/storage/orgStoreUpload'], (req, res) => {
if (req.files && req.files.data) {
const url = removePrefix('/proxies/v8', req.originalUrl)
const file: UploadedFile = req.files.data as UploadedFile
Expand Down Expand Up @@ -690,6 +702,10 @@ proxiesV8.use('/observationSubmissions/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

proxiesV8.use('/demand/content/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

function removePrefix(prefix: string, s: string) {
return s.substr(prefix.length)
}
Expand Down Expand Up @@ -954,3 +970,8 @@ export interface ICohortsUser {
userLocation: string
city: string
}

proxiesV8.use('/ext-forms/*',
// tslint:disable-next-line: max-line-length
proxyCreatorForms(express.Router())
)
18 changes: 17 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import { proxiesV8 } from './proxies_v8/proxies_v8'
import { publicApiV8 } from './publicApi_v8/publicApiV8'
import { CustomKeycloak } from './utils/custom-keycloak'
import { CONSTANTS } from './utils/env'
import { logInfo, logSuccess } from './utils/logger'
import { logError, logInfo, logSuccess } from './utils/logger'
const { frameworkAPI } = require('@project-sunbird/ext-framework-server/api')
const frameworkConfig = require('./configs/framework.config')
const cookieParser = require('cookie-parser')
const healthcheck = require('express-healthcheck')

Expand Down Expand Up @@ -62,6 +64,7 @@ export class Server {
this.authoringApi()
this.resetCookies()
this.app.use(haltOnTimedOut)
this.setExtFormsFramework()
}

private setCookie() {
Expand Down Expand Up @@ -140,6 +143,15 @@ export class Server {
this.app.use(this.keycloak.middleware)
}

private setExtFormsFramework() {
logInfo('setExtFormsFramework MEthod - frameworkConfig :: ', JSON.stringify(frameworkConfig))
// tslint:disable-next-line: no-any
frameworkAPI.bootstrap(frameworkConfig, this.app).then((data: any) => {
logInfo('Successfuly bootstrapped frameworkAPI', data)
})
// tslint:disable-next-line: no-any
.catch((error: any ) => logError('Error in frameworkAPI bootstrap', error))
}
private servePublicApi() {
this.app.use('/public/v8', publicApiV8)
}
Expand Down Expand Up @@ -180,4 +192,8 @@ export class Server {
res.redirect(redirectUrl)
})
}

// private handleShutDowns() {
// await frameworkAPI.closeCassandraConnections();
// }
}
1 change: 1 addition & 0 deletions src/utils/apiWhiteList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const checkIsStaticRoute = (REQ_URL: any) => {
'/content-plugins/',
'/editors/',
'/public/',
'/v1/form/read',
]
// tslint:disable-next-line: no-any
return _.some(excludePath, (path: any) => _.includes(REQ_URL, path))
Expand Down
14 changes: 14 additions & 0 deletions src/utils/proxyCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const proxyCreator = (timeout = 10000) => createProxyServer({
const proxy = createProxyServer({})
const PROXY_SLUG = '/proxies/v8'
const PROXY_SLUG_WAT = '/proxies/v8/wat'
const PROXY_SLUG_FORMS = '/proxies/v8/ext-forms'

// tslint:disable-next-line: no-any
proxy.on('proxyReq', (proxyReq: any, req: any, _res: any, _options: any) => {
Expand Down Expand Up @@ -350,3 +351,16 @@ export function proxyQuestionRead(route: Router, targetUrl: string, _timeout = 1
})
return route
}

export function proxyCreatorForms(route: Router, _timeout = 10000): Router {
route.all('/*', (req, res) => {
// tslint:disable-next-line: no-console
console.log('REQ_URL_ORIGINAL proxyCreatorSunbird', req.originalUrl)
let url = ''
url = removePrefix(`${PROXY_SLUG_FORMS}`, req.originalUrl)
proxy.web(req, res, {
target: 'http://localhost:3003/' + url,
})
})
return route
}
Loading