Skip to content

feat(auth): add login API endpoint for user authentication - #13

Merged
abdelkabirouadoukou merged 6 commits into
mainfrom
chore/production-readiness
Aug 1, 2026
Merged

abdelkabirouadoukou merged 6 commits into
mainfrom
chore/production-readiness

Conversation

@abdelkabirouadoukou

@abdelkabirouadoukou abdelkabirouadoukou commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added configurable build output directories and graceful server shutdown.
    • Added Redis-backed shared rate limiting and enhanced PostgreSQL connection options.
    • Added a working SaaS demo login flow with validation and error states.
    • Added interactive boarding-pass and route-trail experiences to the landing page.
    • Improved environment-variable protection and production cookie security.
  • Bug Fixes

    • Corrected rate-limit processing, database initialization, and static-build reporting.
  • Documentation

    • Added setup, deployment, security, contribution, and environment configuration guidance.

@vercel

vercel Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
thexjs-basic Ready Ready Preview Aug 1, 2026 4:26am
x Ready Ready Preview Aug 1, 2026 4:26am

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@abdelkabirouadoukou, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 69ee3f6f-3a39-4eea-b34a-8f68c7c159eb

📥 Commits

Reviewing files that changed from the base of the PR and between b230767 and ee2ff4f.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • .github/workflows/ci.yml
  • README.md
  • examples/basic/package.json
  • examples/landing/src/components/boarding-pass.tsx
  • examples/landing/src/components/route-trail.tsx
  • examples/landing/src/pages/index.tsx
  • examples/landing/src/pages/play.tsx
  • package.json
  • packages/adapter-vercel/src/generate-entry.ts
  • packages/adapter-vercel/src/scan.ts
  • packages/adapter-vercel/src/types.ts
  • packages/core/src/build.ts
  • packages/core/src/createApp.ts
  • packages/core/src/data/postgres.ts
📝 Walkthrough

Walkthrough

The pull request adds production-readiness changes across runtime security, PostgreSQL connectivity, rate limiting, CLI builds, deployment, authentication templates, landing-page presentation, CI, and project documentation.

Changes

Runtime hardening

Layer / File(s) Summary
PostgreSQL connection lifecycle
packages/core/src/data/postgres.ts, packages/core/src/data/sqlite.ts
connectPostgres now supports pooling, TLS, CA certificates, connection probing, retries, and query proxying. SQLite loading now uses import.meta.require.
Shared rate-limit stores
packages/core/src/security/rate-limit.ts, packages/core/src/createApp.ts, packages/core/src/index.ts, packages/core/src/security/security.test.ts
Rate limiting now supports asynchronous in-memory and Redis-backed stores, bucket sweeping, disposal, public store exports, and asynchronous middleware.
Security controls and validation
.env.example, packages/core/src/security/*, SECURITY.md
Security cookies, environment-access detection, header handling, configuration examples, and security tests were updated.

Build and deployment flow

Layer / File(s) Summary
CLI output and shutdown
packages/cli/src/index.ts, packages/core/src/build.ts, packages/core/src/createApp.ts
The CLI supports --outDir, and generated servers handle signal-driven shutdown with draining and forced-exit fallback. Request handling awaits asynchronous rate-limit checks.
Container and deployment wiring
Dockerfile, DEPLOY.md, AGENTS.md, examples/basic/package.json, package.json
Docker and deployment instructions build and run generated TypeScript server entries from configurable output directories. Vercel build wiring was added.

Authentication templates

Layer / File(s) Summary
Template database and cookie hardening
examples/basic/src/lib/auth.ts, examples/saas/src/lib/auth.ts, packages/create-thexjs-app/templates/*/src/lib/auth.ts, packages/create-thexjs-app/templates/basic/src/pages/login.tsx
Authentication libraries cache SQLite connections, create database directories, set production secure cookies, and show demo-only warnings.
SaaS login flow
packages/create-thexjs-app/templates/saas/src/api/auth/login.ts, packages/create-thexjs-app/templates/saas/src/pages/login.tsx
The SaaS template adds server and client login handling with validation, sessions, redirects, loading state, and errors.

Landing page presentation

Layer / File(s) Summary
Landing page interactive islands
examples/landing/src/components/boarding-pass.tsx, examples/landing/src/components/route-trail.tsx, examples/landing/src/pages/index.tsx, examples/landing/src/pages/play.tsx
The landing page adds route-trail interaction and a route-derived boarding-pass island.
Landing page visual system
examples/landing/src/styles/globals.css, examples/landing/src/pages/index.tsx, examples/landing/x.config.ts
The page adds self-hosted fonts, field-log styling, ticket and route-trail styles, reduced-motion handling, and matching CSP updates.

Project operations and documentation

Layer / File(s) Summary
CI and dependency automation
.github/workflows/ci.yml, .github/dependabot.yml, package.json
CI adds macOS coverage, pins Bun, audits dependencies, and Dependabot checks weekly updates. TypeScript is updated.
Project guidance and release records
CHANGELOG.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md, README.md, .env.example, LICENSE
The repository adds contributor guidance, conduct rules, changelog entries, production-readiness notes, environment guidance, documentation links, and updated license attribution.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant LoginPage
  participant LoginAPI
  participant AuthSession
  Client->>LoginPage: submit credentials
  LoginPage->>LoginAPI: POST credentials
  LoginAPI->>AuthSession: validate credentials and create session
  AuthSession-->>LoginAPI: session cookie
  LoginAPI-->>LoginPage: JSON success or error
  LoginPage-->>Client: redirect or display error
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the added authentication login endpoint, which is a real part of the changeset but not its primary overall focus.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/production-readiness

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.

@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: 13

🧹 Nitpick comments (2)
CONTRIBUTING.md (1)

8-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a language tag to the project-layout fence.

The fenced block at Line 8 has no language tag. Add text so Markdown linting passes consistently.

