Repository navigation
fix(cli): import defineNitroPlugin in evlog Nitro plugins - #1292
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
WalkthroughGenerated TanStack Start evlog setup imports the Nitro v3 plugin API for both drain types. It generates Better Auth middleware and adds a self-hosted TanStack Start build sample. ChangesTanStack Start evlog
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
10ed94a7-99c3-4c88-8afb-f970b25f5787
📒 Files selected for processing: 2
apps/cli/src/helpers/addons/evlog-setup.tsapps/cli/test/generated-builds/samples.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
…tart evlog documents createAuthMiddleware in a server middleware, which the Nuxt template already uses. TanStack Start now does the same: a server/middleware/evlog-auth.ts handler with Nitro v3's defineHandler, created once at startup, replacing the response-hook plugin. Middleware runs before the route handler, so requests that throw are now tagged with the user too. An existing evlog auth plugin is removed when the addon is set up again.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d6a3abb2-72f0-47c1-8f46-81081754117a
📒 Files selected for processing: 1
apps/cli/src/helpers/addons/evlog-setup.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
The CLI only targets the latest scaffold, so the addon no longer looks for and deletes the previous server/plugins/evlog-auth.ts in Nuxt or TanStack Start projects.
There was a problem hiding this comment.
🧹 Nitpick comments: 1
apps/cli/test/generated-builds/samples.ts: 1
287-288: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd runtime checks to the evlog sample.
The sample skips
auth:generateand the TanStack Start runtime probe. Add both checks.auth-generatepreserves the generated Better Auth schema, andstart-auth-runtimeboots the built server and exercises requests through the generated middleware and Nitro plugin.Suggested fix
{ name: "tanstack-start-self-auth-evlog", + checks: ["auth-generate", "start-auth-runtime"], config: {
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ee320bd9-64b3-4428-a8bb-b5ac71b7322d
📒 Files selected for processing: 2
apps/cli/src/helpers/addons/evlog-setup.tsapps/cli/test/generated-builds/samples.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
Summary
TanStack Start with
backend: selfand the evlog addon crashed withReferenceError: defineNitroPlugin is not definedwhenever Nitro was on (webDeploy docker/vercel/prisma, or the axiom addon). This imports the Nitro v3 plugin helper in every Nitro plugin evlog generates for TanStack Start, and fixes the auth plugin so it typechecks and identifies users on Nitro v3.Root cause
apps/cli/src/helpers/addons/evlog-setup.tsonly addedimport { definePlugin as defineNitroPlugin } from "nitro"to the Axiom drain plugin. The FS drain plugin (server/plugins/evlog-drain.ts) and the auth plugin (server/plugins/evlog-auth.ts) relied on thedefineNitroPluginglobal, which Nuxt auto-imports but Nitro v3 does not (current docs:import { definePlugin } from "nitro").With the import added, the auth plugin also failed to typecheck:
createAuthIdentifierexpects a Nitro v2 event, and in a Nitro v3requesthook the evlog logger is not set yet (module plugins register afterserver/plugins), so it never identified anyone. TanStack Start now follows evlog's documented pattern, which the Nuxt template already uses:createAuthMiddlewareruns fromserver/middleware/evlog-auth.ts(Nitro v3defineHandler, withuseLogger(event)fromevlog/nitro/v3). Middleware runs before the route handler, so requests that throw are tagged with the user too. Nuxt output is unchanged.Added a
tanstack-start-self-auth-evloggenerated-build sample (sqlite, drizzle, oRPC, Better Auth, evlog, webDeploy docker). Itscheck-typescoversserver/plugins, so it fails with TS2304 on main.Fixes #1251
Verification
ReferenceError: defineNitroPlugin is not definedinbun run dev, andtscreported TS2304 for both plugins.bun run devgives 200 on/.check-typesis clean.bun run buildandnode .output/server/index.mjsgive 200. After sign-up, signed-in/dashboardand/api/rpc/privateDatawide events carryuserId(built server and dev FS drain).BTS_BUILD_SAMPLES=1 BTS_BUILD_SAMPLE_FILTER=tanstack-start-self-auth-evlog bun test test/generated-builds.test.ts: 1 pass.bun run check: clean.bun run test:ci: 112 pass, 0 fail.Summary by CodeRabbit