Skip to content

feat(weekly-brief): BFF route, controller, service with mock/live switch#776

Draft
manishdixitlfx wants to merge 4 commits into
feat/wg-weekly-brief-shared-interfacesfrom
feat/wg-weekly-brief-bff
Draft

feat(weekly-brief): BFF route, controller, service with mock/live switch#776
manishdixitlfx wants to merge 4 commits into
feat/wg-weekly-brief-shared-interfacesfrom
feat/wg-weekly-brief-bff

Conversation

@manishdixitlfx
Copy link
Copy Markdown
Contributor

@manishdixitlfx manishdixitlfx commented May 24, 2026

Tracking: LFXV2-1982 (part of Epic LFXV2-1976)


Summary

Express BFF for the WG Weekly Brief: route + controller + service. Switches between mock data (default for local UI iteration) and live committee-service proxy via WEEKLY_BRIEF_BACKEND=live.

What's new

  • apps/lfx-one/src/server/routes/weekly-brief.route.ts — 3 endpoints: GET current, POST generate, PUT save
  • apps/lfx-one/src/server/controllers/weekly-brief.controller.ts
  • apps/lfx-one/src/server/services/weekly-brief.service.ts — mock fixtures + proxy passthrough
  • apps/lfx-one/.env.example — adds WEEKLY_BRIEF_BACKEND

Notes

  • 404 from upstream on "no draft yet" is normalized to { brief: null, throttle: defaultThrottle() } — matches committee-service's 200/null contract.
  • 429 / 409 propagated as-is so the global error handler surfaces upstream status codes intact.
  • Touches apps/lfx-one/src/server/server.ts (protected file) — registers the new route only.

Stack

PR 2/4 on lfx-self-serve. Base = PR #775 (shared-interfaces).

Test plan

  • yarn lint / yarn build green (verified)
  • Mock mode returns canned brief
  • Live mode proxies through MicroserviceProxyService

Copilot AI review requested due to automatic review settings May 24, 2026 18:56
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27b8c5af-cbdd-4377-bbff-3a79172a9cf6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wg-weekly-brief-bff

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR titles must follow Conventional Commits. Love from, Your reviewers ❤️.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Express BFF surface area for the WG Weekly Brief feature, providing committee-scoped endpoints and a service layer that can run in mock mode locally or proxy to committee-service in “live” mode.

Changes:

  • Introduces weekly-brief Express route + controller wiring for current/generate/save endpoints.
  • Adds a WeeklyBriefService that serves mock fixtures by default and proxies to LFX_V2_SERVICE when WEEKLY_BRIEF_BACKEND=live.
  • Documents the new WEEKLY_BRIEF_BACKEND env var in .env.example.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