Proposed fix
-```
+```text
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CONTRIBUTING.md` around lines 8 - 15, Add the text language tag to the fenced
project-layout block in CONTRIBUTING.md, changing its opening fence to ```text
while leaving the listed contents and closing fence unchanged.

Source: Linters/SAST tools

.github/dependabot.yml (1)

5-10: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Add Dependabot coverage for GitHub Actions.

The repository uses actions/checkout@v4 and oven-sh/setup-bun@v2, but this configuration monitors only package dependencies. Add a weekly github-actions entry so action security updates receive pull requests. GitHub lists github-actions as a supported ecosystem. (docs.github.com)

Proposed fix
 updates:
   - package-ecosystem: "npm"
     directory: "/"
     schedule:
       interval: "weekly"
     open-pull-requests-limit: 10
     versioning-strategy: increase
+
+  - package-ecosystem: "github-actions"
+    directory: "/"
+    schedule:
+      interval: "weekly"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/dependabot.yml around lines 5 - 10, Add a separate weekly Dependabot
configuration entry with package-ecosystem set to github-actions and directory
set to the repository root, preserving the existing npm configuration and
pull-request limit behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/dependabot.yml:
- Around line 5-10: Update the Dependabot configuration entry to use the native
"bun" package ecosystem instead of "npm", and remove the unsupported
versioning-strategy setting while preserving the directory, schedule, and
pull-request limit.

In @.github/workflows/ci.yml:
- Around line 49-60: Add a separate dependency-audit step near the existing
“Audit dependencies” step that runs an unignored `bun audit --prod`, while
preserving the current ignored full `bun audit` for development dependencies.
Use a distinct step name that clearly identifies the production audit.
- Line 17: Update both actions/checkout@v4 steps in the workflow to set
persist-credentials to false, including the checkout steps near the first and
second checkout locations. Leave all other checkout configuration unchanged.

In `@DEPLOY.md`:
- Around line 14-21: Use a consistent dist output directory throughout the
deployment instructions: update the start command to include --outDir dist, and
ensure the VPS deployment build also uses --outDir dist before copying files
from dist. Keep all build, start, and copy steps aligned to the same directory.

In `@Dockerfile`:
- Around line 30-34: Update Dockerfile lines 30-34 to make the production image
include a self-contained server bundle or copy the runtime dependency
installation and required application modules alongside dist, ensuring
dist/server/index.ts can resolve `@thexjs/core` and route configuration. Update
DEPLOY.md lines 3-4 to require these runtime files for direct and VPS
deployments if the production build remains non-self-contained; otherwise state
that the self-contained build removes that requirement.
- Line 27: Update Dockerfile lines 27-27 so the CLI build output is written to
the directory copied by the production stage, preferably by changing the output
path to ../../dist; update DEPLOY.md lines 128-129 to document the selected
artifact location consistently.

In `@packages/core/src/build.ts`:
- Around line 415-433: Update shutdown in packages/core/src/build.ts so it
awaits server.stop() to drain active requests, then schedules the three-second
fallback to call server.stop(true) followed by process.exit(0); do not
force-stop before the drain or exit immediately. Update AGENTS.md lines 69-70 to
describe the generated behavior as a three-second graceful drain followed by
forced shutdown.

In `@packages/core/src/data/postgres.ts`:
- Around line 90-101: Fix the priming race in the run function by always
awaiting the shared promise returned by prime before executing work, rather than
conditionally awaiting only when primed is unset. Preserve prime’s ??= behavior
so concurrent callers share the same probeWithRetry operation and all queries
wait for its retry/backoff completion.
- Around line 63-78: Update the connection setup around the computed sslMode and
Bun.SQL constructor to apply the TLS policy through the resolved URL’s sslmode
query parameter, rather than passing an unsupported sslMode option. Append
sslmode only when sslMode is not "disable", while preserving the existing URL,
TLS CA, and other connection options.

In `@packages/core/src/security/rate-limit.ts`:
- Around line 150-159: Update getClient to clear connecting when connect()
rejects, while preserving the existing client assignment on successful
connection. Ensure the rejected promise does not remain cached, allowing
subsequent calls to initiate a fresh connection attempt.

In `@packages/create-thexjs-app/templates/saas/src/api/auth/login.ts`:
- Around line 1-29: Add a matching “DEMO ONLY” warning comment immediately above
the hardcoded credential comparison in POST, clearly indicating that the
admin/admin plaintext check is for demonstration purposes and must not be used
in production.
- Around line 1-29: The authentication flow is duplicated across the API route
and page loader; centralize credential validation, session creation, and cookie
issuance in an authenticate(email, password) helper in
packages/create-thexjs-app/templates/saas/src/lib/auth.ts. Update
packages/create-thexjs-app/templates/saas/src/api/auth/login.ts lines 1-29 to
call authenticate, and update
packages/create-thexjs-app/templates/saas/src/pages/login.tsx lines 9-24 to use
the same helper instead of its local admin check, preserving each caller’s
existing response behavior.

In `@README.md`:
- Around line 276-281: Update the “Links” section in README.md to convert the
SECURITY.md and CONTRIBUTING.md code spans into clickable Markdown links,
preserving their existing labels and document targets.

---

Nitpick comments:
In @.github/dependabot.yml:
- Around line 5-10: Add a separate weekly Dependabot configuration entry with
package-ecosystem set to github-actions and directory set to the repository
root, preserving the existing npm configuration and pull-request limit behavior.

