Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 8b460ae

Browse files
Merge branch 'develop'
2 parents 532e405 + d98f4cd commit 8b460ae

15 files changed

+1798
-7
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Wrapper library for Topcoder Submission API
2929
- AUTH0_CLIENT_SECRET - the auth0 client secret, used as credential
3030
- AUTH0_PROXY_SERVER_URL - (optional) the auth0 proxy server url
3131
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder-dev.com/v5`
32+
- PAGE - the page number
33+
- PER_PAGE - the page size
34+
- MAX_PAGE_SIZE - the max number of page size
3235

3336
3. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments
3437

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
* Index file
33
*/
44

5+
const _ = require('lodash')
56
const joi = require('@hapi/joi')
67

7-
module.exports = (config) => {
8+
module.exports = (allConfig) => {
89
/**
910
* The configuration object schema.
1011
* AUTH0_URL: the auth0 url
@@ -25,6 +26,9 @@ module.exports = (config) => {
2526
AUTH0_PROXY_SERVER_URL: joi.string()
2627
})
2728

29+
// Pick auth config
30+
const config = _.pick(allConfig, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
31+
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL', 'AUTH0_PROXY_SERVER_URL' ])
2832
// Validate the arguments
2933
const result = joi.validate(config, schema)
3034

package-lock.json

Lines changed: 36 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"scripts": {
77
"lint": "standard",
88
"lint:fix": "standard --fix",
9-
"test": "mocha test/*.test.js --timeout 30000 --exit",
10-
"cov": "nyc --reporter=html --reporter=text mocha test/*.test.js --timeout 30000 --exit"
9+
"test": "mocha test/*.test.js --require test/prepare.js --timeout 30000 --exit",
10+
"cov": "nyc --reporter=html --reporter=text mocha test/*.test.js --require test/prepare.js --timeout 30000 --exit"
1111
},
1212
"dependencies": {
1313
"@hapi/joi": "^15.0.3",
@@ -18,8 +18,11 @@
1818
"devDependencies": {
1919
"chai": "^4.2.0",
2020
"mocha": "^6.1.4",
21+
"mocha-prepare": "^0.1.0",
22+
"nock": "^9.4.4",
2123
"nyc": "^14.1.1",
22-
"standard": "^12.0.1"
24+
"standard": "^12.0.1",
25+
"uuid": "^3.3.2"
2326
},
2427
"standard": {
2528
"env": [

test/WrapperInitialization.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
const _ = require('lodash')
66
const should = require('chai').should()
7-
const config = require('./testConfig')
7+
const allConfig = require('./testConfig')
88
const api = require('../index')
99

10+
// Pick auth config
11+
const config = _.pick(allConfig, ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
12+
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL', 'AUTH0_PROXY_SERVER_URL' ])
13+
1014
describe('Wrapper Initialization Tests', () => {
1115
for (const key in config) {
1216
it(`Configuration ${key} is missing`, () => {

test/common/bootstrap.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Initialize test env
3+
*/
4+
const joi = require('@hapi/joi')
5+
const config = require('../testConfig')
6+
7+
joi.id = () => joi.number().integer().min(1)
8+
joi.score = () => joi.number()
9+
joi.pageSize = () => joi.number().integer().min(1).max(config.MAX_PAGE_SIZE)

0 commit comments

Comments
 (0)