-
Notifications
You must be signed in to change notification settings - Fork 3
Review Opportunities #6
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public" | ||
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public" | ||
# API configs | ||
BUS_API_URL="https://api.topcoder-dev.com/v5/bus/events" | ||
CHALLENGE_API_URL="https://api.topcoder-dev.com/v5/challenges/" | ||
MEMBER_API_URL="https://api.topcoder-dev.com/v5/members" | ||
# M2m configs | ||
M2M_AUTH_URL="https://auth0.topcoder-dev.com/oauth/token" | ||
M2M_AUTH_CLIENT_ID="jGIf2pd3f44B1jqvOai30BIKTZanYBfU" | ||
M2M_AUTH_CLIENT_SECRET="ldzqVaVEbqhwjM5KtZ79sG8djZpAVK8Z7qieVcC3vRjI4NirgcinKSBpPwk6mYYP" | ||
M2M_AUTH_DOMAIN="topcoder-dev.auth0.com" | ||
M2M_AUTH_AUDIENCE="https://m2m.topcoder-dev.com/" | ||
M2M_AUTH_PROXY_SEREVR_URL= | ||
#Sendgrid email templates | ||
SENDGRID_ACCEPT_REVIEW_APPLICATION="d-2de72880bd69499e9c16369398d34bb9" | ||
SENDGRID_REJECT_REVIEW_APPLICATION="d-82ed74e778e84d8c9bc02eeda0f44b5e" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
const express = require('express') | ||
const winston = require('winston') | ||
const cors = require('cors') | ||
|
||
const app = express() | ||
app.use(cors()) | ||
app.use(express.json()) | ||
app.set('port', 4000) | ||
|
||
const logger = winston.createLogger({ | ||
transports: [ | ||
new winston.transports.Console({ | ||
level: 'debug', | ||
format: winston.format.combine( | ||
winston.format.colorize(), | ||
winston.format.simple() | ||
), | ||
}), | ||
] | ||
}); | ||
|
||
// Event bus | ||
app.post('/eventBus', (req, res) => { | ||
logger.info(`Event Bus received message: ${JSON.stringify(req.body)}`); | ||
res.statusCode = 200; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of setting |
||
res.json({}) | ||
}) | ||
|
||
const m2mToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3RvcGNvZGVyLWRldi5hdXRoMC5jb20vIiwic3ViIjoiakdJZjJwZDNmNDRCMWpxdk9haTMwQklLVFphbllCZlVAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vbTJtLnRvcGNvZGVyLWRldi5jb20vIiwiaWF0IjoxNzQ4MDk5NDk4LCJleHAiOjE4NDgxODU4OTgsInNjb3BlIjoid3JpdGU6YnVzX2FwaSxhbGw6Y2hhbGxlbmdlcyIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyIsImF6cCI6ImpHSWYycGQzZjQ0QjFqcXZPYWkzMEJJS1RaYW5ZQmZVIn0.h3ksdsdJm5USGF1VgROrpkTtStmCzv5ZA6y8bd8AnGY'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Storing sensitive information such as tokens directly in the code is not secure. Consider using environment variables or a secure vault to manage sensitive data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @billsedison - We can't put these into any code, even if they are long since expired, due to security headaches they cause us in Wipro scans. Let's remove this and make it an env variable. |
||
|
||
const m2mScope = 'write:bus_api,all:challenges'; | ||
|
||
// Auth0 | ||
app.post('/oauth/token', (req, res) => { | ||
logger.info('Getting M2M tokens') | ||
res.json({ | ||
access_token: m2mToken, | ||
scope: m2mScope, | ||
expires_in: 94608000, | ||
token_type: 'Bearer' | ||
}) | ||
}) | ||
|
||
// Member API | ||
app.get('/members', (req, res) => { | ||
logger.info(`Member API receives params: ${JSON.stringify(req.query)}`) | ||
let userIdStr = req.query.userIds | ||
userIdStr = userIdStr.replaceAll('[', '').replaceAll(']', '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
const userIds = userIdStr.split(',') | ||
// return result | ||
const ret = userIds.map(id => ({ | ||
userId: parseInt(id), | ||
email: `${id}@topcoder.com` | ||
})) | ||
res.json(ret) | ||
}) | ||
|
||
// Challenge API | ||
app.get('/challenges/:id', (req, res) => { | ||
// directly challenge details | ||
const id = req.params.id | ||
logger.info(`Getting challenge with id ${id}`) | ||
if (id === '11111111-2222-3333-9999-444444444444') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
res.statusCode = 404 | ||
res.json({}) | ||
return | ||
} | ||
res.json({ | ||
id, | ||
name: `Test Challenge ${id}`, | ||
legacy: { | ||
track: 'DEVELOP', | ||
subTrack: 'CODE' | ||
}, | ||
numOfSubmissions: 2, | ||
legacyId: 30376875, | ||
tags: ['Prisma', 'NestJS'] | ||
}) | ||
}) | ||
|
||
|
||
app.listen(app.get('port'), '0.0.0.0', () => { | ||
logger.info(`Express server listening on port ${app.get('port')}`) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
M2M_AUTH_PROXY_SEREVR_URL
seems to have a typo in its name. It should likely beM2M_AUTH_PROXY_SERVER_URL
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@billsedison - Let's fix this thanks.