mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
fix(reader): skip throttling for EPUB file streams (#410)
Allow authenticated EPUB archive file requests to bypass the global request throttle so the streaming reader can load fragmented books without tripping 429 responses. Keep the existing access and archive path checks in place. Fixes: #409
This commit is contained in:
@@ -82,6 +82,10 @@ describe('EpubController', () => {
|
||||
expect(reply.header).toHaveBeenCalledWith('Cache-Control', 'public, max-age=3600');
|
||||
});
|
||||
|
||||
it('skips global throttling for EPUB archive file streams', () => {
|
||||
expect(Reflect.getMetadata('THROTTLER:SKIPdefault', EpubController.prototype.getFile)).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects malformed encoded file paths', async () => {
|
||||
await expect(
|
||||
controller.getFile(9, 'OPS/text/%E0%A4%A', undefined, { id: 1, isSuperuser: false, permissions: [] } as any, {} as any),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BadRequestException, Controller, Get, Param, ParseIntPipe, Query, Res } from '@nestjs/common';
|
||||
import { SkipThrottle } from '@nestjs/throttler';
|
||||
import type { FastifyReply } from 'fastify';
|
||||
|
||||
import { CurrentUser } from '../../../common/decorators/current-user.decorator';
|
||||
@@ -14,6 +15,7 @@ export class EpubController {
|
||||
return this.epubService.getBookInfo(bookId, this.parseFileId(fileId), user);
|
||||
}
|
||||
|
||||
@SkipThrottle()
|
||||
@Get(':bookId/file/*')
|
||||
async getFile(
|
||||
@Param('bookId', ParseIntPipe) bookId: number,
|
||||
|
||||
Reference in New Issue
Block a user