Skip to content

Conversation

@kingston
Copy link
Collaborator

@kingston kingston commented Sep 7, 2025

Summary by CodeRabbit

  • New Features

    • Integrates the pg-boss job queue plugin into the example backend server.
    • Generator now auto-registers the pg-boss plugin in the server configuration.
  • Refactor

    • Switched the pg-boss plugin to a named export without changing runtime behavior.
    • Deferred queue initialization until first use to reduce side effects.
  • Chores

    • Added Prettier ignore for pnpm-lock.yaml in example projects.
    • Updated AI settings to specify the model used.

@changeset-bot
Copy link

changeset-bot bot commented Sep 7, 2025

⚠️ No Changeset found

Latest commit: d66f2d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Sep 7, 2025

Walkthrough

Changes switch pg-boss plugin exports from default to named, add plugin registration to the example server, defer pg-boss initialization in services, and update the pg-boss code generator to inject the plugin into Fastify server config. Minor repository configs added/updated (.prettierignore entries; .claude settings).

Changes

Cohort / File(s) Summary of Changes
PgBoss Plugin Export Refactor
examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts, plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts
Renamed internal callback to pgBossPluginCallback and shifted from default export to named export pgBossPlugin via fastifyPlugin wrapper.
PgBoss Service Init Deferral
examples/blog-with-auth/packages/backend/src/services/pg-boss.service.ts, plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/services/pg-boss.service.ts
Removed eager initialization call in createQueue; initialization now deferred until enqueue/work paths that access pg-boss.
Server Integration
examples/blog-with-auth/packages/backend/src/server.ts
Imported and registered pgBossPlugin in the server bootstrap sequence.
Code Generator Update
plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts
Added fastifyServerConfig task to inject pgBossPlugin into Fastify server config using tsCodeFragment and tsImportBuilder.
Prettier Ignore Entries
examples/blog-with-auth/.prettierignore, examples/todo-with-auth0/.prettierignore
Added pnpm-lock.yaml to Prettier ignore lists.
Tooling Config
.claude/settings.json
Added top-level model: "opusplan"; adjusted JSON to include trailing comma after permissions block.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Gen as PgBoss Generator
  participant Cfg as Fastify Server Config
  Note over Dev,Gen: Build-time generation
  Dev->>Gen: Run generator
  Gen->>Cfg: Inject plugin entry<br/>plugin: import { pgBossPlugin } from '.../pg-boss.plugin'
  Note right of Cfg: pgBossPlugin registered in config
Loading
sequenceDiagram
  autonumber
  participant App as Application
  participant S as Fastify Server
  participant P as pgBossPlugin
  participant SV as PgBoss Service
  Note over App,S: Runtime startup
  App->>S: buildServer()
  S->>P: register()
  P->>P: initialize pg-boss instance
  S-->>App: server ready

  Note over S,P: Shutdown
  App-->>S: close()
  S->>P: onClose()
  P->>P: stop pg-boss

  Note over SV: Queue usage paths
  App->>SV: createQueue()
  SV-->>App: returns queue (no init)
  App->>SV: enqueue/work
  SV->>P: getPgBoss() (requires initialized)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • fix: Export PgBossQueue class #647 — Also modifies pg-boss service code, touching initialization/visibility aspects similar to this PR’s pg-boss service and template changes.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kingston/eng-842-add-pgboss-plugin-to-server-initializers

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

@vercel
Copy link

vercel bot commented Sep 7, 2025

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

Project Deployment Preview Comments Updated (UTC)
baseplate-project-builder-web Ready Ready Preview Comment Sep 7, 2025 9:40pm

@kingston kingston merged commit e9674d4 into main Sep 7, 2025
16 of 17 checks passed
@kingston kingston deleted the kingston/eng-842-add-pgboss-plugin-to-server-initializers branch September 7, 2025 21:47
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
examples/blog-with-auth/packages/backend/src/server.ts (1)

14-14: Prefer tsconfig path alias over relative import.

Guidelines call for absolute '@src/' paths.

-import { pgBossPlugin } from './plugins/pg-boss.plugin.js';
+import { pgBossPlugin } from '@src/plugins/pg-boss.plugin.js';
plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts (1)

