Skip to content

Upgrade Elysia to 1.4 - #25

Merged
chakrihacker merged 4 commits into
mainfrom
feat/elysia-1.4
Nov 21, 2025
Merged

chakrihacker merged 4 commits into
mainfrom
feat/elysia-1.4

Conversation

@chakrihacker

@chakrihacker chakrihacker commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

User description

Summary by Sourcery

Upgrade Elysia to v1.4, switch to the new OpenAPI plugin, refresh dependencies, and refine server and auth setup

New Features:

  • Log server URL on startup for easier local development.

Enhancements:

  • Bump Elysia core and related plugins, middleware, and toolchain dependencies to v1.4 and latest patch versions.
  • Replace @elysiajs/swagger with @elysiajs/openapi and generate schema references using fromTypes.
  • Export the Elysia instance as a constant and attach a startup listener to emit an informational log.
  • Add a basePath setting to the BetterAuth auth configuration for consistent routing.

CodeAnt-AI Description

Use OpenAPI docs, log API URL, and mount auth under /auth

What Changed

  • API documentation now runs through the OpenAPI plugin instead of the previous Swagger setup, keeping docs aligned with the current schema tooling.
  • Authentication routes are rooted under /auth, and the API now logs http://localhost:3000/api on startup so developers can hit those endpoints immediately.
  • Added Docker Compose services for Postgres and Redis, making it possible to launch the required databases and cache locally.

Impact

✅ Auth endpoints served under /auth
✅ Clearer API startup confirmation
✅ Ready-to-run Postgres/Redis for local development

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Oct 28, 2025

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@korbit-ai

korbit-ai Bot commented Oct 28, 2025

Copy link
Copy Markdown

You've used up your 5 PR reviews for this month under the Korbit Starter Plan. You'll get 5 more reviews on November 6th, 2025 or you can upgrade to Pro for unlimited PR reviews and enhanced features in your Korbit Console.

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2025 •

Copy link
Copy Markdown

Reviewer's Guide

This PR upgrades the Elysia framework and related plugins to version 1.4, updates dependencies accordingly, migrates from the deprecated swagger plugin to the new openapi plugin with type-based references, and refines application startup and authentication configuration.

Class diagram for updated authentication configuration

classDiagram
  class AuthConfig {
    +basePath: string
    +plugins: Plugin[]
    +trustedOrigins: string[]
    +database: PrismaAdapter
    +emailAndPassword: EmailAndPasswordConfig
    +advanced: AdvancedConfig
    +session: SessionConfig
    +cache: CacheConfig
  }
  class EmailAndPasswordConfig {
    +enabled: boolean
    +sendOnSignUp: boolean
  }
  class AdvancedConfig {
    +cookiePrefix: string
    +crossSubDomainCookies: CrossSubDomainCookiesConfig
    +defaultCookieAttributes: CookieAttributes
  }
  class SessionConfig {
    +enabled: boolean
  }
  class CacheConfig {
    +get(key, defaultValue)
    +set(key, value, ttl)
  }
  class PrismaAdapter {
    +provider: string
  }
  class Plugin {}
  class CrossSubDomainCookiesConfig {
    +enabled: boolean
  }
  class CookieAttributes {
    +sameSite: string
    +secure: boolean
  }

  AuthConfig --> EmailAndPasswordConfig
  AuthConfig --> AdvancedConfig
  AuthConfig --> SessionConfig
  AuthConfig --> CacheConfig
  AuthConfig --> PrismaAdapter
  AuthConfig --> Plugin
  AdvancedConfig --> CrossSubDomainCookiesConfig
  AdvancedConfig --> CookieAttributes
Loading

File-Level Changes

Change Details Files
Bump core dependencies to v1.4 releases
  • Updated @better-auth/expo, better-auth, and related packages
  • Upgraded @elysiajs plugins (cors, opentelemetry, server-timing, static) to v1.4
  • Replaced swagger plugin dependency with @elysiajs/openapi and fromTypes
  • Updated OpenTelemetry exporters and SDK, plus utility libraries (ioredis, lru-cache, nodemailer)
