-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Add pgboss plugin to server initializers #653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add pgboss plugin to server initializers #653
Conversation
|
WalkthroughChanges 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
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
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this 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.
⛔ Files ignored due to path filters (3)
examples/blog-with-auth/packages/backend/baseplate/generated/src/plugins/pg-boss.plugin.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/server.tsis excluded by!**/generated/**,!**/generated/**examples/blog-with-auth/packages/backend/baseplate/generated/src/services/pg-boss.service.tsis 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 forsrc/)
If a particular interface or type is not exported, change the file so it is exportedIf 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.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.tsexamples/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.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.tsexamples/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.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.tsexamples/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.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/templates/src/plugins/pg-boss.plugin.tsplugins/plugin-queue/src/pg-boss/core/generators/pg-boss/pg-boss.generator.tsexamples/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)
Useimport typefor 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.tsexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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/.prettierignoreexamples/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
pgBossPluginwith aname: '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
Version10.3.2is the current latest release (npm view pg-boss versionreturned10.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.pgBossPluginends in.jsto satisfy Node16 ESM rules.- Ensure the
'pgBossPlugin'key infastifyServerConfig.plugins.set('pgBossPlugin', …)is not duplicated elsewhere in the codebase.
Summary by CodeRabbit
New Features
Refactor
Chores