Skip to content

Commit babf337

Browse files
Add prizes and phases
1 parent 840c8d2 commit babf337

25 files changed

+9678
-1339
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ aws dynamodb scan --table-name Challenge --endpoint-url http://localhost:7777
4747
aws dynamodb scan --table-name ChallengeType --endpoint-url http://localhost:7777
4848
aws dynamodb scan --table-name ChallengeSetting --endpoint-url http://localhost:7777
4949
aws dynamodb scan --table-name AuditLog --endpoint-url http://localhost:7777
50+
aws dynamodb scan --table-name Phase --endpoint-url http://localhost:7777
51+
aws dynamodb scan --table-name TimelineTemplate --endpoint-url http://localhost:7777
5052
```
5153

5254
## Local Deployment
@@ -57,7 +59,6 @@ aws dynamodb scan --table-name AuditLog --endpoint-url http://localhost:7777
5759
- Start app `npm start`
5860
- App is running at `http://localhost:3000`
5961
- Clear and init db `npm run init-db`
60-
- Insert test data `npm run test-data`
6162

6263
## Verification
6364
Refer to the verification document `Verification.md`

Verification.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
## Postman tests
44
- import Postman collection and environment in the docs folder to Postman
5-
- note that the Postman tests depend on the test data, so you must first run `npm run init-db` and `npm run test-data` to setup test data
65
- Just run the whole test cases under provided environment.
76

87
## DynamoDB Verification
@@ -14,4 +13,6 @@ aws dynamodb scan --table-name Challenge --endpoint-url http://localhost:7777
1413
aws dynamodb scan --table-name ChallengeType --endpoint-url http://localhost:7777
1514
aws dynamodb scan --table-name ChallengeSetting --endpoint-url http://localhost:7777
1615
aws dynamodb scan --table-name AuditLog --endpoint-url http://localhost:7777
16+
aws dynamodb scan --table-name Phase --endpoint-url http://localhost:7777
17+
aws dynamodb scan --table-name TimelineTemplate --endpoint-url http://localhost:7777
1718
```

app-bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
global.Promise = require('bluebird')
55
const Joi = require('joi')
66

7-
Joi.optionalId = () => Joi.string()
7+
Joi.optionalId = () => Joi.string().uuid()
88
Joi.id = () => Joi.optionalId().required()
99
Joi.page = () => Joi.number().integer().min(1).default(1)
1010
Joi.perPage = () => Joi.number().integer().min(1).max(100).default(20)

app-constants.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ const UserRoles = {
66
Copilot: 'Copilot'
77
}
88

9+
const prizeSetTypes = {
10+
Code: 'Code',
11+
F2F: 'First to Finish',
12+
CheckPoint: 'Check Point',
13+
MM: 'Marathon'
14+
}
15+
16+
const prizeTypes = {
17+
First: 'first place',
18+
Second: 'second place',
19+
Third: 'third place',
20+
Fouth: 'fourth place',
21+
Fifth: 'fifth place'
22+
}
23+
924
module.exports = {
10-
UserRoles
25+
UserRoles,
26+
prizeSetTypes,
27+
prizeTypes
1128
}

app-routes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ module.exports = (app) => {
3232

3333
// add Authenticator check if route has auth
3434
if (def.auth) {
35+
actions.push((req, res, next) => {
36+
if (_.get(req, 'query.token')) {
37+
_.set(req, 'headers.authorization', `Bearer ${_.trim(req.query.token)}`)
38+
}
39+
next()
40+
})
41+
3542
actions.push((req, res, next) => {
3643
authenticator(_.pick(config, ['AUTH_SECRET', 'VALID_ISSUERS']))(req, res, next)
3744
})

app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ app.use(interceptor((req, res) => {
3737
}
3838
if (obj && obj.result && obj.result.content && obj.result.content.message) {
3939
const ret = { message: obj.result.content.message }
40+
res.statusCode = 401
4041
send(JSON.stringify(ret))
4142
} else {
4243
send(body)

0 commit comments

Comments
 (0)