Skip to content

Commit a6173a9

Browse files
Merge branch 'develop' of https://github.com/topcoder-platform/challenge-api into new-readme
2 parents edeb224 + 7f1c869 commit a6173a9

File tree

10 files changed

+314
-43
lines changed

10 files changed

+314
-43
lines changed

app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ const HttpStatus = require('http-status-codes')
1313
const logger = require('./src/common/logger')
1414
const interceptor = require('express-interceptor')
1515
const fileUpload = require('express-fileupload')
16+
const YAML = require('yamljs')
17+
const swaggerUi = require('swagger-ui-express')
18+
const challengeAPISwaggerDoc = YAML.load('./docs/swagger.yaml')
1619

1720
// setup express app
1821
const app = express()
1922

23+
// serve challenge V5 API swagger definition
24+
app.use('/v5/challenges/docs', swaggerUi.serve, swaggerUi.setup(challengeAPISwaggerDoc))
25+
2026
app.use(cors({
2127
exposedHeaders: [
2228
'X-Prev-Page',

config/default.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ module.exports = {
2222
KAFKA_ERROR_TOPIC: process.env.KAFKA_ERROR_TOPIC || 'common.error.reporting',
2323

2424
AMAZON: {
25-
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID || 'FAKE_ACCESS_KEY',
26-
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || 'FAKE_SECRET_ACCESS_KEY',
25+
// Uncomment for local deployment
26+
// AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID || 'FAKE_ACCESS_KEY',
27+
// AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || 'FAKE_SECRET_ACCESS_KEY',
2728
AWS_REGION: process.env.AWS_REGION || 'ap-northeast-1',
2829
IS_LOCAL_DB: process.env.IS_LOCAL_DB ? process.env.IS_LOCAL_DB === 'true' : true,
2930
DYNAMODB_URL: process.env.DYNAMODB_URL || 'http://localhost:7777',
@@ -45,7 +46,7 @@ module.exports = {
4546
? Number(process.env.FILE_UPLOAD_SIZE_LIMIT) : 50 * 1024 * 1024, // 50M
4647
RESOURCES_API_URL: process.env.RESOURCES_API_URL || 'http://localhost:4000/v5/resources',
4748
GROUPS_API_URL: process.env.GROUPS_API_URL || 'http://localhost:4000/v5/groups',
48-
PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v4/projects',
49+
PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v5/projects',
4950
// copilot resource role ids allowed to upload attachment
5051
COPILOT_RESOURCE_ROLE_IDS: process.env.COPILOT_RESOURCE_ROLE_IDS
5152
? process.env.COPILOT_RESOURCE_ROLE_IDS.split(',') : ['10ba038e-48da-487b-96e8-8d3b99b6d18b'],

mock-api/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ app.get('/v5/resources/:memberId/challenges', (req, res) => {
6464
})
6565

6666
// get project by id
67-
app.get('/v4/projects/:projectId', (req, res) => {
67+
app.get('/v5/projects/:projectId', (req, res) => {
6868
const projectId = req.params.projectId
6969
if (projectId === '111' || projectId === '123' || projectId === '112233') {
7070
res.end()

package-lock.json

Lines changed: 41 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@
4949
"jsonwebtoken": "^8.3.0",
5050
"lodash": "^4.17.11",
5151
"moment": "^2.24.0",
52+
"swagger-ui-express": "^4.1.3",
5253
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6.2",
5354
"topcoder-bus-api-wrapper": "topcoder-platform/tc-bus-api-wrapper.git",
5455
"uuid": "^3.3.2",
55-
"winston": "^3.1.0"
56+
"winston": "^3.1.0",
57+
"yamljs": "^0.3.0"
5658
},
5759
"standard": {
5860
"ignore": [

src/models/Challenge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const schema = new Schema({
9696
},
9797
// winners
9898
winners: {
99-
type: [Object],
99+
type: Array,
100100
required: false
101101
},
102102
created: {

src/models/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
const config = require('config')
66
const dynamoose = require('dynamoose')
77

8-
dynamoose.AWS.config.update({
9-
// accessKeyId: config.AMAZON.AWS_ACCESS_KEY_ID,
10-
// secretAccessKey: config.AMAZON.AWS_SECRET_ACCESS_KEY,
8+
const awsConfigs = config.AMAZON.IS_LOCAL_DB ? {
9+
accessKeyId: config.AMAZON.AWS_ACCESS_KEY_ID,
10+
secretAccessKey: config.AMAZON.AWS_SECRET_ACCESS_KEY,
1111
region: config.AMAZON.AWS_REGION
12-
})
12+
} : {
13+
region: config.AMAZON.AWS_REGION
14+
}
15+
16+
dynamoose.AWS.config.update(awsConfigs)
1317

1418
if (config.AMAZON.IS_LOCAL_DB) {
1519
dynamoose.local(config.AMAZON.DYNAMODB_URL)

src/routes.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ module.exports = {
9292
'/challengeTimelines': {
9393
get: {
9494
controller: 'ChallengeTypeTimelineTemplateController',
95-
method: 'searchChallengeTypeTimelineTemplates',
96-
auth: 'jwt',
97-
access: [constants.UserRoles.Admin, constants.UserRoles.Copilot],
98-
scopes: [CHALLENGE_TYPE_TIMELINE_TEMPLATES.READ, CHALLENGE_TYPE_TIMELINE_TEMPLATES.ALL]
95+
method: 'searchChallengeTypeTimelineTemplates'
96+
// auth: 'jwt',
97+
// access: [constants.UserRoles.Admin, constants.UserRoles.Copilot],
98+
// scopes: [CHALLENGE_TYPE_TIMELINE_TEMPLATES.READ, CHALLENGE_TYPE_TIMELINE_TEMPLATES.ALL]
9999
},
100100
post: {
101101
controller: 'ChallengeTypeTimelineTemplateController',
@@ -108,10 +108,10 @@ module.exports = {
108108
'/challengeTimelines/:challengeTypeTimelineTemplateId': {
109109
get: {
110110
controller: 'ChallengeTypeTimelineTemplateController',
111-
method: 'getChallengeTypeTimelineTemplate',
112-
auth: 'jwt',
113-
access: [constants.UserRoles.Admin, constants.UserRoles.Copilot],
114-
scopes: [CHALLENGE_TYPE_TIMELINE_TEMPLATES.READ, CHALLENGE_TYPE_TIMELINE_TEMPLATES.ALL]
111+
method: 'getChallengeTypeTimelineTemplate'
112+
// auth: 'jwt',
113+
// access: [constants.UserRoles.Admin, constants.UserRoles.Copilot],
114+
// scopes: [CHALLENGE_TYPE_TIMELINE_TEMPLATES.READ, CHALLENGE_TYPE_TIMELINE_TEMPLATES.ALL]
115115
},
116116
put: {
117117
controller: 'ChallengeTypeTimelineTemplateController',

0 commit comments

Comments
 (0)