|
|
@@ -20,12 +20,13 @@ const validator = {
|
|
|
list: [
|
|
|
query('limit').optional().isInt({ max: 100 }).withMessage('limit must be a number less than or equal to 100'),
|
|
|
query('offset').optional().isInt().withMessage('page must be a number'),
|
|
|
+ query('query').optional().isString().withMessage('query must be a string'),
|
|
|
],
|
|
|
};
|
|
|
|
|
|
const apiLimiter = rateLimit({
|
|
|
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
|
- max: 10, // limit each IP to 10 requests per windowMs
|
|
|
+ max: 30, // limit each IP to 30 requests per windowMs
|
|
|
message:
|
|
|
'Too many requests sent from this IP, please try again after 15 minutes.',
|
|
|
});
|
|
|
@@ -41,9 +42,10 @@ module.exports = (crowi: Crowi): Router => {
|
|
|
router.get('/', apiLimiter, accessTokenParser, loginRequiredStrictly, adminRequired, validator.list, apiV3FormValidator, async(req: Request, res: ApiV3Response) => {
|
|
|
const limit = req.query.limit || await crowi.configManager?.getConfig('crowi', 'customize:showPageLimitationS') || 10;
|
|
|
const offset = req.query.offset || 1;
|
|
|
+ const query = req.query.query as string || '';
|
|
|
|
|
|
try {
|
|
|
- const paginationResult = await Activity.getPaginatedActivity(limit, offset);
|
|
|
+ const paginationResult = await Activity.getPaginatedActivity(limit, offset, JSON.parse(query));
|
|
|
|
|
|
const User = crowi.model('User');
|
|
|
const serializedDocs = paginationResult.docs.map((doc: IActivity) => {
|