apps/api/package.json
Enhance authentication setup with basePath and consistent styling
  • Added basePath "/auth" option to betterAuth configuration
  • Standardized string quotes to double quotes throughout auth.ts
apps/api/src/lib/auth.ts
Replace swagger-based docs with new openapi plugin
  • Removed @elysiajs/swagger import and custom OpenAPI utility
  • Imported openapi and fromTypes from @elysiajs/openapi
  • Reconfigured .use() call to openapi({ references: fromTypes() })
apps/api/src/index.ts
Refine app export and startup logging
  • Exported the Elysia app instance
  • Modified .listen() to include a callback that logs the running URL
apps/api/src/index.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Oct 28, 2025 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • Updated core dependencies for improved compatibility and performance
    • Replaced API documentation tool (Swagger → OpenAPI)
    • Removed unused job queue dependency
    • Updated TypeScript configuration
  • Infrastructure

    • Added Docker Compose configuration for local development environment with database and caching services
  • Improvements

    • Added startup logging displaying API URL on server launch

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Dependency bumps across the API app, Swagger → OpenAPI migration, exported the Elysia app instance, added auth basePath "/auth", introduced a tsconfig for declaration output and simplified tsconfig, and added a docker-compose.base.yml with Postgres and Redis services. Startup now logs the API URL.

Changes

