Skip to content

feat: Status Codes Constant case#1758

Open
gabrielmar wants to merge 1 commit intoelysiajs:mainfrom
gabrielmar:feat/normalize-status-codes
Open

feat: Status Codes Constant case#1758
gabrielmar wants to merge 1 commit intoelysiajs:mainfrom
gabrielmar:feat/normalize-status-codes

Conversation

@gabrielmar
Copy link

@gabrielmar gabrielmar commented Feb 26, 2026

Normalize and rename StatusMap

Before:

try {
  const response = await fetch('https://jsonplaceholder.typicode.com/todos/1')
  const data = await response.json()

  return data ? status(StatusMap.OK, data) : status(StatusMap['Not Found'])
} catch {
  return status(StatusMap['Internal Server Error'])
}

After:

try {
  const response = await fetch('https://jsonplaceholder.typicode.com/todos/1');
  const data = await response.json();

  return data ? status(StatusCodes.OK, data) : status(StatusCodes.NOT_FOUND);
} catch {
  return status(StatusCodes.INTERNAL_SERVER_ERROR);
}

Closes #1757

Summary by CodeRabbit

  • New Features

    • Introduced StatusCodes constant with standardized HTTP status code definitions.
  • Deprecations

    • StatusMap is deprecated and scheduled for removal in version 2.0. Please migrate to StatusCodes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

Walkthrough

A new StatusCodes object with uppercase HTTP status code constants was introduced, while the existing StatusMap was marked deprecated with a version 2.0 removal notice. This standardizes the casing convention for HTTP status codes.

Changes

Cohort / File(s) Summary
HTTP Status Code Standardization
src/utils.ts
Added new StatusCodes export with canonical HTTP status constants in CONSTANT_CASE format; deprecated existing StatusMap with JSDoc indicating removal in v2.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hopping through constants with constant care,
Status codes dressed in uppercase flair,
From mixed-up cases to CONSTANT so bright,
Industry standards now shining in sight,
Protocol stability: always just right! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: introducing StatusCodes in CONSTANT_CASE as requested in the linked issue.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #1757: introducing StatusCodes with CONSTANT_CASE naming (e.g., NOT_FOUND, INTERNAL_SERVER_ERROR) to standardize HTTP status code identifiers.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue's objective: adding StatusCodes constant and deprecating StatusMap. No unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/utils.ts (3)

665-666: Use standard JSDoc tags or descriptive comments.

@unused (line 665) and @Twitter (line 689) are non-standard JSDoc tags and won't be recognized by documentation tools or IDEs. Consider using @see or plain descriptions.

Proposed fix
-	/** `@unused` */
-	UNUSED: 306,
+	/** Reserved; no longer used in HTTP/1.1 */
+	UNUSED: 306,
-	/** `@Twitter` */
-	ENHANCE_YOUR_CALM: 420,
+	/** Unofficial; originally defined by Twitter */
+	ENHANCE_YOUR_CALM: 420,

Also applies to: 689-690

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils.ts` around lines 665 - 666, Replace the non-standard JSDoc tags by
changing the comment on the UNUSED enum entry and the TWITTER-related comment to
use standard tags or plain descriptive comments: remove "@unused" from the
comment above the UNUSED symbol and either replace it with a short plain comment
like "Unused placeholder" or a standard JSDoc tag such as "@deprecated" if
appropriate, and do the same for the "@Twitter" comment—use "@see", a short
descriptive comment, or a standard tag instead so IDEs and doc tools can
recognize them; update the comments near the symbols UNUSED and the
TWITTER-related entry accordingly.

716-720: Consider the lifecycle of InvertedStatusMap given StatusMap deprecation.

InvertedStatusMap derives from the now-deprecated StatusMap. When StatusMap is removed in 2.0, you'll need to decide whether to:

  1. Remove InvertedStatusMap alongside it
  2. Add an equivalent InvertedStatusCodes derived from the new object
  3. Update InvertedStatusMap to derive from StatusCodes (would change key format)

If option 2 is intended, consider adding it now for feature parity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils.ts` around lines 716 - 720, InvertedStatusMap is currently derived
from the deprecated StatusMap; decide which migration path to take and implement
it: either (A) remove InvertedStatusMap when StatusMap is removed, (B) add a new
InvertedStatusCodes that mirrors InvertedStatusMap but is derived from the new
StatusCodes object (create
Object.fromEntries(Object.entries(StatusCodes).map(([k,v])=>[v,k])) and add a
matching typed cast), or (C) change InvertedStatusMap to derive from StatusCodes
now (noting key format/type changes) and update its type declaration
accordingly; update any callers to use the new symbol (InvertedStatusCodes or
the revised InvertedStatusMap) and add a short comment noting the
deprecation/migration choice.

640-714: Add type export for StatusCodes to maintain API symmetry.

StatusMap has a corresponding type export at line 722, but StatusCodes lacks one. TypeScript consumers may need the type for annotations.

Proposed fix

Add after line 714:

export type StatusCodes = typeof StatusCodes
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils.ts` around lines 640 - 714, Add a exported type for StatusCodes so
TypeScript consumers can reference the shape; specifically, create an exported
type alias named StatusCodes that is the typeof the existing StatusCodes
constant (matching how StatusMap's type is exported) and place it after the
StatusCodes constant export.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/utils.ts`:
- Around line 665-666: Replace the non-standard JSDoc tags by changing the
comment on the UNUSED enum entry and the TWITTER-related comment to use standard
tags or plain descriptive comments: remove "@unused" from the comment above the
UNUSED symbol and either replace it with a short plain comment like "Unused
placeholder" or a standard JSDoc tag such as "@deprecated" if appropriate, and
do the same for the "@Twitter" comment—use "@see", a short descriptive comment,
or a standard tag instead so IDEs and doc tools can recognize them; update the
comments near the symbols UNUSED and the TWITTER-related entry accordingly.
- Around line 716-720: InvertedStatusMap is currently derived from the
deprecated StatusMap; decide which migration path to take and implement it:
either (A) remove InvertedStatusMap when StatusMap is removed, (B) add a new
InvertedStatusCodes that mirrors InvertedStatusMap but is derived from the new
StatusCodes object (create
Object.fromEntries(Object.entries(StatusCodes).map(([k,v])=>[v,k])) and add a
matching typed cast), or (C) change InvertedStatusMap to derive from StatusCodes
now (noting key format/type changes) and update its type declaration
accordingly; update any callers to use the new symbol (InvertedStatusCodes or
the revised InvertedStatusMap) and add a short comment noting the
deprecation/migration choice.
- Around line 640-714: Add a exported type for StatusCodes so TypeScript
consumers can reference the shape; specifically, create an exported type alias
named StatusCodes that is the typeof the existing StatusCodes constant (matching
how StatusMap's type is exported) and place it after the StatusCodes constant
export.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbaf6b7 and 0ed2a60.

📒 Files selected for processing (1)
  • src/utils.ts

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.

Change StatusMap casing to Constant case

1 participant