11-19: Rename to pgBossPluginCallback is fine; consider re-enabling type-checking.

Template has "// @ts-nocheck" on Line 1; recommend removing to keep template type-safe.

-// @ts-nocheck
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0770931 and d66f2d0.

⛔ Files ignored due to path filters (3)
  • examples/blog-with-auth/packages/backend/baseplate/generated/src/plugins/pg-boss.plugin.ts is excluded by !**/generated/**, !**/generated/**
  • examples/blog-with-auth/packages/backend/baseplate/generated/src/server.ts is excluded by !**/generated/**, !**/generated/**
  • examples/blog-with-auth/packages/backend/baseplate/generated/src/services/pg-boss.service.ts is excluded by !**/generated/**, !**/generated/**
📒 Files selected for processing (9)
  • .claude/settings.json (1 hunks)
  • examples/blog-with-auth/.prettierignore (1 hunks)
  • examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts (2 hunks)
  • examples/blog-with-auth/packages/backend/src/server.ts (2 hunks)
  • examples/blog-with-auth/packages/backend/src/services/pg-boss.service.ts (0 hunks)
  • examples/todo-with-auth0/.prettierignore (1 hunks)
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts (2 hunks)
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts (2 hunks)
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/services/pg-boss.service.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • examples/blog-with-auth/packages/backend/src/services/pg-boss.service.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/services/pg-boss.service.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)

**/*.{ts,tsx}: TypeScript with strict type checking
Always include return types on top-level functions including React components (React.ReactElement)
Include absolute paths in import statements via tsconfig paths (@src/ is the alias for src/)
If a particular interface or type is not exported, change the file so it is exported

If an interface or type is needed publicly but is not exported, modify the TypeScript file so it is exported

Files:

  • examples/blog-with-auth/packages/backend/src/server.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts
  • examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)

Node 16 module resolution - include file extensions in imports (.js)

Files:

  • examples/blog-with-auth/packages/backend/src/server.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts
  • examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)

**/*.{ts,tsx,js}: Sort imports by group: external libs first, then local imports
Use camelCase for variables/functions, PascalCase for types/classes
Order functions such that functions are placed below the variables/functions they use
We use the prefer using nullish coalescing operator (??) ESLint rule instead of a logical or (||), as it is a safer operator
Use console.info/warn/error instead of console.log

Files:

  • examples/blog-with-auth/packages/backend/src/server.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts
  • examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts
**/*

📄 CodeRabbit inference engine (.cursor/rules/code-style.mdc)

Use kebab-case for file names

Files:

  • examples/blog-with-auth/packages/backend/src/server.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts
  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts
  • examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts
examples/blog-with-auth/packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (examples/blog-with-auth/CLAUDE.md)

examples/blog-with-auth/packages/**/src/**/*.{ts,tsx}: Always use .js extensions in import statements (even when importing from TypeScript files)
Use import type for type-only imports
Always specify explicit return types for all functions
Add JSDoc to all exported functions, interfaces, and classes (document parameters, return values, and fields)

Files:

  • examples/blog-with-auth/packages/backend/src/server.ts
  • examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts
🧠 Learnings (11)
📚 Learning: 2025-09-03T17:03:33.250Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/todo-with-auth0/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:03:33.250Z
Learning: Applies to examples/todo-with-auth0/{package.json,packages/**/package.json} : Package manager is pnpm 10+ (enforce via `packageManager` field)

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:33.250Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/todo-with-auth0/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:03:33.250Z
Learning: Applies to examples/todo-with-auth0/**/pnpm-workspace.yaml : Use pnpm workspaces with packages located under `packages/`

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:02:31.412Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/blog-with-auth/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:02:31.412Z
Learning: Use pnpm 10+ and Node 20+ (Volta pinned)

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:52.726Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: .cursor/rules/dev-commands.mdc:0-0
Timestamp: 2025-09-03T17:03:52.726Z
Learning: From a package, build using `pnpm build`

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:52.726Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: .cursor/rules/dev-commands.mdc:0-0
Timestamp: 2025-09-03T17:03:52.726Z
Learning: From repository root, build using `pnpm build`

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:52.726Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: .cursor/rules/dev-commands.mdc:0-0
Timestamp: 2025-09-03T17:03:52.726Z
Learning: From a package, lint with auto-fixing using `pnpm lint --fix`

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:52.726Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: .cursor/rules/dev-commands.mdc:0-0
Timestamp: 2025-09-03T17:03:52.726Z
Learning: From a package, run all tests using `pnpm test`

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:52.726Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: .cursor/rules/dev-commands.mdc:0-0
Timestamp: 2025-09-03T17:03:52.726Z
Learning: From repository root, check types using `pnpm typecheck`