apps/lfx-one/src/server/services/weekly-brief.service.ts Implements mock/live switching and upstream proxying for weekly brief operations.
apps/lfx-one/src/server/controllers/weekly-brief.controller.ts Adds request handlers with logging and param validation for weekly brief endpoints.
apps/lfx-one/src/server/routes/weekly-brief.route.ts Defines the /committees/:committeeId/weekly-briefs/* routes.
apps/lfx-one/src/server/server.ts Registers the new weekly brief router under /api/committees.
apps/lfx-one/.env.example Adds WEEKLY_BRIEF_BACKEND configuration example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/lfx-one/src/server/controllers/weekly-brief.controller.ts
Comment thread apps/lfx-one/src/server/controllers/weekly-brief.controller.ts
Comment thread apps/lfx-one/src/server/services/weekly-brief.service.ts
Comment thread apps/lfx-one/src/server/services/weekly-brief.service.ts Outdated
Comment thread apps/lfx-one/.env.example Outdated
Introduce a closed `WeeklyBriefSourceType` union and use it on
WeeklyBriefSourceRef.source_type instead of `string` with an inline
comment listing the values (per copilot-pull-request-reviewer). Both
the BFF and the Angular service consume this type, so widening it to a
real union restores type-safety at every call site without runtime
cost.

Resolves 1 review thread.

Signed-off-by: Manish Dixit <mdixit@linuxfoundation.org>
… switch

Signed-off-by: Manish Dixit <mdixit@linuxfoundation.org>
…vice

Signed-off-by: Manish Dixit <mdixit@linuxfoundation.org>
manishdixitlfx added a commit that referenced this pull request May 24, 2026
Address copilot-pull-request-reviewer comments:

- apps/lfx-one/src/server/controllers/weekly-brief.controller.ts:
  * saveBrief now validates req.body via validateSaveBriefBody before
    handing off to the service. Surfaces ServiceValidationError with
    per-field reasons on invalid input. Without this, e.g. a string
    "1" for revision would concatenate ("1" + 1 = "11") in downstream
    revision math.

- apps/lfx-one/src/server/services/weekly-brief.service.ts:
  * Narrowed the 404 catch to `error instanceof MicroserviceError`
    instead of loose `error.status` / `error.statusCode` checks.
    Matches the convention used in cdp.service.ts, impersonation
    .service.ts, etc.

- apps/lfx-one/.env.example:
  * Moved the WEEKLY_BRIEF_BACKEND comment above the assignment with
    a note about dotenv inline-comment parsing — the previous form
    risked producing values like `live # ...` that wouldn't match
    the strict === 'live' check in code.

Resolves 5 review threads (3 unique findings — two pairs were
duplicates flagging the same code on different lines).

Signed-off-by: Manish Dixit <mdixit@linuxfoundation.org>
@manishdixitlfx manishdixitlfx force-pushed the feat/wg-weekly-brief-bff branch from 666d056 to 501f263 Compare May 24, 2026 21:05
@manishdixitlfx
Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Commit: 501f263

Changes Made (per copilot-pull-request-reviewer)

  • apps/lfx-one/src/server/controllers/weekly-brief.controller.ts: saveBrief validates req.body via a dedicated helper before calling the service; surfaces ServiceValidationError with per-field reasons. Prevents the string-revision concatenation bug.
  • apps/lfx-one/src/server/services/weekly-brief.service.ts: narrowed the 404 catch to error instanceof MicroserviceError, matching the convention used in cdp.service.ts and elsewhere.
  • apps/lfx-one/.env.example: moved the WEEKLY_BRIEF_BACKEND comment above the assignment to avoid dotenv parsing it into the value.

Threads Resolved

5 of 5 unresolved threads addressed in this iteration (3 unique findings; two pairs were duplicates flagging the same code on different lines).

Address copilot-pull-request-reviewer comments:

- apps/lfx-one/src/server/controllers/weekly-brief.controller.ts:
  * saveBrief now validates req.body via validateSaveBriefBody before
    handing off to the service. Surfaces ServiceValidationError with
    per-field reasons on invalid input. Without this, e.g. a string
    "1" for revision would concatenate ("1" + 1 = "11") in downstream
    revision math.

- apps/lfx-one/src/server/services/weekly-brief.service.ts:
  * Narrowed the 404 catch to `error instanceof MicroserviceError`
    instead of loose `error.status` / `error.statusCode` checks.
    Matches the convention used in cdp.service.ts, impersonation
    .service.ts, etc.

- apps/lfx-one/.env.example:
  * Moved the WEEKLY_BRIEF_BACKEND comment above the assignment with
    a note about dotenv inline-comment parsing — the previous form
    risked producing values like `live # ...` that wouldn't match
    the strict === 'live' check in code.

Resolves 5 review threads (3 unique findings — two pairs were
duplicates flagging the same code on different lines).

Signed-off-by: Manish Dixit <mdixit@linuxfoundation.org>

Refs: LFXV2-1982
Signed-off-by: Manish Dixit <mdixit@linuxfoundation.org>
@manishdixitlfx manishdixitlfx force-pushed the feat/wg-weekly-brief-shared-interfaces branch from cc5c4af to 88e4d63 Compare May 24, 2026 22:43
@manishdixitlfx manishdixitlfx force-pushed the feat/wg-weekly-brief-bff branch from 501f263 to a5f4885 Compare May 24, 2026 22:43
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.

2 participants