In `@CONTRIBUTING.md`:
- Around line 8-15: Add the text language tag to the fenced project-layout block
in CONTRIBUTING.md, changing its opening fence to ```text while leaving the
listed contents and closing fence unchanged.
🪄 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 Plus

Run ID: 5ef3ca6b-ca9c-414c-88bc-9880ec893474

📥 Commits

Reviewing files that changed from the base of the PR and between 15143a9 and e9d4fca.

📒 Files selected for processing (30)
  • .env.example
  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • AGENTS.md
  • CHANGELOG.md
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • DEPLOY.md
  • Dockerfile
  • README.md
  • SECURITY.md
  • examples/basic/src/lib/auth.ts
  • examples/landing/src/pages/index.tsx
  • examples/saas/src/lib/auth.ts
  • package.json
  • packages/cli/src/index.ts
  • packages/core/src/build.ts
  • packages/core/src/createApp.ts
  • packages/core/src/data/postgres.ts
  • packages/core/src/index.ts
  • packages/core/src/security/csrf.ts
  • packages/core/src/security/env-isolation.ts
  • packages/core/src/security/headers.ts
  • packages/core/src/security/rate-limit.ts
  • packages/core/src/security/security.test.ts
  • packages/create-thexjs-app/templates/basic/src/lib/auth.ts
  • packages/create-thexjs-app/templates/basic/src/pages/login.tsx
  • packages/create-thexjs-app/templates/saas/src/api/auth/login.ts
  • packages/create-thexjs-app/templates/saas/src/lib/auth.ts
  • packages/create-thexjs-app/templates/saas/src/pages/login.tsx
💤 Files with no reviewable changes (1)
  • packages/core/src/security/headers.ts

Comment thread .github/dependabot.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread DEPLOY.md Resolved
Comment thread Dockerfile Resolved
Comment thread packages/core/src/data/postgres.ts Resolved
Comment thread packages/core/src/data/postgres.ts Resolved
Comment thread README.md Resolved

@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: 7

🧹 Nitpick comments (1)
examples/landing/src/styles/globals.css (1)

371-402: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

Remove unused crop mark selectors.

.crop-marks .crop-tl and .crop-marks .crop-br are declared here, but the landing example only uses crop-marks and hides its pseudo-elements via inline styles. Remove these dead selector rows unless a component later adds child .crop-tl/.crop-br elements.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/landing/src/styles/globals.css` around lines 371 - 402, Remove the
unused `.crop-marks .crop-tl` and `.crop-marks .crop-br` selectors from the
crop-marks rule, leaving the `.crop-marks` pseudo-element selectors and their
existing styling unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/landing/src/components/boarding-pass.tsx`:
- Around line 48-63: Update deriveTicket to generate a unique stable id
alongside each bar width, then return both values in the bars data. In the
boarding-pass JSX map, replace the index-based key with each bar’s generated id;
do not use width alone, since repeated widths must still produce distinct keys.
- Around line 42-44: Run Biome formatting on the code containing the boarding
time expression in the boarding pass component, and retain explicit parentheses
around the modulo result before multiplication to document the intended operator
grouping.

In `@examples/landing/src/components/route-trail.tsx`:
- Around line 27-75: Update the effect’s onMove handler to guard ref.current
locally and use that guarded element for getBoundingClientRect and appendChild,
removing both el! assertions. In the cleanup callback, replace
live.current.forEach with a for...of loop that removes each pin, preserving the
existing cleanup behavior.

In `@examples/landing/src/styles/globals.css`:
- Around line 598-601: Update the header comment near the “Boarding Pass” styles
so the final comment line includes a space before the closing */ delimiter,
satisfying the comment-whitespace-inside Stylelint rule.
- Around line 78-81: Update the --font-mono declaration in the `@theme` inline
block by changing the SFMono-Regular font keyword to lowercase, preserving the
existing fallback order and other font declarations.
- Around line 172-176: Update the em and i style rule to remove the conflicting
not-italic utility from its `@apply` directive, while preserving font-display,
italic, and text-primary.

In `@packages/create-thexjs-app/templates/saas/src/lib/auth.ts`:
- Around line 47-55: Update authenticate to prevent the universal admin/admin
credential from granting sessions: use user lookup with password-hash
verification, or gate demo authentication behind an explicit non-production
mode. Ensure both existing callers retain the Session/null contract, and add
coverage confirming the demo credential is rejected in production mode.

---

Nitpick comments:
In `@examples/landing/src/styles/globals.css`:
- Around line 371-402: Remove the unused `.crop-marks .crop-tl` and `.crop-marks
.crop-br` selectors from the crop-marks rule, leaving the `.crop-marks`
pseudo-element selectors and their existing styling unchanged.
🪄 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 Plus

Run ID: 29e68430-8027-4139-a629-51ba76094b96

📥 Commits

Reviewing files that changed from the base of the PR and between e9d4fca and b230767.

⛔ Files ignored due to path filters (7)
  • bun.lock is excluded by !**/*.lock
  • examples/landing/public/files/inter-latin-ext-wght-normal.woff2 is excluded by !**/*.woff2
  • examples/landing/public/files/inter-latin-wght-normal.woff2 is excluded by !**/*.woff2
  • examples/landing/public/files/jetbrains-mono-latin-ext-wght-normal.woff2 is excluded by !**/*.woff2
  • examples/landing/public/files/jetbrains-mono-latin-wght-normal.woff2 is excluded by !**/*.woff2
  • examples/landing/public/files/space-grotesk-latin-ext-wght-normal.woff2 is excluded by !**/*.woff2
  • examples/landing/public/files/space-grotesk-latin-wght-normal.woff2 is excluded by !**/*.woff2
📒 Files selected for processing (21)
  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • DEPLOY.md
  • Dockerfile
  • LICENSE
  • README.md
  • examples/basic/package.json
  • examples/landing/package.json
  • examples/landing/src/components/boarding-pass.tsx
  • examples/landing/src/components/route-trail.tsx
  • examples/landing/src/pages/index.tsx
  • examples/landing/src/pages/play.tsx
  • examples/landing/src/styles/globals.css
  • examples/landing/x.config.ts
  • package.json
  • packages/core/src/data/postgres.ts
  • packages/core/src/data/sqlite.ts
  • packages/core/src/security/rate-limit.ts
  • packages/create-thexjs-app/templates/saas/src/api/auth/login.ts
  • packages/create-thexjs-app/templates/saas/src/lib/auth.ts
  • packages/create-thexjs-app/templates/saas/src/pages/login.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
  • Dockerfile
  • package.json
  • .github/workflows/ci.yml
  • README.md
  • packages/create-thexjs-app/templates/saas/src/pages/login.tsx
  • packages/create-thexjs-app/templates/saas/src/api/auth/login.ts
  • examples/landing/src/pages/index.tsx
  • packages/core/src/data/postgres.ts
  • DEPLOY.md

Comment on lines +27 to +75
useEffect(() => {
const el = ref.current;
if (!el) return;
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
if (window.matchMedia("(pointer: coarse)").matches) return; // skip on touch

function onMove(e: PointerEvent) {
const rect = el!.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
if (x < 0 || y < 0 || x > rect.width || y > rect.height) return;

const prev = last.current;
if (prev) {
const dx = x - prev.x;
const dy = y - prev.y;
if (Math.hypot(dx, dy) < MIN_DISTANCE) return;
}
last.current = { x, y };

const pin = document.createElement("span");
pin.className = "route-pin-drop";
pin.style.left = `${x}px`;
pin.style.top = `${y}px`;
pin.style.transform = "translate(-50%, -50%)";
el!.appendChild(pin);
live.current.push(pin);

if (live.current.length > MAX_LIVE_PINS) {
const stale = live.current.shift();
stale?.remove();
}

window.setTimeout(() => {
pin.remove();
live.current = live.current.filter((p) => p !== pin);
}, PIN_LIFETIME_MS);
}

// Listen on window rather than the (pointer-events-none) overlay itself —
// the overlay must stay click-through so it never eats clicks on the
// hero's real buttons/inputs, so we hit-test against its rect instead.
window.addEventListener("pointermove", onMove);
return () => {
window.removeEventListener("pointermove", onMove);
live.current.forEach((p) => p.remove());
live.current = [];
};
}, []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does TypeScript narrow a const variable captured by a nested function declaration after an early-return null check on the outer variable?

💡 Result:

Whether TypeScript preserves the narrowed type of a const variable inside a nested function declaration depends on the type of function used (declaration vs. expression) and current TypeScript limitations. In general, TypeScript does not maintain type refinements for variables captured within nested function declarations (the function name() {} syntax) [1][2]. This is primarily because function declarations are hoisted to the top of the enclosing scope, meaning the function could theoretically be called before the code that performs the narrowing has executed [1]. Because of this hoisting, the compiler cannot safely assume the variable has been narrowed when the function is eventually invoked [1]. Key distinctions and behaviors include: 1. Function Declarations vs. Expressions: If you define the nested function as a function expression (e.g., const inner = () => { ... } or const inner = function() { ... }), TypeScript is often able to preserve the narrowed type because it can verify the closure is created after the narrowing has occurred [1][3]. 2. Limitations with Hoisting: Even for const variables, which cannot be reassigned, the compiler does not currently distinguish between them and other variables regarding this hoisting-related limitation [1]. There is an active, long-standing request to improve this, but it remains a known constraint [1][4]. 3. Workarounds: - Use function expressions instead of function declarations when the function must capture a narrowed variable [1]. - Alias the narrowed value to a new constant inside the narrowed scope (e.g., const narrowedAlias = variable;) [4][5]. Since this new constant is block-scoped and defined only after the narrowing, capturing this alias in a nested function will typically preserve the expected type [4][5]. In summary, while it may seem logical for TypeScript to preserve narrowing for a const variable in a hoisted function declaration, it currently does not [1]. Using function expressions or local aliasing are the recommended patterns to achieve the desired type-safety [1][4].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== candidate files =="
fd -a 'route-trail\.tsx|tsconfig.*' . || true

echo "== route-trail.tsx outline =="
ast-grep outline examples/landing/src/components/route-trail.tsx || true

echo "== route-trail.tsx relevant lines =="
cat -n examples/landing/src/components/route-trail.tsx | sed -n '1,110p'

Repository: abdelkabirouadoukou/x

Length of output: 4702


Avoid el! and forEach in this effect.

el! at Lines 34 and 52 triggers Biome noNonNullAssertion; add a local guard at the start of onMove instead of assuming the outer null check persists there. Replace live.current.forEach((p) => p.remove()) at Line 72 with a for...of loop to satisfy noForEach.

🧰 Tools
🪛 GitHub Actions: CI / 0_Test (ubuntu-latest).txt

[error] 34-34: Biome lint/style/noNonNullAssertion: Forbidden non-null assertion on 'el!'.


[error] 52-52: Biome lint/style/noNonNullAssertion: Forbidden non-null assertion on 'el!'.


[error] 72-72: Biome lint/complexity/noForEach: Prefer a for...of loop instead of forEach.

🪛 GitHub Actions: CI / 2_Test (macos-latest).txt

[error] 34-34: Biome lint/style/noNonNullAssertion: Forbidden non-null assertion on 'el!'.


[error] 52-52: Biome lint/style/noNonNullAssertion: Forbidden non-null assertion on 'el!'.


[error] 72-72: Biome lint/complexity/noForEach: Prefer a for...of loop instead of forEach.

🪛 GitHub Actions: CI / Test (macos-latest)

[error] 34-34: Biome lint error (lint/style/noNonNullAssertion): Forbidden non-null assertion on 'el!'.


[error] 52-52: Biome lint error (lint/style/noNonNullAssertion): Forbidden non-null assertion on 'el!'.


[error] 72-72: Biome lint error (lint/complexity/noForEach): Prefer a for...of loop instead of forEach.

🪛 GitHub Actions: CI / Test (ubuntu-latest)

[error] 34-34: Biome lint error (lint/style/noNonNullAssertion): Forbidden non-null assertion on el!. Replace it with safer null-aware logic. Command: bun run lint.


[error] 52-52: Biome lint error (lint/style/noNonNullAssertion): Forbidden non-null assertion on el!. Replace it with safer null-aware logic. Command: bun run lint.


[error] 72-72: Biome lint error (lint/complexity/noForEach): Prefer a for...of loop instead of forEach. Command: bun run lint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/landing/src/components/route-trail.tsx` around lines 27 - 75, Update
the effect’s onMove handler to guard ref.current locally and use that guarded
element for getBoundingClientRect and appendChild, removing both el! assertions.
In the cleanup callback, replace live.current.forEach with a for...of loop that
removes each pin, preserving the existing cleanup behavior.

