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

Sync master with dev #38

Merged
merged 13 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Set the api prefix
  • Loading branch information
callmekatootie committed Oct 28, 2020
commit e85a0c28e383425b3ac9a92989d7a929e71d8614
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The following parameters can be set in config files or in env variables:

- LOG_LEVEL: the log level
- PORT: the server port
- API_VERSION: the API version
- CHALLENGE_API_URL: the Topcoder challenge API URL
- MEMBER_API_URL: the Topcoder member API URL
- AUTH0_URL: Auth0 URL, used to get TC M2M token
Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module.exports = {
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
PORT: process.env.PORT || 3000,
API_VERSION: process.env.API_VERSION || '/v5',
AUTH_SECRET: process.env.AUTH_SECRET || 'mysecret',
VALID_ISSUERS: process.env.VALID_ISSUERS ? process.env.VALID_ISSUERS.replace(/\\"/g, '')
: '["https://topcoder-dev.auth0.com/", "https://api.topcoder.com"]',
Expand Down
6 changes: 1 addition & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ app.use(cors())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))

const apiRouter = express.Router()

// load all routes
_.each(routes, (verbs, url) => {
_.each(verbs, (def, verb) => {
Expand Down Expand Up @@ -102,12 +100,10 @@ _.each(routes, (verbs, url) => {
}

actions.push(method)
apiRouter[verb](url, helper.autoWrapExpress(actions))
app[verb](`${config.API_VERSION}${url}`, helper.autoWrapExpress(actions))
})
})

app.use('/v5/', apiRouter)

app.use((err, req, res, next) => {
logger.logFullError(err, req.signature)
const errorResponse = {}
Expand Down