Applied to files:

  • examples/blog-with-auth/.prettierignore
  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:33.250Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/todo-with-auth0/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:03:33.250Z
Learning: Applies to examples/todo-with-auth0/{package.json,packages/**/package.json} : Module system must be ESM only (`"type": "module"` in package.json)

Applied to files:

  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-03T17:03:33.250Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: examples/todo-with-auth0/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:03:33.250Z
Learning: Applies to examples/todo-with-auth0/{package.json,packages/**/package.json} : Node version 22+ with Volta pinned to 22.18.0

Applied to files:

  • examples/todo-with-auth0/.prettierignore
📚 Learning: 2025-09-05T15:28:22.494Z
Learnt from: CR
PR: halfdomelabs/baseplate#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-05T15:28:22.494Z
Learning: Follow task-based architecture, use provider scopes, leverage the TypeScript rendering system, organize generation with Task Phases, and use Dynamic Tasks for data-driven generation

Applied to files:

  • plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts
🧬 Code graph analysis (3)
examples/blog-with-auth/packages/backend/src/server.ts (2)
examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts (1)
  • pgBossPlugin (23-25)
plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts (1)
  • pgBossPlugin (21-23)
plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts (1)
examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts (1)
  • pgBossPlugin (23-25)
plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts (4)
packages/sync/src/generators/generators.ts (1)
  • createGeneratorTask (196-204)
packages/fastify-generators/src/generators/core/fastify-server/fastify-server.generator.ts (1)
  • fastifyServerConfigProvider (67-67)
packages/core-generators/src/renderers/typescript/fragments/creators.ts (1)
  • tsCodeFragment (73-83)
packages/core-generators/src/renderers/typescript/imports/builder.ts (1)
  • tsImportBuilder (74-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Lint
  • GitHub Check: Test E2E
  • GitHub Check: test
🔇 Additional comments (10)
examples/blog-with-auth/.prettierignore (1)

1-1: Lockfile in .prettierignore is fine.

Ignoring pnpm-lock.yaml avoids noisy diffs.

examples/todo-with-auth0/.prettierignore (1)

1-1: Same here—good to ignore the lockfile.

Keeps Prettier away from the lockfile.

.claude/settings.json (1)

19-21: Model alias validated
“opusplan” is a valid Claude model alias (Opus in plan mode and Sonnet in execution mode); no changes required.

examples/blog-with-auth/packages/backend/src/server.ts (1)

42-43: Registering pg-boss plugin in bootstrap sequence looks good.

Order (after healthCheck, before requestContext) is reasonable.

plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.ts (1)

21-23: Named export is aligned with consumers.

Exporting pgBossPlugin with a name: 'pg-boss' is consistent and clear.

examples/blog-with-auth/packages/backend/src/plugins/pg-boss.plugin.ts (2)

13-21: Plugin callback change LGTM.

Init + onClose shutdown are wired correctly.


23-26: Named export matches new import style.

This aligns with server.ts usage.

plugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.ts (3)

1-5: Import additions are appropriate.

Bringing in tsCodeFragment/tsImportBuilder is correct for fragment injection.


71-73: No action needed: pg-boss remains at latest secure version
Version 10.3.2 is the current latest release (npm view pg-boss version returned 10.3.2) and GitHub reports no open advisories for it.


31-44: Verify .js extension in generated pgBossPlugin import path and unique plugin key

  • Manually confirm that GENERATED_TEMPLATES.paths.provider.pgBossPlugin ends in .js to satisfy Node16 ESM rules.
  • Ensure the 'pgBossPlugin' key in fastifyServerConfig.plugins.set('pgBossPlugin', …) is not duplicated elsewhere in the codebase.

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