Skip to content

Enhanced HTTP Response class with convenient static methods for common scenarios

License

dep-ts/response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@dep/response 🌐

Enhanced HTTP Response class with convenient static methods for common scenarios. A lightweight wrapper around the native Response class for Node.js and browser environments.

JSR version

Features ✨

  • 🛠️ Extends standard Response with zero overhead
  • 🎯 Full TypeScript support with native types
  • ⚡ Static helpers for common HTTP scenarios
  • 📡 Works seamlessly with standard Fetch API
  • 🚀 No dependencies, minimal footprint

Installation 📦

@dep/response is published on JSR.io and is primarily designed for Deno. It can also be used in Node.js (18+) and browsers via JSR.

  • Deno:

    import { HttpResponse } from 'jsr:@dep/response';
  • Node.js (18+) or Browsers:

    npx jsr add @dep/response

    Then import as an ES module:

    import { HttpResponse } from '@dep/response';

Usage 🎯

API 🧩

import { HttpResponse } from '@dep/response';

// Success responses
HttpResponse.json({ data: user });
HttpResponse.success(user, 'User found');
HttpResponse.created(newUser, 'User created successfully');

// Error responses
HttpResponse.notFound('User not found');
HttpResponse.unauthorized('Invalid credentials');
HttpResponse.serverError('DATABASE_ERROR', 'Unable to connect');

// Special responses
HttpResponse.noContent();
HttpResponse.redirect('/login');

License 📄

MIT License – see LICENSE for details.

Author: Estarlin R (estarlincito.com)

About

Enhanced HTTP Response class with convenient static methods for common scenarios

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published