<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matteo Teodori</title>
    <description>The latest articles on DEV Community by Matteo Teodori (@matteoteodori).</description>
    <link>https://dev.to/matteoteodori</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3798577%2F3d486d80-e703-4138-bd73-6ef09b4fc7ed.png</url>
      <title>DEV Community: Matteo Teodori</title>
      <link>https://dev.to/matteoteodori</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matteoteodori"/>
    <language>en</language>
    <item>
      <title>TS-first library to standardize your API responses and errors</title>
      <dc:creator>Matteo Teodori</dc:creator>
      <pubDate>Sat, 28 Feb 2026 18:08:39 +0000</pubDate>
      <link>https://dev.to/matteoteodori/ts-first-library-to-standardize-your-api-responses-and-errors-cli</link>
      <guid>https://dev.to/matteoteodori/ts-first-library-to-standardize-your-api-responses-and-errors-cli</guid>
      <description>&lt;p&gt;Hey everyone! 👋&lt;/p&gt;

&lt;p&gt;If you've ever built a Node.js API, you know the struggle of keeping your HTTP responses and error formats consistent across controllers, middlewares, and services. You often end up writing the same custom error classes and response wrappers over and over again.&lt;/p&gt;

&lt;p&gt;That's exactly why I built &lt;a href="https://www.npmjs.com/package/http-response-kit" rel="noopener noreferrer"&gt;&lt;strong&gt;http-response-kit&lt;/strong&gt;&lt;/a&gt; — to solve this once and for all. It's a clean, professional, and zero-dependency utility that provides a rock-solid standard for all your HTTP payloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✨ What makes it great?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;100% Type-Safe 🛡️:&lt;/strong&gt; Built with TypeScript from the ground up. It fully supports &lt;strong&gt;Generics (&lt;code&gt;&amp;lt;T&amp;gt;&lt;/code&gt;)&lt;/strong&gt;, meaning &lt;code&gt;HttpResponse.ok&amp;lt;User&amp;gt;(userData)&lt;/code&gt; gives you perfect autocomplete and type safety out of the box. No more &lt;code&gt;any&lt;/code&gt; casting.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;35+ Error Factory Methods 🛑:&lt;/strong&gt; Throwing errors is expressive and readable. Just &lt;code&gt;throw HttpError.notFound('User missing')&lt;/code&gt; or &lt;code&gt;HttpError.tooManyRequests('Slow down', 60)&lt;/code&gt;. It covers all standard 4xx and 5xx codes.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Predictable Response Structure 📦:&lt;/strong&gt; Every success or error response follows a strict, predictable JSON interface. Your frontend team will love you.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Zero Dependencies 🪶:&lt;/strong&gt; Keep your &lt;code&gt;node_modules&lt;/code&gt; light and your startup times fast.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Highly Customizable ⚙️:&lt;/strong&gt; Exposes a global &lt;code&gt;configure()&lt;/code&gt; method. You can override default messages, toggle timestamps, or even plug in a custom response transformer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  💻 Quick Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Throw an error anywhere (Controller, Service, Middleware...)&lt;/span&gt;
&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;HttpError&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;badRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid payload&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Return a structured success response with generics!&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User retrieved successfully&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// Outputs: { success: true, status_code: 200, data: { id: 1, ... }, message: "..." }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works beautifully with Express, Fastify, NestJS, native Node, or any other framework you are using. Just catch the errors in your global error handler and stream them via &lt;code&gt;HttpResponse.fromError(err)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I'd love for you to check it out, try it in your next backend project, and let me know your thoughts! Feedback, suggestions, or PRs are super welcome.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;NPM:&lt;/strong&gt; &lt;code&gt;npm i http-response-kit&lt;/code&gt;&lt;br&gt;
🔗 &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/matteo-teodori/http-response-kit" rel="noopener noreferrer"&gt;github.com/matteo-teodori/http-response-kit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding! 💻🔥&lt;/p&gt;

</description>
      <category>node</category>
      <category>npm</category>
      <category>backend</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
