Skip to content

feat(routes-f): swift/bic validator, closed captions, mod team, and category tests#1082

Closed
omarima-10 wants to merge 291 commits into
StreamFi-x:mainfrom
omarima-10:fix/streamfi-hillwisdom-batch
Closed

feat(routes-f): swift/bic validator, closed captions, mod team, and category tests#1082
omarima-10 wants to merge 291 commits into
StreamFi-x:mainfrom
omarima-10:fix/streamfi-hillwisdom-batch

Conversation

@omarima-10

Copy link
Copy Markdown
Contributor

Summary

Four self-contained route implementations and tests inside app/api/routes-f/. No files modified outside that folder.

Changes

#433 — Category management endpoint tests

  • app/api/routes-f/__tests__/categories.test.ts: 6 tests covering GET list, POST create (admin/non-admin), GET by unknown slug, PATCH update, DELETE; mocks @vercel/postgres and @/lib/auth/verify-session

#790 — SWIFT/BIC code validator

  • app/api/routes-f/swift-bic/iso-countries.ts: inline 36-country ISO 3166-1 set
  • app/api/routes-f/swift-bic/route.ts: POST validates 8/11-char BIC regex, parses bank/country/location/branch fields
  • app/api/routes-f/swift-bic/route.test.ts: 5 tests (valid 8-char, valid 11-char, wrong length, unknown country, lowercase rejection)

#1035 — Closed captions toggle and data

  • app/api/routes-f/closed-captions/seed-tracks.ts: bundled caption track seed data
  • app/api/routes-f/closed-captions/route.ts: GET by playback_id or viewer_id, PUT to update prefs; in-memory store
  • app/api/routes-f/closed-captions/route.test.ts: 5 tests including GET→PUT→GET round-trip

#1055 — Channel mod team management

  • app/api/routes-f/mod-team/route.ts: GET/POST/DELETE with upsert semantics, 20-mod cap per creator; in-memory store
  • app/api/routes-f/mod-team/route.test.ts: 5 tests (list, assign, upsert role, delete, cap enforcement)

closes #433
closes #790
closes #1035
closes #1055

logantalen and others added 30 commits April 26, 2026 18:42
Add POST endpoint that decodes JWT header and payload without signature
verification. Returns decoded claims, warnings for expiration and missing
standard claims, and explicit 'not verified' notice. Includes tests for
valid, expired, and malformed tokens.

Refs StreamFi-x#572
Add POST endpoint for markdown-to-HTML conversion with heading extraction
and word counting. Supports headings, bold, italic, inline code, code blocks,
links, lists, and paragraphs. Sanitizes by default to strip scripts, event
handlers, and javascript: URLs. Preserves code block content exactly.

Refs StreamFi-x#635
add post /api/routes-f/feedback for anonymous feedback collection.

- validates message length (10-2000), category enum, optional contact
- strips html tags from message and contact before in-memory storage
- in-folder rate limiter: 5 submissions per ip per hour
- unit tests cover validation, html stripping, and rate limit per ip

scoped entirely to app/api/routes-f/feedback/; no shared lib changes.
closes StreamFi-x#566
ts1117: object literal had two 'right' entries (lines 11, 16).
removing the second (65) preserves the higher-frequency value (420).
unrelated to the feedback endpoint, but blocks ci typecheck across
all open prs; folding into this pr to unblock StreamFi-x#566.
- wrap if-body in braces (curly rule) in stripHtmlTags
- drop unused 'error' binding in catch in route.ts
mechanical lint fixes that block ci eslint on every open pr:
- wrap single-statement if/else bodies in braces (curly rule) across
  anagram, captcha-math, emoji, isbn, joke, palindrome, register,
  user-agent, viewer/history, word-frequency, and addfundsbutton.
- drop unused NextRequest import and dead 'usedTokens' set in
  captcha-math/route.ts.

