Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Configuration for the application is at config/default.js and config/production.
- AUTH_SECRET: TC Authentication secret
- VALID_ISSUERS: valid issuers for TC authentication
- PAGE_SIZE: the default pagination limit
- MAX_PAGE_SIZE: the maximum pagination size
- API_VERSION: the API version
- AWS_ACCESS_KEY_ID: The AWS access key
- AWS_SECRET_ACCESS_KEY: The AWS secret key
Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
: '["https://topcoder-dev.auth0.com/", "https://api.topcoder.com"]',

PAGE_SIZE: process.env.PAGE_SIZE || 20,
MAX_PAGE_SIZE: parseInt(process.env.MAX_PAGE_SIZE) || 100,
API_VERSION: process.env.API_VERSION || 'api/1.0',

AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
* add logger and joi to services
*/

const config = require('config')
const fs = require('fs')
const path = require('path')
const logger = require('./common/logger')
const joi = require('@hapi/joi')

joi.id = () => joi.number().integer().min(1)
joi.pageSize = () => joi.number().integer().min(1).max(config.get('MAX_PAGE_SIZE'))

/**
* add logger and joi schema to service
Expand Down
6 changes: 5 additions & 1 deletion src/common/service-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ function getServiceMethods (Model, createSchema, patchSchema, searchSchema, buil
}

search.schema = {
query: searchSchema,
query: {
page: joi.id(),
perPage: joi.pageSize(),
...searchSchema
},
auth: joi.object()
}

Expand Down