Source: Pipeline failures

Comment on lines 78 to +81
@theme inline {
--font-display: "Oswald", ui-sans-serif, system-ui, sans-serif;
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
--font-mono: "IBM Plex Mono", ui-monospace, monospace;
--font-display: "Space Grotesk Variable", ui-sans-serif, system-ui, sans-serif;
--font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
--font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, monospace;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the Stylelint keyword-case failure.

CI reports value-keyword-case at Line 81 for SFMono-Regular. Lowercase the keyword to match the project's Stylelint configuration.

🎨 Proposed fix
-  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, monospace;
+  --font-mono: "JetBrains Mono Variable", ui-monospace, sfmono-regular, monospace;
📝 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
@theme inline {
--font-display: "Oswald", ui-sans-serif, system-ui, sans-serif;
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
--font-mono: "IBM Plex Mono", ui-monospace, monospace;
--font-display: "Space Grotesk Variable", ui-sans-serif, system-ui, sans-serif;
--font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
--font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, monospace;
`@theme` inline {
--font-display: "Space Grotesk Variable", ui-sans-serif, system-ui, sans-serif;
--font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
--font-mono: "JetBrains Mono Variable", ui-monospace, sfmono-regular, monospace;
🧰 Tools
🪛 Stylelint (17.14.1)

[error] 81-81: Expected "SFMono-Regular" to be "sfmono-regular" (value-keyword-case)

(value-keyword-case)


[error] 78-78: Unexpected unknown at-rule "@theme" (scss/at-rule-no-unknown)

(scss/at-rule-no-unknown)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/landing/src/styles/globals.css` around lines 78 - 81, Update the
--font-mono declaration in the `@theme` inline block by changing the
SFMono-Regular font keyword to lowercase, preserving the existing fallback order
and other font declarations.

Source: Linters/SAST tools

Comment on lines +172 to +176
/* accent the display font's red kicker runs in italics when present */
em,
i {
@apply font-display not-italic italic text-primary;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Remove the conflicting not-italic utility.

@apply font-display not-italic italic text-primary; applies both not-italic and italic to font-style. Since italic is listed after not-italic, it wins in the cascade, so not-italic has no effect. The surrounding comment states the intent is italics, so drop the dead not-italic class.

🎨 Proposed fix
   em,
   i {
-    `@apply` font-display not-italic italic text-primary;
+    `@apply` font-display italic text-primary;
   }
📝 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
/* accent the display font's red kicker runs in italics when present */
em,
i {
@apply font-display not-italic italic text-primary;
}
/* accent the display font's red kicker runs in italics when present */
em,
i {
`@apply` font-display italic text-primary;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/landing/src/styles/globals.css` around lines 172 - 176, Update the
em and i style rule to remove the conflicting not-italic utility from its `@apply`
directive, while preserving font-display, italic, and text-primary.

Comment on lines +598 to +601
/* ---------------------------------------------------------------------- */
/* Boarding Pass — personalized ticket generator (new feature, see */
/* boarding-pass.tsx). Perforated stub layout + a barcode made of CSS bars.*/
/* ---------------------------------------------------------------------- */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the Stylelint comment-whitespace failure.

CI reports comment-whitespace-inside at Line 600. Add a space before the closing */.

🎨 Proposed fix
-/* boarding-pass.tsx). Perforated stub layout + a barcode made of CSS bars.*/
+/* boarding-pass.tsx). Perforated stub layout + a barcode made of CSS bars. */
📝 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
/* ---------------------------------------------------------------------- */
/* Boarding Pass — personalized ticket generator (new feature, see */
/* boarding-pass.tsx). Perforated stub layout + a barcode made of CSS bars.*/
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* Boarding Pass — personalized ticket generator (new feature, see */
/* boarding-pass.tsx). Perforated stub layout + a barcode made of CSS bars. */
/* ---------------------------------------------------------------------- */
🧰 Tools
🪛 Stylelint (17.14.1)

[error] 600-600: Expected whitespace before "*/" (comment-whitespace-inside)

(comment-whitespace-inside)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/landing/src/styles/globals.css` around lines 598 - 601, Update the
header comment near the “Boarding Pass” styles so the final comment line
includes a space before the closing */ delimiter, satisfying the
comment-whitespace-inside Stylelint rule.

Source: Linters/SAST tools

Comment on lines +47 to +55
// DEMO ONLY: the single source of truth for the credential check, shared by
// the login API route and the login page's server fallback. Replace this with
// real (hashed) password verification before shipping.
export function authenticate(email: string, password: string): Session | null {
if (email === "admin" && password === "admin") {
return createSession(email);
}
return null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Do not ship a universal admin / admin credential.

Line 51 grants a session to any caller who knows the template defaults. Both the login API and the page loader use authenticate, so this credential enables access through both flows.

The DEMO ONLY comment does not enforce safe deployment. Replace this with user lookup and password-hash verification, or disable demo authentication unless an explicit non-production mode is enabled. Add a test that rejects the demo credential in production mode.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/create-thexjs-app/templates/saas/src/lib/auth.ts` around lines 47 -
55, Update authenticate to prevent the universal admin/admin credential from
granting sessions: use user lookup with password-hash verification, or gate demo
authentication behind an explicit non-production mode. Ensure both existing
callers retain the Session/null contract, and add coverage confirming the demo
credential is rejected in production mode.

- Updated package.json in examples/basic to re-add "shadcn" dependency.
- Refactored boarding-pass.tsx to use bitwise right shift operator for seat calculations and improved barcode rendering logic.
- Enhanced route-trail.tsx by changing function declaration to arrow function and improved cleanup logic.
- Cleaned up index.tsx and play.tsx for better readability by adjusting JSX formatting.
- Added overrides for specific packages in the root package.json.
- Enhanced adapter-vercel to include stylesheetHref in the generated entry and manifest.
- Updated core build and app creation logic to handle stylesheetHref more effectively.
- Simplified Postgres client type definitions and connection logic for better readability.
@abdelkabirouadoukou
abdelkabirouadoukou merged commit fbfb44e into main Aug 1, 2026
7 checks passed
abdelkabirouadoukou added a commit that referenced this pull request Aug 20, 2026
- changeset: scope the 'no embedded literals' claim to masked quoted
  strings; note the template-tag path binds values out-of-band (#1)
- cli: serialize Tailwind recompiles so saves coalesce into one follow-up
  run after the active compile exits, instead of stacking overlapping
  processors writing the same output (#8); unit test proves no two
  compiles overlap, verified to fail against the old concurrent spawn
- redact: capture the authorization/auth keyword group so it survives the
  $1 replacement instead of emitting a literal '$1 [REDACTED]' (#9);
  exact-output regression test verified against the old non-capturing regex
- tracing: stop double-recording a throwing handler error on the x.http
  root span (the wrapper's fail() plus runWithRequestSpan's catch) (#11);
  mask quoted SQL string literals to '?' in db.statement (#13) — both
  verified failing against the previous behavior
- redis rate-limit test: FakeRedis PTTL now validates its key argument
  instead of silently modeling a malformed call as a missing key (#15)
- auth: empty-identifier regression test now provably fails against the
  old shared `login:` account key (auth.ts skip logic and brute-force
  namespacing both reverted to confirm); IP-bucket test rewritten so the
  attacker's own successful login must NOT reset the spray counter
  (verified it fails when the success path clears the IP bucket)
abdelkabirouadoukou added a commit that referenced this pull request Aug 20, 2026
… (#141)

* feat(core): request-scoped OpenTelemetry tracing correlation (#79)

@thexjs/core never initializes OpenTelemetry itself — apps opt in by calling setTracer() (or getTracer()) with any tracer whose startSpan(name, { attributes }) matches the OTel surface. Without a configured tracer the layer degrades to synchronous no-ops.

Every request opens an x.http root span carrying the x.requestId attribute plus route/method/status; with no inbound x-request-id, one is minted and shared via traceRequestId() so the log line, the response header and the trace span all agree. Request-scoped phase spans cover the whole pipeline, all correlated by x.requestId: x.api (API routes), x.loader (page loaders + SSR/SSG), x.action (server functions), x.middleware (composed onion + handler), x.ssr, and x.db (both connectSQLite and connectPostgres, wrapping query/run/execute/template-tag calls with db.system, db.operation and a redacted + truncated db.statement). Errors inside any span set ERROR and record an exception.

runWithRequestSpan, tracePhase, tracePhaseSync, dbTraceAttributes, TraceSpan and TracerLike are exported. Mock-tracer tests cover a failing DB call carrying the request id, phase spans, error status propagation and the full createApp request lifecycle.

* fix(core): reject hydration beacons from prefix-matching or opaque origins (#138)

The hydration-mismatch beacon used a prefix match on the canonical origin, so Origin: https://localhost.evil.com passed (not just https://localhost). Exact-match now: the header is parsed via originFromHeader and compared as a full origin string, and a present-but-unparseable header (Origin: null from a sandboxed/opaque origin) is treated as cross-site rather than absent. Regression tests cover the evil-prefix origin and Origin: null.

* fix(core): deterministic routing when dynamic routes tie (#140)

Same-category route ties (e.g. /bar/[b] vs /[a]/foo both matching /bar/foo) were left to the OS's directory-scan order, so a build could serve different pages on different platforms. Ties are now broken segment-by-segment by positional specificity (literal 0 > param 1 > catch-all 2), falling back to a lexical routePath sort — deterministic everywhere and documented in the core README. Regression test with both fixture routes active.

* fix(core): serialize concurrent Postgres migrations with an advisory lock (#131)

runPostgresMigrations now runs inside one client.begin() transaction holding SELECT pg_advisory_xact_lock(MIGRATION_LOCK_KEY), so a second process racing the same migration set can't double-apply or interleave DDL. The applied-tracking read happens under the lock, migrations use savepoints, and a failure rolls back only its own migration while prior successes keep their commit. Concurrency regression test added.

* fix(core): pin image-proxy fetch to the verified public IP to close the DNS-rebinding TOCTOU (#132)

The allow-listed hostname was resolved once for validation but the actual fetch re-resolved it, so the DNS answer for the fetch could differ (a second lookup rebinding to a private address). The target is now resolved a single time: private/reserved literals are rejected, every DNS answer must be public, and the first public IP is pinned into the fetch via the Host header + tls.serverName with redirect: manual. Each redirect hop re-resolves and re-pins before connecting. Tests cover pinning on first fetch and on every hop.

* fix(auth): rate-guess spraying across IPs with separate account and IP buckets (#133)

Brute-force was keyed by (IP, identifier), so rotating source IPs reset the throttle. createBruteForceGuard now maintains two independent buckets — an account bucket (identifier alone) stopping guessing one account from many IPs, and an IP bucket (client IP) stopping one IP spraying many accounts — checked together, failed/reset together, with Retry-After reflecting the longer window. Tests updated and extended for the two-bucket behavior.

* fix(core): generated href() now fills catch-all params instead of dropping them (#134)

A catch-all like /docs/* compiles to a * token with no :slug to substitute, so href('/docs/*', { slug }) only stripped the * and returned '/docs/'. The generated href() now substitutes * segments in param order with the value (segments encoded individually so multi-segment values keep their slashes). New runtime test imports the generated manifest and asserts catch-all, param and static href calls.

* fix(core): Redis rate-limiter reports the real window reset, not a sliding one (#135)

The Redis store returned resetAt = Date.now() + windowMs on every call, so Retry-After kept sliding forward instead of converging on the TTL the EXPIRE enforces. incr() now reads PTTL right after INCR (clamped to >= 0) and derives resetAt from the key's actual remaining life. FakeRedis models PTTL and a regression test verifies a mid-window key reports ~remaining, not the full window; verified it fails against the old implementation.

* fix(core): mask connection-string passwords in log redaction (#136)

redactString already masked bearer/basic credentials and inline Authorization values but not URI userinfo, so postgres://deploy:supersecret@db:5432/app printed the password. Redaction now masks the userinfo password for any scheme (http, postgres, mysql, redis, ...) via a scheme://user:pass@ shape regex, leaving password-less URLs untouched. Regression tests added for the common drivers.

* fix(cli): keep dev server responsive during Tailwind recompiles and exit promptly on SIGTERM (#137, #139)

Dev-mode Tailwind recompilation used an async spawn but awaited it synchronously, stalling request handling until the (potentially multi-second) recompile finished; the watcher path now uses a true async compile so the server stays responsive mid-build. shutdown() awaited server.stop(true) inside the 3s window, so a SIGTERM that arrived with nothing left to drain still waited the full grace period — it now stops immediately and the timer is a hard-cap fallback (unref'd). E2E tests cover both: a fake-slow bunx keeping the dev server under 1s, and prompt SIGTERM exit.

* fix(core): lock bookkeeping-table creation in Postgres migrations (#131)

The _x_migrations table was created via CREATE TABLE IF NOT EXISTS before the advisory lock, so two booting replicas raced that DDL and hit Postgres's simultaneous-create catalog race (pg_type_typname_nsp_index) before serialization kicked in. Moving the table creation inside the locked transaction means the loser instead finds the table the winner committed and proceeds to skip — the advisory lock now guards the entire run.

* fix: finish CodeRabbit review on tracing PR (#141, #79, #131-#140)

- changeset: scope the 'no embedded literals' claim to masked quoted
  strings; note the template-tag path binds values out-of-band (#1)
- cli: serialize Tailwind recompiles so saves coalesce into one follow-up
  run after the active compile exits, instead of stacking overlapping
  processors writing the same output (#8); unit test proves no two
  compiles overlap, verified to fail against the old concurrent spawn
- redact: capture the authorization/auth keyword group so it survives the
  $1 replacement instead of emitting a literal '$1 [REDACTED]' (#9);
  exact-output regression test verified against the old non-capturing regex
- tracing: stop double-recording a throwing handler error on the x.http
  root span (the wrapper's fail() plus runWithRequestSpan's catch) (#11);
  mask quoted SQL string literals to '?' in db.statement (#13) — both
  verified failing against the previous behavior
- redis rate-limit test: FakeRedis PTTL now validates its key argument
  instead of silently modeling a malformed call as a missing key (#15)
- auth: empty-identifier regression test now provably fails against the
  old shared `login:` account key (auth.ts skip logic and brute-force
  namespacing both reverted to confirm); IP-bucket test rewritten so the
  attacker's own successful login must NOT reset the spray counter
  (verified it fails when the success path clears the IP bucket)
abdelkabirouadoukou added a commit that referenced this pull request Aug 20, 2026
* feat(core): request-scoped OpenTelemetry tracing correlation (#79)

@thexjs/core never initializes OpenTelemetry itself — apps opt in by calling setTracer() (or getTracer()) with any tracer whose startSpan(name, { attributes }) matches the OTel surface. Without a configured tracer the layer degrades to synchronous no-ops.

Every request opens an x.http root span carrying the x.requestId attribute plus route/method/status; with no inbound x-request-id, one is minted and shared via traceRequestId() so the log line, the response header and the trace span all agree. Request-scoped phase spans cover the whole pipeline, all correlated by x.requestId: x.api (API routes), x.loader (page loaders + SSR/SSG), x.action (server functions), x.middleware (composed onion + handler), x.ssr, and x.db (both connectSQLite and connectPostgres, wrapping query/run/execute/template-tag calls with db.system, db.operation and a redacted + truncated db.statement). Errors inside any span set ERROR and record an exception.

runWithRequestSpan, tracePhase, tracePhaseSync, dbTraceAttributes, TraceSpan and TracerLike are exported. Mock-tracer tests cover a failing DB call carrying the request id, phase spans, error status propagation and the full createApp request lifecycle.

* fix(core): reject hydration beacons from prefix-matching or opaque origins (#138)

The hydration-mismatch beacon used a prefix match on the canonical origin, so Origin: https://localhost.evil.com passed (not just https://localhost). Exact-match now: the header is parsed via originFromHeader and compared as a full origin string, and a present-but-unparseable header (Origin: null from a sandboxed/opaque origin) is treated as cross-site rather than absent. Regression tests cover the evil-prefix origin and Origin: null.

* fix(core): deterministic routing when dynamic routes tie (#140)

Same-category route ties (e.g. /bar/[b] vs /[a]/foo both matching /bar/foo) were left to the OS's directory-scan order, so a build could serve different pages on different platforms. Ties are now broken segment-by-segment by positional specificity (literal 0 > param 1 > catch-all 2), falling back to a lexical routePath sort — deterministic everywhere and documented in the core README. Regression test with both fixture routes active.

* fix(core): serialize concurrent Postgres migrations with an advisory lock (#131)

runPostgresMigrations now runs inside one client.begin() transaction holding SELECT pg_advisory_xact_lock(MIGRATION_LOCK_KEY), so a second process racing the same migration set can't double-apply or interleave DDL. The applied-tracking read happens under the lock, migrations use savepoints, and a failure rolls back only its own migration while prior successes keep their commit. Concurrency regression test added.

* fix(core): pin image-proxy fetch to the verified public IP to close the DNS-rebinding TOCTOU (#132)

The allow-listed hostname was resolved once for validation but the actual fetch re-resolved it, so the DNS answer for the fetch could differ (a second lookup rebinding to a private address). The target is now resolved a single time: private/reserved literals are rejected, every DNS answer must be public, and the first public IP is pinned into the fetch via the Host header + tls.serverName with redirect: manual. Each redirect hop re-resolves and re-pins before connecting. Tests cover pinning on first fetch and on every hop.

* fix(auth): rate-guess spraying across IPs with separate account and IP buckets (#133)

Brute-force was keyed by (IP, identifier), so rotating source IPs reset the throttle. createBruteForceGuard now maintains two independent buckets — an account bucket (identifier alone) stopping guessing one account from many IPs, and an IP bucket (client IP) stopping one IP spraying many accounts — checked together, failed/reset together, with Retry-After reflecting the longer window. Tests updated and extended for the two-bucket behavior.

* fix(core): generated href() now fills catch-all params instead of dropping them (#134)

A catch-all like /docs/* compiles to a * token with no :slug to substitute, so href('/docs/*', { slug }) only stripped the * and returned '/docs/'. The generated href() now substitutes * segments in param order with the value (segments encoded individually so multi-segment values keep their slashes). New runtime test imports the generated manifest and asserts catch-all, param and static href calls.

* fix(core): Redis rate-limiter reports the real window reset, not a sliding one (#135)

The Redis store returned resetAt = Date.now() + windowMs on every call, so Retry-After kept sliding forward instead of converging on the TTL the EXPIRE enforces. incr() now reads PTTL right after INCR (clamped to >= 0) and derives resetAt from the key's actual remaining life. FakeRedis models PTTL and a regression test verifies a mid-window key reports ~remaining, not the full window; verified it fails against the old implementation.

* fix(core): mask connection-string passwords in log redaction (#136)

redactString already masked bearer/basic credentials and inline Authorization values but not URI userinfo, so postgres://deploy:supersecret@db:5432/app printed the password. Redaction now masks the userinfo password for any scheme (http, postgres, mysql, redis, ...) via a scheme://user:pass@ shape regex, leaving password-less URLs untouched. Regression tests added for the common drivers.

* fix(cli): keep dev server responsive during Tailwind recompiles and exit promptly on SIGTERM (#137, #139)

Dev-mode Tailwind recompilation used an async spawn but awaited it synchronously, stalling request handling until the (potentially multi-second) recompile finished; the watcher path now uses a true async compile so the server stays responsive mid-build. shutdown() awaited server.stop(true) inside the 3s window, so a SIGTERM that arrived with nothing left to drain still waited the full grace period — it now stops immediately and the timer is a hard-cap fallback (unref'd). E2E tests cover both: a fake-slow bunx keeping the dev server under 1s, and prompt SIGTERM exit.

* fix(core): lock bookkeeping-table creation in Postgres migrations (#131)

The _x_migrations table was created via CREATE TABLE IF NOT EXISTS before the advisory lock, so two booting replicas raced that DDL and hit Postgres's simultaneous-create catalog race (pg_type_typname_nsp_index) before serialization kicked in. Moving the table creation inside the locked transaction means the loser instead finds the table the winner committed and proceeds to skip — the advisory lock now guards the entire run.

* fix: finish CodeRabbit review on tracing PR (#141, #79, #131-#140)

- changeset: scope the 'no embedded literals' claim to masked quoted
  strings; note the template-tag path binds values out-of-band (#1)
- cli: serialize Tailwind recompiles so saves coalesce into one follow-up
  run after the active compile exits, instead of stacking overlapping
  processors writing the same output (#8); unit test proves no two
  compiles overlap, verified to fail against the old concurrent spawn
- redact: capture the authorization/auth keyword group so it survives the
  $1 replacement instead of emitting a literal '$1 [REDACTED]' (#9);
  exact-output regression test verified against the old non-capturing regex
- tracing: stop double-recording a throwing handler error on the x.http
  root span (the wrapper's fail() plus runWithRequestSpan's catch) (#11);
  mask quoted SQL string literals to '?' in db.statement (#13) — both
  verified failing against the previous behavior
- redis rate-limit test: FakeRedis PTTL now validates its key argument
  instead of silently modeling a malformed call as a missing key (#15)
- auth: empty-identifier regression test now provably fails against the
  old shared `login:` account key (auth.ts skip logic and brute-force
  namespacing both reverted to confirm); IP-bucket test rewritten so the
  attacker's own successful login must NOT reset the spray counter
  (verified it fails when the success path clears the IP bucket)

* fix(release): bump changesets/action to v2 for changesets CLI v3

changesets/action@v1 detects published packages by parsing the publish
command's stdout for 'New tag:' lines, which @changesets/cli v3 no longer
prints. Since the CLI was bumped to v3.0.0 (#55), npm publishes succeeded
but the action never pushed git tags or created GitHub releases.

v2 reads the CHANGESETS_OUTPUT event file the CLI writes instead and
fails loudly if that output is missing. Rename the custom-script inputs
to their v2 names (version-script, publish-script, pr-title,
commit-message).

This branch was successfully deployed

2 active deployments
Preview – thexjs-basic — ee2ff4f3 Deployed Aug 1, 2026 by vercel[bot]
Preview – x — ee2ff4f3 Deployed Aug 1, 2026 by vercel[bot]
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.

1 participant