Cohort / File(s) Summary
Dependency updates
apps/api/package.json
Bumped many packages (Elysia ecosystem, OpenTelemetry, better-auth, ioredis, lru-cache, nodemailer, pino-pretty, etc.), removed @elysiajs/swagger and bullmq, added @elysiajs/openapi, replaced bun-types with @types/bun.
OpenAPI migration & app export
apps/api/src/index.ts
Replaced Swagger usage with @elysiajs/openapi, switched to openapi({...}) integration, made app exported (export const app = ...), and added a startup log that prints the API URL.
Auth config
apps/api/src/lib/auth.ts
Added basePath: "/auth" to the betterAuth configuration object.
TypeScript configs
apps/api/tsconfig.dts.json, apps/api/tsconfig.json
Added tsconfig.dts.json for declaration-only generation; simplified and tightened tsconfig.json (noEmit: true, target ESNext, moduleResolution: bundler, strict, preserved path alias).
Docker compose base
docker-compose.base.yml
Added base compose file defining postgres:18-alpine and redis:8-alpine services with env vars, ports, and named volumes (postgres_data, redis_data).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server as Elysia App
    participant OpenAPI as `@elysiajs/openapi`
    participant Auth as betterAuth

    Client->>Server: HTTP request / startup
    Note right of Server: Initialize server with routes & middleware
    Server->>OpenAPI: register OpenAPI (fromTypes / openapi({...}))
    Server->>Auth: mount betterAuth with basePath "/auth"
    Server-->>Client: respond to request
    Note left of Server: on listen -> log API URL
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay extra attention to:
    • apps/api/package.json — verify cross-package compatibility for Elysia and @elysiajs/* modules and OpenTelemetry versions.
    • apps/api/src/index.ts — ensure OpenAPI migration preserves previous docs/paths and any Swagger-specific configs were fully handled.
    • export const app — confirm no lifecycle or import-order regressions elsewhere.
    • New tsconfig.dts.json and changed tsconfig.json — validate declaration build steps and CI build behavior.

Possibly related PRs

Suggested labels

Possible security concern, size:M

Poem

🐰 I hopped from Swagger to OpenAPI bright,

Bumped up packages and tightened types just right.
/auth now greets the routes I guard,
The app steps out — exported and starred.
I log the URL and nibble a carrot of delight.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: upgrading the Elysia framework to version 1.4, which is the primary objective of this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing the upgrade of Elysia to v1.4, migration from Swagger to OpenAPI, dependency updates, auth path configuration, and server startup logging.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33ed057 and d775547.

📒 Files selected for processing (1)
  • docker-compose.base.yml (1 hunks)

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.

❤️ Share

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

@qodo-code-review

qodo-code-review Bot commented Oct 28, 2025 •

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
⚪
Permissive trusted origins

Description: The trustedOrigins list includes broad schemes like "universalstarter://*" and localhost
which, if applied too broadly in production, may allow unintended origins to be trusted
for auth flows.
auth.ts [12-18]

Referred Code
trustedOrigins: [
  "universalstarter://",
  "universalstarter://*",
  "https://*.expo.app",
  "https://expo.app",
  "http://localhost:8081",
],
Misleading service URL

Description: The startup log prints a hardcoded localhost URL that may mislead in non-local
environments; ensure environment-aware URLs to avoid exposing incorrect service endpoints
in logs.
index.ts [75-77]

Referred Code
.listen(PORT, () => {
  elysiaLogger.info(`🚀 API Server running at http://localhost:${PORT}/api`);
});
Ticket Compliance
⚪
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
⚪
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

⚪
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit logs: New routes and auth configuration are introduced but no explicit audit logging of critical
actions (auth events, health checks, route access) is added in the new code, making audit
coverage unclear.

Referred Code
export const app = new Elysia({ prefix: "/api" })
  // Core
  .use(instrumentation)
  .use(wrap(elysiaLogger as pino.Logger, {}))
  .use(
    openapi({
      references: fromTypes(),
    })
  )
  .use(serverTiming())
  .use(
    staticPlugin({
      assets: "public",
      prefix: "/static",
      headers: { "Cache-Control": "public, max-age=31536000, immutable" },
    })
  )
  .use(etag())
  .use(
    cors({
      origin: (request: Request) => {


 ... (clipped 41 lines)
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Unhandled listen errors: The new .listen callback logs startup but does not handle or log server startup failures
or edge cases, leaving error paths unspecified.

Referred Code
.listen(PORT, () => {
  elysiaLogger.info(`🚀 API Server running at http://localhost:${PORT}/api`);
});
Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Auth path exposure: Adding basePath "/auth" and OpenAPI plugin may expose new endpoints; the diff
does not show added validation or authorization checks for these routes.

Referred Code
export const auth = betterAuth({
  basePath: "/auth",
  plugins: [expo(), openAPI(), admin()],
  trustedOrigins: [
    "universalstarter://",
    "universalstarter://*",
    "https://*.expo.app",
    "https://expo.app",
    "http://localhost:8081",
  ],
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review

Copy link
Copy Markdown

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: build-api

Failed stage: Build and push API image [❌]

Failure summary:

Docker buildx failed due to an invalid image tag format:
- The tag
ghcr.io/fyndx/universal-starter-api:-8719d78 is invalid because it starts with a hyphen after the
colon (empty tag followed by -8719d78), which violates Docker image reference rules.
- Command that
failed: /usr/bin/docker buildx build ... --tag ghcr.io/fyndx/universal-starter-api:pr-25 --tag
ghcr.io/fyndx/universal-starter-api:-8719d78 ... --push .
- Fix by ensuring the second tag is a
valid semver/sha-like tag without a leading hyphen (e.g.,
ghcr.io/fyndx/universal-starter-api:8719d78 or sha-8719d78).

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

426:  "Direct push": true,
427:  "Docker exporter": true,
428:  "Multi-platform build": true,
429:  "OCI exporter": true
430:  },
431:  "labels": {
432:  "org.mobyproject.buildkit.worker.moby.host-gateway-ip": "172.17.0.1"
433:  }
434:  }
435:  ],
436:  "name": "default",
437:  "driver": "docker"
438:  }
439:  ##[endgroup]
440:  [command]/usr/bin/docker buildx build --file ./apps/api/Dockerfile --iidfile /home/runner/work/_temp/docker-actions-toolkit-JawWdo/build-iidfile-75d97e316b.txt --label org.opencontainers.image.created=--label org.opencontainers.image.description= --label org.opencontainers.image.licenses= --label org.opencontainers.image.revision=8719d788de02cb05aa94492e20ad32fabbed453d --label org.opencontainers.image.source=https://github.com/fyndx/universal-starter --label org.opencontainers.image.title=universal-starter --label org.opencontainers.image.url=https://github.com/fyndx/universal-starter --label org.opencontainers.image.version=pr-25 --tag ghcr.io/fyndx/universal-starter-api:pr-25 --tag ghcr.io/fyndx/universal-starter-api:-8719d78 --metadata-file /home/runner/work/_temp/docker-actions-toolkit-JawWdo/build-metadata-21a6629b41.json --push .
441:  ERROR: failed to build: invalid tag "ghcr.io/fyndx/universal-starter-api:-8719d78": invalid reference format
442:  ##[error]buildx failed with: ERROR: failed to build: invalid tag "ghcr.io/fyndx/universal-starter-api:-8719d78": invalid reference format
443:  Post job cleanup.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Confirm that replacing @elysiajs/swagger with @elysiajs/openapi/fromTypes still exposes your API docs/UI at the expected endpoint, since the openapi plugin doesn’t bundle a UI by default.
  • Double-check your CORS and static plugin configurations against the Elysia 1.4 upgrade guide — some plugin initialization signatures changed in v1.4.
  • You’ve set basePath to "/auth" in the betterAuth config — ensure your frontend routes and OpenAPI references are updated accordingly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Confirm that replacing @elysiajs/swagger with @elysiajs/openapi/fromTypes still exposes your API docs/UI at the expected endpoint, since the openapi plugin doesn’t bundle a UI by default.
- Double-check your CORS and static plugin configurations against the Elysia 1.4 upgrade guide — some plugin initialization signatures changed in v1.4.
- You’ve set basePath to "/auth" in the betterAuth config — ensure your frontend routes and OpenAPI references are updated accordingly.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Oct 28, 2025
@qodo-code-review

qodo-code-review Bot commented Oct 28, 2025 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Verify automated OpenAPI spec generation

The PR replaces a manual Swagger setup with an automated one using fromTypes().
It is important to verify that the new, automatically generated OpenAPI
specification is as complete and accurate as the previous one.

Examples:

apps/api/src/index.ts [20-24]
  .use(
    openapi({
      references: fromTypes(),
    })
  )

Solution Walkthrough:

Before:

// apps/api/src/index.ts
import swagger from "@elysiajs/swagger";
import { OpenAPI } from "@src/lib/open-api";

const app = new Elysia()
  .use(
    swagger({
      documentation: {
        components: await OpenAPI.components,
        paths: await OpenAPI.getPaths(),
        ...
      },
    })
  );

After:

// apps/api/src/index.ts
import { fromTypes, openapi } from "@elysiajs/openapi";

export const app = new Elysia()
  .use(
    openapi({
      references: fromTypes(),
    })
  );
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a critical risk of regression in API documentation due to the switch from a custom setup to the new automated fromTypes() generator, which is a significant change.

Medium
General
Add metadata to OpenAPI documentation

Add metadata such as info (title, version, description) and tags to the openapi
configuration to improve the generated API documentation.

apps/api/src/index.ts [21-23]

 openapi({
+  info: {
+    title: "Universal API",
+    version: "1.0.0",
+    description: "API for the Universal Starter project",
+  },
+  tags: [{ name: "App", description: "General endpoints" }],
   references: fromTypes(),
 })
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that migrating from swagger to openapi resulted in the loss of API documentation metadata. Restoring this information improves the quality and completeness of the generated API spec.

Low
  • Update

@codeant-ai

codeant-ai Bot commented Oct 28, 2025

Copy link
Copy Markdown

Pull Request Feedback 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Exports + Auto-start
    The PR now exports app while also calling .listen(...) in the same chain. Importing this module will start the server immediately, which is undesirable for tests or tools that import the app object. Consider separating creation/export of the Elysia instance from starting the listener.

  • Dependency compatibility
    Many runtime dependencies are bumped (Elysia, better-auth, opentelemetry, etc.). Verify peer dependency constraints and runtime compatibility (Bun/Node), and run integration tests to catch breaking API or plugin changes introduced by these upgrades.

  • Inconsistent transitive versions
    New opentelemetry and related packages may introduce transitive version mismatches across other workspace packages. Confirm a single compatible opentelemetry stack is used app-wide (or add overrides/resolutions) to avoid subtle runtime errors.

  • Value serialization in secondaryStorage
    secondaryStorage stores and retrieves value directly from Redis. If callers pass non-string values (objects), they may be stored incorrectly or retrieved as raw strings. Consider JSON serialization/deserialization and error handling.

  • Hardcoded port and log accuracy
    The server listens on a hardcoded PORT = 3000 and logs a hardcoded local URL. This may be misleading in non-local or containerized environments and doesn't reflect run-time overrides (e.g., environment variables). Also the logged URL is constructed from that constant instead of the actual bound address/host.

Comment thread apps/api/package.json
"@opentelemetry/exporter-trace-otlp-proto": "^0.203.0",
"@opentelemetry/sdk-trace-node": "^2.0.1",
"@elysiajs/cors": "^1.4.0",
"@elysiajs/openapi": "^1.4.11",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Search the codebase for any imports or runtime usage of @elysiajs/swagger and update them to @elysiajs/openapi; also update plugin initialization to the OpenAPI plugin API (e.g., use the new fromTypes or current OpenAPI initialization pattern) so there are no lingering imports or old API usage at runtime. [possible issue]

Comment thread apps/api/src/lib/auth.ts
set: async (key, value, ttl) => {
if (ttl) {
await redis.set(key, value, 'EX', ttl);
await redis.set(key, value, "EX", ttl);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Replace the direct variadic call to redis.set(key, value, "EX", ttl) with a robust implementation that detects the Redis client API at runtime and uses setEx, the options-object signature, or falls back to the variadic form so TTL is actually applied across different Redis clients. [possible bug]

@codeant-ai

codeant-ai Bot commented Oct 28, 2025

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@codeant-ai

codeant-ai Bot commented Nov 21, 2025

Copy link
Copy Markdown

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:M This PR changes 30-99 lines, ignoring generated files labels Nov 21, 2025
@codeant-ai

codeant-ai Bot commented Nov 21, 2025

Copy link
Copy Markdown

CodeAnt AI Incremental review completed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
apps/api/package.json (1)

16-16: Verify swagger to openapi migration is complete.

The package dependencies correctly replace @elysiajs/swagger with @elysiajs/openapi. However, as noted in a previous review comment, you should verify that all runtime code has been updated accordingly.

This duplicates an earlier concern about the swagger→openapi migration. Please confirm that:

  1. No lingering swagger imports exist in the codebase
  2. All plugin initialization uses the new OpenAPI API
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68f39c6 and 33ed057.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • apps/api/package.json (1 hunks)
  • apps/api/src/index.ts (2 hunks)
  • apps/api/tsconfig.dts.json (1 hunks)
  • apps/api/tsconfig.json (1 hunks)
  • docker-compose.base.yml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use object destructuring for method parameters (wrap multiple parameters in an object; define shapes with TypeScript interfaces)
Use authClient.useSession() for session state
Avoid React hooks; use Legend State observables directly (exception: Better Auth hooks)
Import UI components via path aliases (e.g., @/src/components/ui/)
Prefer union string/number literals over TypeScript enums
Use export type and import type for types
Don't use non-null assertions (!) or implicit any
Avoid TypeScript namespaces; prefer ESM modules

Files:

  • apps/api/src/index.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Platform.OS and process.env.EXPO_OS for conditional platform logic

Files:

  • apps/api/src/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx}: Don't use the arguments object
Use for...of instead of Array.forEach
Use arrow functions instead of function expressions
Use Date.now() instead of new Date().getTime()
Use .flatMap() instead of map().flat() when possible
Prefer regex literals over RegExp constructor when possible
Use concise optional chaining instead of chained logical expressions
Always provide radix to parseInt()
Don't use var; use const/let and prefer const when single assignment
Use template literals over string concatenation
Use strict equality (===/!==)
Don't use console or debugger in committed code
Prevent import cycles and avoid namespace imports
Don't hardcode secrets (API keys/tokens) in source
Don't have unused vars, params, imports, labels, or private members
Avoid await inside loops; ensure Promise-like statements are handled
Disallow bitwise operators and comma operator
Ensure switch statements are exhaustive; default clause comes last; no fallthrough or duplicate cases
Use object spread over Object.assign when creating new objects
Prefer Array.isArray over instanceof Array; use at() instead of integer index access where appropriate
No unreachable code, duplicate conditions, or assignments in conditionals
Always use radix with parseInt; prefer Number.isNaN/Number.isFinite over globals
Disallow using global eval, with, var, and unsafe negation
Ensure typeof comparisons use valid strings; getters return values; constructors don’t return values

Files:

  • apps/api/src/index.ts
🧠 Learnings (15)
📚 Learning: 2025-08-28T12:01:24.375Z
Learnt from: chakrihacker
Repo: fyndx/universal-starter PR: 13
File: apps/frontend/tsconfig.json:13-17
Timestamp: 2025-08-28T12:01:24.375Z
Learning: When using TypeScript project references for Eden Treaty type safety, the backend needs both "composite": true and "declaration": true in tsconfig.json to emit .d.ts files that the frontend can consume. The workspace root also needs TypeScript as a devDependency for the build commands to work properly.

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-02T09:56:34.362Z
Learnt from: chakrihacker
Repo: fyndx/universal-starter PR: 15
File: apps/backend/package.json:43-55
Timestamp: 2025-09-02T09:56:34.362Z
Learning: For Eden Treaty type safety in monorepo setups, TypeScript source files can be referenced directly in package.json "types" fields (e.g., "./src/index.ts") since Eden Treaty works with compile-time type inference and doesn't require emitted .d.ts files for local development.

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
  • apps/api/package.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx} : Use export type and import type for types

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx} : Avoid TypeScript namespaces; prefer ESM modules

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-08-28T12:01:24.375Z
Learnt from: chakrihacker
Repo: fyndx/universal-starter PR: 13
File: apps/frontend/tsconfig.json:13-17
Timestamp: 2025-08-28T12:01:24.375Z
Learning: The project uses TypeScript project references between frontend and backend specifically for Eden Treaty type safety. The frontend references the backend via "references": [{"path": "../backend"}] in tsconfig.json to access exported App types for compile-time type inference, not runtime imports.

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Prevent import cycles and avoid namespace imports

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Don't have unused vars, params, imports, labels, or private members

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx} : Don't use non-null assertions (!) or implicit any

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to tsconfig.json : Configure TypeScript path aliases for @/* from project root

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ios,android,web}.{ts,tsx,js} : Use platform-specific file extensions (.ios.tsx, .web.ts, etc.) for platform implementations

Applied to files:

  • apps/api/tsconfig.dts.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Don't hardcode secrets (API keys/tokens) in source

Applied to files:

  • apps/api/tsconfig.dts.json
  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to babel.config.js : Configure NativeWind Babel/Metro plugins for Tailwind compilation

Applied to files:

  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Don't use var; use const/let and prefer const when single assignment

Applied to files:

  • apps/api/tsconfig.json
📚 Learning: 2025-09-03T13:07:10.649Z
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Disallow bitwise operators and comma operator

Applied to files:

  • apps/api/tsconfig.json
📚 Learning: 2025-08-28T11:58:48.129Z
Learnt from: chakrihacker
Repo: fyndx/universal-starter PR: 13
File: apps/backend/package.json:41-53
Timestamp: 2025-08-28T11:58:48.129Z
Learning: The universal/backend package in this project is used solely for Eden Treaty type safety (similar to ORPC), not for runtime code imports. Eden Treaty provides compile-time type inference from Elysia app types, so Metro transpilation of the backend package is not required.

Applied to files:

  • apps/api/package.json
🧬 Code graph analysis (1)
apps/api/src/index.ts (2)
packages/logger/src/index.ts (1)
  • elysiaLogger (27-30)
apps/api/src/lib/open-api.ts (1)
  • prefix (8-24)
⏰ 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). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (6)
apps/api/tsconfig.dts.json (1)

1-106: LGTM! Declaration configuration is properly structured.

This dedicated TypeScript configuration for declaration file generation is well-configured with emitDeclarationOnly: true and appropriate compiler options. It complements the main tsconfig.json (which uses noEmit: true) by separating type declaration generation from the build process.

Based on learnings, this setup supports Eden Treaty type safety by ensuring .d.ts files are properly generated for consumers.

apps/api/tsconfig.json (1)

3-3: LGTM! Streamlined configuration with separate declaration generation.

The simplified configuration with noEmit: true works well with the new tsconfig.dts.json for declaration generation. The use of module: "Preserve" and composite: true maintains Eden Treaty type safety while reducing config complexity.

Based on learnings, maintaining composite: true and declaration: true is essential for Eden Treaty type inference across the monorepo.

Also applies to: 28-38

apps/api/src/index.ts (2)

17-17: LGTM! App export and startup logging enhance developer experience.

Exporting the app instance improves type safety for Eden Treaty consumers, and the startup log provides clear feedback during local development.

Also applies to: 86-88


22-34: I need to gather more information about the backend TypeScript configuration and whether type definitions are being generated properly.

Let me check the backend TypeScript configuration to understand if type declarations are being generated:

Based on my verification, I can now provide the rewritten review comment:

OpenAPI documentation is functional without type-based schema generation.

By default, Elysia relies on runtime schema to generate OpenAPI documentation. The current code using openapi({}) without the fromTypes configuration will still provide working OpenAPI endpoints at /openapi and /openapi/json.

The commented code indicates it's recommended that declaration files (.d.ts) should be pre-generated to provide type declarations to the generator. For monorepo setups, it's recommended to provide the path to the project root to allow the generator to run correctly. A common error when enabling this is "Couldn't find generated declaration file" when calling the OpenAPI endpoint.

Recommended action: Either restore the fromTypes configuration with proper monorepo paths (project root and tsconfig.dts.json), or document that type-based schema generation is temporarily disabled while OpenAPI documentation remains accessible via runtime schemas. If enabling type-based generation, ensure the backend's tsconfig.json has "declaration": true and "composite": true to emit .d.ts files.

apps/api/package.json (1)

12-38: LGTM! Dependency updates align with Elysia 1.4 upgrade.

All dependency updates are consistent with the PR objectives to upgrade Elysia core and related plugins to v1.4. The migration from @elysiajs/swagger to @elysiajs/openapi and the package name correction from bun-types to @types/bun are appropriate.

Also applies to: 41-41

docker-compose.base.yml (1)

6-8: Use stronger default passwords or document security expectations.

The default passwords (supersecret) are weak and hardcoded, violating the coding guideline against hardcoding secrets. While these may be intended for local development, they create security risks if this file is used as a template for other environments.

Consider one of these approaches:

  1. Document that users must override these in a .env file before running
  2. Use randomly generated defaults or fail if not set
  3. Add a security warning comment above these lines

As per coding guidelines.

Also applies to: 18-18

⛔ Skipped due to learnings
Learnt from: CR
Repo: fyndx/universal-starter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-03T13:07:10.649Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Don't hardcode secrets (API keys/tokens) in source

Comment thread apps/api/src/index.ts
import { meRoutes } from "@src/modules/me";
import { elysiaLogger } from "@universal/logger";
import { Elysia } from "elysia";
import path from "path";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused import.

The path import is only used in the commented-out code block (lines 24-32). Since that code is disabled, this import is unused and should be removed.

As per coding guidelines.

-import path from "path";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import path from "path";
🤖 Prompt for AI Agents
In apps/api/src/index.ts around line 13, the import "path" is unused (only
referenced in a commented-out block); remove the unused import statement (delete
the import line) and run the project's linter/formatter or import fixer to
update and tidy remaining imports.

Comment thread docker-compose.base.yml Outdated
…word and remove unused environment variables
@chakrihacker
chakrihacker merged commit c508a17 into main Nov 21, 2025
3 of 5 checks passed
@chakrihacker
chakrihacker deleted the feat/elysia-1.4 branch November 21, 2025 19:29
@coderabbitai coderabbitai Bot added Possible security concern size:M This PR changes 30-99 lines, ignoring generated files labels Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Possible security concern Review effort 2/5 Review effort 3/5 size:L This PR changes 100-499 lines, ignoring generated files size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant