1.0.0 โ€ข Published 5 months ago

express-superjson v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

NPM Version GitHub Actions Workflow Status Codecov GitHub License GitHub Repo stars

๐Ÿ”„ express-superjson

Express middleware that seamlessly integrates Superjson into your Express.js applications, enabling automatic handling of JavaScript built-in types in HTTP responses.

๐Ÿš€ Installation

Install the package using your preferred package manager. Here's an example using pnpm:

pnpm add superjson express-superjson

๐Ÿ“ Example Usage

import express from 'express';
import superjsonMiddleware from 'express-superjson';

const app = express();

app.use(express.json());

// This middleware must be registered after `express.json()` middleware.
app.use(superjsonMiddleware());

app.get('/', (req, res) => {
  res.json({ date: new Date() });
});

app.listen(3000, () => console.log('Application is running on port 3000.'));

Send a GET request to http://localhost:3000 and you'll receive a Superjson response like below:

{
  "json": {
    "date": "2023-01-01T00:00:00.000Z"
  },
  "meta": {
    "values": {
      "date": ["Date"]
    }
  }
}

๐Ÿงช Code Coverage and Tests

Tests are crucial for ensuring that the library functions as expected. You can review the code coverage reports by visiting Codecov. The primary objective is to achieve complete coverage of the entire codebase through rigorous testing.

โ˜• Support

If you find this project useful and would like to support me, you can do so by visiting my website.

1.0.0

5 months ago