Skip to content

refactor(api): move startup setup out of Program.cs - #69

Open
yt314 wants to merge 1 commit into
mainfrom
claude/nifty-franklin-cpn0wj
Open

yt314 wants to merge 1 commit into
mainfrom
claude/nifty-franklin-cpn0wj

Conversation

@yt314

@yt314 yt314 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What

Program.cs had grown to 313 lines, most of it service registrations. The setup moves into extension methods under backend/Talmidon.Api/Startup/, one file per concern:

File Contents
ApiServices.cs AddApiServices(): the tenant provider and every API-layer service, in the same groups and with the same comments
AuthSetup.cs AddJwtAuthentication() (secret-length check, JWT validation, authenticated-by-default fallback policy) and AddAuthRateLimiting()
DatabaseInitialization.cs InitializeDatabaseAsync(): migrations, role seeding, the admin user
RecurringJobs.cs ScheduleRecurringJobs(): the four Hangfire recurring jobs

CORS and the middleware pipeline stay in Program.cs, where their order and the comments explaining it are read together. Program.cs is now 105 lines.

Why

To keep Program.cs readable as a short outline of startup, rather than a long list of registrations.

Behavior

Nothing changes in behavior. Configuration is still read at the same point in startup, which matters because TalmidonWebApplicationFactory relies on that order.

Testing

  • dotnet build: succeeds. The only warnings are 3 CS8604 warnings that were already there in ErrorLogTests.cs.
  • dotnet test Talmidon.Tests: 340 of 340 pass against Postgres.

Co-authored with Claude Code.

Program.cs had grown to 313 lines, most of it service registrations.
Move them into extension methods under Startup/, one file per concern:

- ApiServices: the tenant provider and the API-layer services
- AuthSetup: JWT authentication, the fallback policy, auth rate limiting
- DatabaseInitialization: migrations, role seeding, the admin user
- RecurringJobs: the Hangfire recurring jobs

CORS and the middleware pipeline stay in Program.cs, where their order
and the comments explaining it are read together. Configuration is
still read at the same point in startup. Program.cs is now 105 lines.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
talmidon Ready Ready Preview Oct 22, 2026 11:16am UTC

This branch was successfully deployed

1 active deployment
Preview — fa924993 Deployed Oct 22, 2026 by vercel[bot]
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.

1 participant