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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ workflows:
- pm-3454
- use-pnpm
- PM-3458
- pm-3318

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
6 changes: 6 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ module.exports = {
MAMBO_PRIVATE_KEY: process.env.MAMBO_PRIVATE_KEY,
MAMBO_DOMAIN_URL: process.env.MAMBO_DOMAIN_URL,
MAMBO_DEFAULT_SITE: process.env.MAMBO_DEFAULT_SITE,

// Learning Paths API
LEARNING_PATHS_API_URL: process.env.LEARNING_PATHS_API_URL || 'https://api.topcoder-dev.com/v5/learning-paths',

// Gamification API
GAMIFICATION_API_URL: process.env.GAMIFICATION_API_URL || 'https://api.topcoder-dev.com/v5/gamification',

HASHING_KEYS: {
USERFLOW: process.env.USERFLOW_PRIVATE_KEY
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "TopCoder Member V6 API",
"main": "app.js",
"scripts": {
"postinstall": "prisma generate --schema=prisma/schema.prisma && prisma generate --schema=prisma/identity-schema.prisma",
"postinstall": "prisma generate --schema=prisma/schema.prisma",
"start": "node app.js",
"start:dev": "nodemon app.js",
"lint": "standard",
Expand Down Expand Up @@ -36,6 +36,8 @@
"@topcoder/resource-api-v6": "topcoder-platform/resource-api-v6.git#develop",
"@topcoder/standardized-skills-api": "topcoder-platform/standardized-skills-api.git#develop",
"@topcoder/tc-finance-api": "topcoder-platform/tc-finance-api.git#dev",
"@topcoder/tc-identity-service": "topcoder-platform/identity-api-v6.git#develop",
"react-pdf-html": "^2.1.5",
"@topcoder/engagements-api-v6": "topcoder-platform/engagements-api-v6.git#develop",
"aws-sdk": "^2.466.0",
"axios": "^0.27.2",
Expand All @@ -55,6 +57,8 @@
"lodash": "^4.17.19",
"mime-types": "^2.1.35",
"moment": "^2.27.0",
"moment-timezone": "^0.5.43",
"city-timezones": "^1.3.2",
"mysql2": "^3.14.3",
"prisma": "^6.10.1",
"qs": "^6.14.1",
Expand Down
402 changes: 401 additions & 1 deletion pnpm-lock.yaml

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions prisma/identity-schema.prisma

This file was deleted.

6 changes: 6 additions & 0 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ async function getMemberGroups (memberId) {
* @returns {Promise}
*/
const getM2MToken = () => {
if (!config.AUTH0_URL) {
throw new Error('AUTH0_URL is not configured. Please set AUTH0_URL environment variable or add it to config.')
}
if (!config.AUTH0_CLIENT_ID || !config.AUTH0_CLIENT_SECRET) {
throw new Error('AUTH0_CLIENT_ID and AUTH0_CLIENT_SECRET must be configured for M2M authentication.')
}
return m2m.getMachineToken(
config.AUTH0_CLIENT_ID,
config.AUTH0_CLIENT_SECRET
Expand Down
31 changes: 31 additions & 0 deletions src/common/htmlUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Convert HTML to plain text (strip tags, decode entities).
* Used for achievements/badge content in PDF so unregistered fonts (e.g. Roboto) are never passed to the renderer.
* @param {string} html - HTML string
* @returns {string} plain text
*/
function htmlToText (html) {
if (!html || typeof html !== 'string') return ''

let out = html
// Strip all tags: replace with space so words don't glue together
.replace(/<[^>]*>/g, ' ')
// Collapse whitespace
.replace(/\s+/g, ' ')
.trim()

// Decode common HTML entities
out = out
.replace(/&nbsp;/gi, ' ')
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
.replace(/&quot;/gi, '"')
.replace(/&#39;/gi, "'")
.replace(/&amp;/gi, '&')

return out
}

module.exports = {
htmlToText
}
23 changes: 16 additions & 7 deletions src/common/identityPrisma.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
const config = require('config')
const errors = require('./errors')
const { PrismaClient: IdentityPrismaClient } = require('../../prisma/generated/identity-client')
const { PrismaClient: IdentityExternalPrismaClient } = require('@topcoder/tc-identity-service/packages/identity-prisma-client')

let identityClient

const clientOptions = {
transactionOptions: {
timeout: config.MEMBER_SERVICE_PRISMA_TIMEOUT,
},
log: [
{ level: 'query', emit: 'event' },
{ level: 'info', emit: 'event' },
{ level: 'warn', emit: 'event' },
{ level: 'error', emit: 'event' }
]
}

function getIdentityClient () {
if (!config.IDENTITY_DB_URL) {
throw new errors.BadRequestError('IDENTITY_DB_URL is not configured')
}

if (!identityClient) {
identityClient = new IdentityPrismaClient({
datasources: {
identitydb: {
url: config.IDENTITY_DB_URL
}
}
identityClient = new IdentityExternalPrismaClient({
...clientOptions,
datasources: { db: { url: config.IDENTITY_DB_URL } }
})
}

Expand Down
Loading
Loading