Skip to content

[Backend] stream.controller.ts.listStreams: extract magic limit cap of 100 to a constant #669

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

backend/src/controllers/stream.controller.ts lines 167-171:

const parsedLimit = Math.min(
  typeof limit === 'string' ? (Number.parseInt(limit, 10) || 20) : 20,
  100
);

The 20 default and 100 cap are unexplained inline magic. The events listing in the same file (line 282-285) uses different magic numbers (50 default, 500 cap). The user-events controller (backend/src/controllers/user.controller.ts:80-82) uses yet another (50 default, 200 cap). Three pagination tunables — none named.

Acceptance criteria

  • Define DEFAULT_STREAM_PAGE_SIZE = 20, MAX_STREAM_PAGE_SIZE = 100 at module scope in stream.controller.ts
  • Do the same for the events listing (DEFAULT_EVENTS_PAGE_SIZE, MAX_EVENTS_PAGE_SIZE) and the user-events controller
  • Reuse the events listing's existing MAX_EVENT_LIMIT/DEFAULT_EVENT_LIMIT already declared in routes/v1/events.routes.ts:24-25 for consistency

Files to touch

  • backend/src/controllers/stream.controller.ts (lines 167-171, 282-285)
  • backend/src/controllers/user.controller.ts (lines 80-82)

Out of scope

  • Introducing a shared pagination middleware

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomersrefactorRefactoring existing code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions