feat: refs #7524 check noLimit method key
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-09-10 13:21:56 +02:00
parent d98f0a2493
commit 1ff1a97f29
1 changed files with 2 additions and 7 deletions

View File

@ -28,7 +28,7 @@ module.exports = function(Self) {
});
this.beforeRemote('**', async ctx => {
if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return;
if (ctx.method.noLimit || !this.hasFilter(ctx)) return;
const defaultLimit = this.app.orm.selectLimit;
const filter = ctx.args.filter || {limit: defaultLimit};
@ -40,7 +40,7 @@ module.exports = function(Self) {
});
this.afterRemote('**', async ctx => {
if (this.hasNoLimit(ctx) || !this.hasFilter(ctx)) return;
if (ctx.method.noLimit || !this.hasFilter(ctx)) return;
const {result} = ctx;
const length = Array.isArray(result) ? result.length : result ? 1 : 0;
@ -352,10 +352,5 @@ module.exports = function(Self) {
return ctx.req.method.toUpperCase() === 'GET' &&
ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object');
},
hasNoLimit(ctx) {
return ctx.method.accepts.some(x => x.arg.toLowerCase() === 'nolimit') && ctx.args.noLimit;
}
});
};