feat(elysia): add elysia integration package (@aura-stack/elysia)#140
feat(elysia): add elysia integration package (@aura-stack/elysia)#140halvaradop merged 2 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughIntroduces a new Changes
Sequence DiagramsequenceDiagram
participant Client
participant ElysiaApp as Elysia App
participant ElysiaPkg as `@aura-stack/elysia`
participant AuthAPI as Auth API
Client->>ElysiaApp: GET /api/protected
ElysiaApp->>ElysiaPkg: derive(withAuth) resolver invoked
activate ElysiaPkg
ElysiaPkg->>AuthAPI: api.getSession({ headers })
activate AuthAPI
AuthAPI-->>ElysiaPkg: session | throws
deactivate AuthAPI
ElysiaPkg-->>ElysiaApp: { session: Session | null }
deactivate ElysiaPkg
alt session present
ElysiaApp->>ElysiaApp: handler reads ctx.session
ElysiaApp-->>Client: 200 + protected content
else no session
ElysiaApp-->>Client: 401 Unauthorized
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/elysia/test/index.test.ts (1)
129-129: Strengthen cookie assertion to validate the auth cookie key.
toBeDefined()can pass on unrelated cookies; asserting the cookie name/value prefix will make this test more regression-resistant.Suggested test tightening
- expect(res.headers.get("set-cookie")).toBeDefined() + const setCookie = res.headers.get("set-cookie") + expect(setCookie).toBeTruthy() + expect(setCookie).toContain("aura-auth.session_token=")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/elysia/test/index.test.ts` at line 129, The test currently only checks that res.headers.get("set-cookie") is defined, which can pass for unrelated cookies; update the assertion to verify the auth cookie key/value prefix instead (e.g., assert the Set-Cookie header contains the expected cookie name like "auth=" or matches a regex such as /^auth=.+/). Locate the assertion using res.headers.get("set-cookie") in the test (packages/elysia/test/index.test.ts) and replace the toBeDefined() check with a stricter assertion such as expect(setCookie).toMatch(/(^|;\s*)auth=[^;]+/) or expect(setCookie).toContain("auth=") to ensure the auth cookie is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/elysia/CHANGELOG.md`:
- Line 13: Update the changelog entry that currently references PR `#139` to the
correct PR `#140`: edit the line "Introduced seamless Elysia integration
package..." and replace the link/text
"[`#139`](https://github.com/aura-stack-ts/auth/pull/139)" with
"[`#140`](https://github.com/aura-stack-ts/auth/pull/140)" so the changelog
correctly points to PR `#140`.
In `@packages/elysia/README.md`:
- Around line 82-85: The README.md contains a broken relative license link "[MIT
License](LICENSE)"; either add a package-local LICENSE file to satisfy the
existing link or update the markdown link in README.md to point to the repo root
LICENSE (for example change "[MIT License](LICENSE)" to "[MIT
License](../../LICENSE)"); modify the file README.md and/or add the missing
LICENSE to packages/elysia so the link resolves correctly.
In `@packages/elysia/src/lib/with-auth.ts`:
- Around line 16-23: In with-auth.ts, avoid turning every exception from
api.getSession into session: null; update the try/catch around api.getSession so
that you only convert authentication failures (e.g., an explicit AuthError type
or an error indicating HTTP 401/unauthorized from api.getSession) into return {
session: null }, and for any other unexpected errors rethrow (or propagate) the
error so real server/runtime issues are not masked; locate the api.getSession
call and its surrounding catch in withAuth and implement error-type/status
checking before deciding to return { session: null } versus rethrowing.
---
Nitpick comments:
In `@packages/elysia/test/index.test.ts`:
- Line 129: The test currently only checks that res.headers.get("set-cookie") is
defined, which can pass for unrelated cookies; update the assertion to verify
the auth cookie key/value prefix instead (e.g., assert the Set-Cookie header
contains the expected cookie name like "auth=" or matches a regex such as
/^auth=.+/). Locate the assertion using res.headers.get("set-cookie") in the
test (packages/elysia/test/index.test.ts) and replace the toBeDefined() check
with a stricter assertion such as
expect(setCookie).toMatch(/(^|;\s*)auth=[^;]+/) or
expect(setCookie).toContain("auth=") to ensure the auth cookie is present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4c3ca1e0-3448-4859-80db-2e7957be71f3
⛔ Files ignored due to path filters (3)
bun.lockis excluded by!**/*.lockdeno.lockis excluded by!**/*.lockpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (22)
apps/elysia/README.mdapps/elysia/package.jsonapps/elysia/src/auth.tsapps/elysia/src/index.tsapps/elysia/src/lib/auth.tsapps/elysia/src/plugins/with-auth.tsapps/elysia/tsconfig.jsondeno.jsonpackages/elysia/CHANGELOG.mdpackages/elysia/README.mdpackages/elysia/deno.jsonpackages/elysia/package.jsonpackages/elysia/src/createAuth.tspackages/elysia/src/index.tspackages/elysia/src/lib/handler.tspackages/elysia/src/lib/with-auth.tspackages/elysia/test/index.test.tspackages/elysia/test/presets.tspackages/elysia/tsconfig.jsonpackages/elysia/tsup.config.tspackages/elysia/vitest.config.tspackages/hono/tsconfig.json
💤 Files with no reviewable changes (2)
- apps/elysia/src/auth.ts
- apps/elysia/src/plugins/with-auth.ts
Description
This pull request introduces the
@aura-stack/elysiapackage, providing seamless authentication integration for the Elysia framework. The package includes built-in plugins and adapters to bridge Web Standard APIs (Request,Response) with Elysia’s internal interfaces.The integration provides utilities that can be used within Elysia’s
deriveandresolvelifecycle functions, enabling type-safe session handling and simplified authentication flows.Key Changes
@aura-stack/elysiapackagewithAuthplugin for use withderiveandresolvetoHandleradapter for Web API ↔ Elysia interoperabilityapps/elysiaintegration exampleUsage