Registry / development / gracely

gracely

JSON →
library2.0.13jsnpmunverified

gracely is a lightweight TypeScript library for creating structured, HTTP-friendly error objects suitable for REST API responses. Version 2.0.13 is stable with a low release cadence. It provides a set of factory functions (e.g., badRequest, notFound) that generate standardized error payloads with status codes, messages, and optional details. Unlike generic error classes, gracely focuses on REST semantics and integrates cleanly with frameworks like Express or Fastify. Ships TypeScript types.

npm install gracely
INSTALL
IMPORT
SIG · GRACELY
G
gracely
developmentjavascriptv2.0.13
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gracely
import { gracely } from 'gracely'
const gracely = require('gracely')
Library is ESM-only; CommonJS require is not supported.
badRequest
import { badRequest } from 'gracely'
import badRequest from 'gracely'
All exports are named, not default. The default export is not present.
NotFoundError
import type { NotFoundError } from 'gracely'
import { NotFoundError } from 'gracely'
Error types are only exported as types, not values. Use import type for TypeScript.

Demonstrates creating structured REST error responses using gracely's factory functions and type guard.

import { gracely, badRequest, notFound } from 'gracely'; const error = badRequest('Validation failed', { field: 'email' }); console.log(error); // { status: 400, title: 'Bad Request', detail: 'Validation failed', details: { field: 'email' } } if (gracely.isError(error)) { console.log('Error status:', error.status); } const notFoundError = notFound('User not found'); console.log(notFoundError); // { status: 404, title: 'Not Found', detail: 'User not found' }
Debug
Known issues
breakingv2.0 removed CommonJS support; library is now ESM-only.
fix
Use ES module imports (import { ... } from 'gracely') instead of require().
affects: >=2.0.0
deprecatedThe function 'serverError' was renamed to 'internalServerError' in v2.0.
fix
Use 'internalServerError' instead of 'serverError'.
affects: >=1.0.0 <2.0.0
gotchagracely.error is not a constructor; use factory functions or the gracely object directly.
fix
Use gracely.fail() or specific factory functions like badRequest() to create errors.
affects: >=2.0.0
breakingError types (e.g., NotFoundError) are no longer available as runtime values; only type exports.
fix
Use import type { NotFoundError } from 'gracely' for TypeScript type annotations.
affects: >=2.0.0
Errors
Common errors & fixes
Module not found: Can't resolve 'gracely'
Missing installation or wrong import path.
fix
Install the package: npm install gracely
TypeError: gracely.badRequest is not a function
Using a wrong import (e.g., default import) or outdated version.
fix
Use named import: import { badRequest } from 'gracely'
Cannot find module 'gracely' from 'index.ts'
CommonJS require() used with ESM-only package.
fix
Switch to ES module imports in your project (type: 'module' in package.json) and use import { ... } from 'gracely'.
Upgrade
Version history
2.0.13latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
65 hits · last 30 days
node
58
Perplexity
1
OpenAI (training)
1
Resources
gracely — npm install gracely · libregistry