unrelated to this pr's feature work, but folded in to unblock StreamFi-x#566;
each fix is mechanical and changes no runtime behavior.
feat: add clips, whitelist, feature flags, and user preferences
…fy (StreamFi-x#560-563)

All files scoped entirely to app/api/routes-f/ per task constraints.
No imports from lib/, utils/, types/, or components/.

StreamFi-x#560 — Feature flag store endpoint
- feature-flags/route.ts: GET (all / single / rollout check), PUT (create/update),
  DELETE. In-memory Map store in _lib/store.ts.
- Deterministic percentage rollout via djb2-style hash of (flagKey:userId).
- Tests cover CRUD, validation, rollout bucketing (~50% distribution check).

StreamFi-x#561 — Event ingestion with batching
- events/route.ts: POST accepts { event } or { events: [...] }, validates each
  event (required name+timestamp, optional properties object), rejects batches
  > 100. GET returns paginated results.
- Bounded ring-buffer of 10,000 events in _lib/buffer.ts; oldest evicted on
  overflow.
- Tests cover single/batch submit, validation, eviction, non-overlapping pages.

StreamFi-x#562 — UUID generator endpoint (v4 and v7)
- uuid/route.ts: GET ?version=v4|v7&count=1..100.
- uuid/_lib/generators.ts: inline uuidV4() and uuidV7() using crypto.getRandomValues();
  no external libraries.
- v4: random 128 bits with RFC 4122 version/variant bits.
- v7: 48-bit Unix-ms timestamp prefix for time-ordered sorting.
- Tests verify format, version nibble, variant bits, uniqueness, time-ordering.

StreamFi-x#563 — Slugify endpoint
- slugify/route.ts: POST { text, separator?, maxLength? } → { slug }.
- slugify/_lib/slugify.ts: NFD decomposition + diacritic strip, emoji removal,
  lowercase, separator collapse, word-boundary truncation.
- Tests cover 15+ varied inputs: diacritics, emoji, punctuation, truncation.
- avatar-initials/route.ts: GET ?name=...&size=128 returns image/svg+xml with
  Cache-Control: public, max-age=31536000 (deterministic output, 1-year cache).
- avatar-initials/_lib/avatar.ts: extractInitials (first+last word, max 2),
  clampSize (32-512), deterministic background via djb2 name hash → HSL hue,
  WCAG luminance check to pick white or black foreground for adequate contrast.
- Tests: initials extraction, size clamping, SVG determinism, foreground contrast,
  Content-Type header, Cache-Control header, size clamping via route, 400 on
  missing/blank name. All files inside app/api/routes-f/avatar-initials/.
Adds /api/routes-f/email-validate with RFC 5322 subset validation,
disposable-domain detection, role-based detection, and Gmail normalization.
Includes scoped unit tests.

Made-with: Cursor
…60-561-562-563

feat(routes-f): feature flags, event ingestion, UUID generator, slugify, avatar-initials (StreamFi-x#560-563 StreamFi-x#582)
Adds missing admin helper export, fixes typed SQL parameter cast,
and removes duplicate key in word-frequency corpus.

Made-with: Cursor
…-referrals-presence-onboarding

feat(routes-f): items catalog, creator referral program, viewer presence & onboarding checklist APIs
…terministic quotes, HTML escape/unescape, and case converter

- Add HTTP status code lookup endpoint (StreamFi-x#663)
  - GET /api/routes-f/http-status?code=404 returns status details
  - GET /api/routes-f/http-status lists all statuses grouped by category
  - Includes ~60 HTTP status codes with RFC references
  - Returns 404 with suggestions for unknown codes

- Add deterministic quote of the day endpoint (StreamFi-x#654)
  - GET /api/routes-f/quote/today returns deterministic quote by date
  - GET /api/routes-f/quote/random?category=... returns random quote
  - GET /api/routes-f/quote/[id] returns specific quote
  - Bundles ~200 quotes across 5 categories (technology, inspiration, business, science, philosophy)

- Add HTML escape/unescape endpoint (StreamFi-x#662)
  - POST /api/routes-f/html-escape with {input, mode} converts text
  - Escape mode handles <, >, &, ", '
  - Unescape mode handles ~80 named entities and numeric entities
  - 1MB input size limit with proper error handling

- Add string case converter endpoint (StreamFi-x#658)
  - POST /api/routes-f/case-convert with {text, target?} converts case formats
  - Supports 7 formats: camelCase, snake_case, kebab-case, PascalCase, CONSTANT_CASE, Title Case, Sentence case
  - Auto-detects input case and preserves numbers
  - Returns all formats when no target specified

All endpoints include comprehensive test coverage and follow the scope constraint of keeping files within app/api/routes-f/ directory.

Closes StreamFi-x#663, StreamFi-x#654, StreamFi-x#662, StreamFi-x#658
…ndpoints

feat(routes-f): implement four API endpoints - HTTP status lookup, de…
…ements-multifire

feat(routes-f): implement stream extensions, obs overlay, co-streamer…
feat(routes-f): items catalog, creator referral program, viewer presence & onboarding checklist APIs
Also fix pre-existing build blockers: corpus duplicate key, missing isAdmin
and lib stubs (db/auth/redis), USERS_STORE export, feature-flags array cast,
Next.js 16 async params across dynamic routes.
- POST /api/routes-f/correlation accepts { x: number[], y: number[] }
- Returns { coefficient, strength, direction, n }
- Rejects arrays shorter than 3 or unequal length with 400
- Rejects zero-variance series with 400
- Strength: weak <0.3, moderate 0.3-0.7, strong >=0.7
- Direction: positive | negative | none
- 14 tests: perfect positive/negative, no correlation, real datasets, shape validation
- Add POST /api/routes-f/shorten endpoint for creating short URLs
- Add GET /api/routes-f/shorten/[code] endpoint for URL lookup
- Implement collision-safe 6-character code generation
- Add URL validation for HTTP/HTTPS schemes only
- Use in-memory Map storage scoped to feature folder
- Include comprehensive unit tests for all functionality
- All files contained within app/api/routes-f/shorten/ as required

Fixes StreamFi-x#552
fortezzalaboratory and others added 25 commits June 25, 2026 08:42
…s-f-features

feat(routes-f): subscription and chat features
…-routes-f-stream-health-tips-badges

feat(routes-f): stream heartbeat, tip alert config, tip goal progress, viewer badge grant
Adds app/api/routes-f/mute-creator/ with POST, DELETE, and GET handlers
so followers can mute creators (hiding live alerts) without unfollowing.

Implementation:
- _lib/types.ts — MuteRecord interface { follower_id, creator_id, muted_at }
- _lib/store.ts — in-memory Map store keyed by follower:creator composite
  key for O(1) mute/unmute lookups; exports muteCreator, unmuteCreator,
  listMutedCreators, and __resetMuteStore for test isolation
- route.ts — three handlers:
    POST   { follower_id, creator_id } → 201 { muted_at } or 409 if already
           muted, 400 if self-mute attempted
    DELETE { follower_id, creator_id } → 200 on success, 404 if no mute exists
    GET    ?follower_id=<id>           → 200 { muted, count } sorted by muted_at
- __tests__/route.test.ts — 9 tests covering mute success, duplicate mute (409),
  self-mute (400), missing fields (400), unmute success, unmute non-existent (404),
  empty list, multi-creator list scoped to follower, and list after unmute

Closes StreamFi-x#982
Closes StreamFi-x#987
Closes StreamFi-x#991
Closes StreamFi-x#993
…87-991-993

feat(routes-f): add mute/unmute creator route
Implements GET and POST for viewer watch history tracking.
GET returns entries sorted by watched_at desc with configurable limit.
POST records entries and deduplicates by (viewer_id, target_id),
keeping the latest timestamp via ON CONFLICT ... DO UPDATE.

Includes tests covering validation, dedup behavior, ordering, and
error handling.
Implements GET for generating shareable tip recap card payloads.
Returns creator, tipper (or anonymous placeholder), amount, asset,
message, and image_meta for a given tip_id.
Returns 404 for unknown tips.

Includes tests covering present tips, anonymous tips, missing tips,
and error handling.
Implements POST, DELETE, and GET for tracking and capping concurrent
playback sessions per viewer. POST registers a session (returns 429
when the 3-session cap is hit), DELETE removes a session, and GET
lists active sessions.

Includes tests covering register, duplicate detection, cap enforcement,
eviction, and error handling.
Implements POST, DELETE, and GET for scheduled stream reminder opt-in.
POST sets a reminder for a scheduled stream (resolves fires_at from the
stream's scheduled_at), DELETE unsubscribes, and GET lists upcoming
reminders.

Includes tests covering signup, cancel, listing, and error handling.
…-history-tip-recap-session-cap-reminders

feat(routes-f): viewer watch history, tip recap, session cap, stream reminders
Implement POST endpoint that suggests tags for a clip from its title
and description using an in-memory keyword-to-tag mapping.

- Bundle keyword-to-tag mapping covering gaming, music, irl, crypto,
  creative, sports, tech, and just_chatting categories
- Return top 5 matching tags ranked by relevance score
- Support multi-word keyword matching (exact phrase and prefix)
- Add input validation for title (required) and description (optional)
- Include comprehensive tests for gaming/music/irl titles and edge cases

Closes StreamFi-x#1050
Implement playlist management endpoints allowing viewers to maintain
custom VOD watch playlists with append, remove, and reorder operations.

- GET returns playlist for a viewer_id
- POST appends a VOD to the playlist
- DELETE removes a VOD from the playlist
- POST /reorder reorders playlist items by vod_id array
- Cap playlist at 100 items with validation
- Prevent duplicate VOD additions
- Include comprehensive lifecycle tests covering all operations

Closes StreamFi-x#1051
Implement endpoints to configure a VOD to auto-play as a rerun when
the creator is offline, with toggle and clear operations.

- POST sets rerun config with creator_id, vod_id, and enabled flag
- GET returns current rerun status for a creator
- DELETE clears the rerun configuration
- Track started_at timestamp when rerun is enabled
- Include tests covering toggle, clearing, and inactive state

Closes StreamFi-x#1052
Implement endpoints to set and retrieve a custom cover image for the
most recent stream session with URL validation.

- POST sets cover image with stream_id and cover_url
- GET retrieves current cover for a stream_id
- Validate URL format using new URL() constructor
- Return updated_at timestamp on successful set
- Include tests for set, retrieve, overwrite, and invalid URL cases

Closes StreamFi-x#1053
…list-rerun-cover

feat(routes-f): clip auto-tag, VOD playlist, rerun loop, stream cover
Implements GET /api/routes-f/notifications with cursor-based pagination,
per-viewer seed data, and full unit test coverage.
@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

👷 Deploy request for streamfi pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d86724d

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

@omarima-10 is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

Hi @omarima-10 — thanks for the contribution!

This repo uses dev as the integration branch. PRs targeting main are not accepted.

Please re-open this PR against dev instead. From your branch:

  1. Click Edit on this PR title area
  2. Change the base branch from main to dev

Or open a fresh PR from the GitHub UI with dev selected as the base.

@github-actions github-actions Bot closed this Jun 26, 2026
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@omarima-10 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.