express-fast-json-stringify 1.1.4 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.2.2](https://github.com/nigrosimone/express-fast-json-stringify/compare/v1.2.0...v1.2.2) (2024-09-29)
|
|
6
|
+
|
|
7
|
+
## [1.2.0](https://github.com/nigrosimone/express-fast-json-stringify/compare/v1.1.4...v1.2.0) (2024-09-29)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add options ([9466dc3](https://github.com/nigrosimone/express-fast-json-stringify/commit/9466dc30c20693a7ceabf2240d5d9701c76280c0))
|
|
13
|
+
|
|
5
14
|
### [1.1.4](https://github.com/nigrosimone/express-fast-json-stringify/compare/v1.1.2...v1.1.4) (2024-09-29)
|
|
6
15
|
|
|
7
16
|
### [1.1.2](https://github.com/nigrosimone/express-fast-json-stringify/compare/v1.1.0...v1.1.2) (2024-09-29)
|
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
One of the reasons why [Fastify](https://www.npmjs.com/package/fastify) is faster than Express is its use of [fast-json-stringify](https://www.npmjs.com/package/fast-json-stringify). `fast-json-stringify` is a library developed by the Fastify team that boosts JSON conversion speed by analyzing JSON schema definitions.
|
|
4
4
|
|
|
5
|
-
See the stackblitz [demo](https://stackblitz.com/edit/express-fast-json-stringify).
|
|
6
|
-
|
|
7
5
|
By using the `fast-json-stringify` library, Fastify can serialize JSON much faster than Express, contributing to its overall performance advantage.
|
|
8
6
|
|
|
9
7
|
With `express-fast-json-stringify`, you can leverage `fast-json-stringify` in your Express application as follows:
|
|
@@ -45,6 +43,8 @@ app.get('/', fastJsonSchema(schema), (req, res, next) => {
|
|
|
45
43
|
});
|
|
46
44
|
```
|
|
47
45
|
|
|
46
|
+
See the stackblitz [demo](https://stackblitz.com/edit/express-fast-json-stringify).
|
|
47
|
+
|
|
48
48
|
## How to Use
|
|
49
49
|
|
|
50
50
|
1. Install the package:
|
|
@@ -76,7 +76,7 @@ const schema: Schema = {
|
|
|
76
76
|
};
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
3.
|
|
79
|
+
3. Apply the `fastJsonSchema` middleware to your Express route, passing in the schema object, eg.:
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
82
|
import { fastJsonSchema, Schema } from 'express-fast-json-stringify';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { Schema } from 'fast-json-stringify';
|
|
3
|
-
export type { Schema } from 'fast-json-stringify';
|
|
2
|
+
import { Options, Schema } from 'fast-json-stringify';
|
|
3
|
+
export type { Schema, Options } from 'fast-json-stringify';
|
|
4
4
|
/**
|
|
5
5
|
* Set the schema
|
|
6
|
-
* @param {Schema} schema
|
|
6
|
+
* @param {Schema} schema The schema used to stringify values
|
|
7
|
+
* @param {Options} options The options to use (optional)
|
|
7
8
|
*
|
|
8
9
|
* Examples:
|
|
9
10
|
* ```ts
|
|
@@ -42,4 +43,4 @@ export type { Schema } from 'fast-json-stringify';
|
|
|
42
43
|
* });
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
|
-
export declare const fastJsonSchema: (schema: Schema) => (_req: Request, res: Response, next: NextFunction) => void;
|
|
46
|
+
export declare const fastJsonSchema: (schema: Schema, options?: Options) => (_req: Request, res: Response, next: NextFunction) => void;
|
|
@@ -7,7 +7,8 @@ exports.fastJsonSchema = void 0;
|
|
|
7
7
|
const fast_json_stringify_1 = __importDefault(require("fast-json-stringify"));
|
|
8
8
|
/**
|
|
9
9
|
* Set the schema
|
|
10
|
-
* @param {Schema} schema
|
|
10
|
+
* @param {Schema} schema The schema used to stringify values
|
|
11
|
+
* @param {Options} options The options to use (optional)
|
|
11
12
|
*
|
|
12
13
|
* Examples:
|
|
13
14
|
* ```ts
|
|
@@ -46,11 +47,11 @@ const fast_json_stringify_1 = __importDefault(require("fast-json-stringify"));
|
|
|
46
47
|
* });
|
|
47
48
|
* ```
|
|
48
49
|
*/
|
|
49
|
-
const fastJsonSchema = (schema) => {
|
|
50
|
+
const fastJsonSchema = (schema, options) => {
|
|
50
51
|
if (!schema) {
|
|
51
52
|
throw new TypeError(`express-fast-json-stringify: invalid schema`);
|
|
52
53
|
}
|
|
53
|
-
const fjs = (0, fast_json_stringify_1.default)(schema);
|
|
54
|
+
const fjs = (0, fast_json_stringify_1.default)(schema, options);
|
|
54
55
|
return (_req, res, next) => {
|
|
55
56
|
/**
|
|
56
57
|
* Send JSON response.
|
|
@@ -71,4 +72,4 @@ const fastJsonSchema = (schema) => {
|
|
|
71
72
|
};
|
|
72
73
|
};
|
|
73
74
|
exports.fastJsonSchema = fastJsonSchema;
|
|
74
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
75
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9saWIvbWlkZGxld2FyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDQSw4RUFBZ0U7QUFJaEU7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBeUNHO0FBQ0ksTUFBTSxjQUFjLEdBQUcsQ0FBQyxNQUFjLEVBQUUsT0FBaUIsRUFBRSxFQUFFO0lBQ2xFLElBQUksQ0FBQyxNQUFNLEVBQUU7UUFDWCxNQUFNLElBQUksU0FBUyxDQUFDLDZDQUE2QyxDQUFDLENBQUM7S0FDcEU7SUFDRCxNQUFNLEdBQUcsR0FBRyxJQUFBLDZCQUFRLEVBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxDQUFDO0lBQ3RDLE9BQU8sQ0FBQyxJQUFhLEVBQUUsR0FBYSxFQUFFLElBQWtCLEVBQUUsRUFBRTtRQUMxRDs7Ozs7Ozs7V0FRRztRQUNILEdBQUcsQ0FBQyxRQUFRLEdBQUcsQ0FBQyxJQUFTLEVBQVksRUFBRTtZQUNyQyxJQUFJLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxjQUFjLENBQUMsRUFBRTtnQkFDbEMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEVBQUUsa0JBQWtCLENBQUMsQ0FBQzthQUNuRDtZQUNELE9BQU8sR0FBRyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztRQUM3QixDQUFDLENBQUM7UUFDRixJQUFJLEVBQUUsQ0FBQztJQUNULENBQUMsQ0FBQztBQUNKLENBQUMsQ0FBQztBQXZCVyxRQUFBLGNBQWMsa0JBdUJ6QiJ9
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { Schema } from 'fast-json-stringify';
|
|
3
|
-
export type { Schema } from 'fast-json-stringify';
|
|
2
|
+
import { Options, Schema } from 'fast-json-stringify';
|
|
3
|
+
export type { Schema, Options } from 'fast-json-stringify';
|
|
4
4
|
/**
|
|
5
5
|
* Set the schema
|
|
6
|
-
* @param {Schema} schema
|
|
6
|
+
* @param {Schema} schema The schema used to stringify values
|
|
7
|
+
* @param {Options} options The options to use (optional)
|
|
7
8
|
*
|
|
8
9
|
* Examples:
|
|
9
10
|
* ```ts
|
|
@@ -42,4 +43,4 @@ export type { Schema } from 'fast-json-stringify';
|
|
|
42
43
|
* });
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
|
-
export declare const fastJsonSchema: (schema: Schema) => (_req: Request, res: Response, next: NextFunction) => void;
|
|
46
|
+
export declare const fastJsonSchema: (schema: Schema, options?: Options) => (_req: Request, res: Response, next: NextFunction) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fastJson from 'fast-json-stringify';
|
|
2
2
|
/**
|
|
3
3
|
* Set the schema
|
|
4
|
-
* @param {Schema} schema
|
|
4
|
+
* @param {Schema} schema The schema used to stringify values
|
|
5
|
+
* @param {Options} options The options to use (optional)
|
|
5
6
|
*
|
|
6
7
|
* Examples:
|
|
7
8
|
* ```ts
|
|
@@ -40,11 +41,11 @@ import fastJson from 'fast-json-stringify';
|
|
|
40
41
|
* });
|
|
41
42
|
* ```
|
|
42
43
|
*/
|
|
43
|
-
export const fastJsonSchema = (schema) => {
|
|
44
|
+
export const fastJsonSchema = (schema, options) => {
|
|
44
45
|
if (!schema) {
|
|
45
46
|
throw new TypeError(`express-fast-json-stringify: invalid schema`);
|
|
46
47
|
}
|
|
47
|
-
const fjs = fastJson(schema);
|
|
48
|
+
const fjs = fastJson(schema, options);
|
|
48
49
|
return (_req, res, next) => {
|
|
49
50
|
/**
|
|
50
51
|
* Send JSON response.
|
|
@@ -64,4 +65,4 @@ export const fastJsonSchema = (schema) => {
|
|
|
64
65
|
next();
|
|
65
66
|
};
|
|
66
67
|
};
|
|
67
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9saWIvbWlkZGxld2FyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLFFBQTZCLE1BQU0scUJBQXFCLENBQUM7QUFJaEU7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBeUNHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sY0FBYyxHQUFHLENBQUMsTUFBYyxFQUFFLE9BQWlCLEVBQUUsRUFBRTtJQUNsRSxJQUFJLENBQUMsTUFBTSxFQUFFO1FBQ1gsTUFBTSxJQUFJLFNBQVMsQ0FBQyw2Q0FBNkMsQ0FBQyxDQUFDO0tBQ3BFO0lBQ0QsTUFBTSxHQUFHLEdBQUcsUUFBUSxDQUFDLE1BQU0sRUFBRSxPQUFPLENBQUMsQ0FBQztJQUN0QyxPQUFPLENBQUMsSUFBYSxFQUFFLEdBQWEsRUFBRSxJQUFrQixFQUFFLEVBQUU7UUFDMUQ7Ozs7Ozs7O1dBUUc7UUFDSCxHQUFHLENBQUMsUUFBUSxHQUFHLENBQUMsSUFBUyxFQUFZLEVBQUU7WUFDckMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsY0FBYyxDQUFDLEVBQUU7Z0JBQ2xDLEdBQUcsQ0FBQyxTQUFTLENBQUMsY0FBYyxFQUFFLGtCQUFrQixDQUFDLENBQUM7YUFDbkQ7WUFDRCxPQUFPLEdBQUcsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7UUFDN0IsQ0FBQyxDQUFDO1FBQ0YsSUFBSSxFQUFFLENBQUM7SUFDVCxDQUFDLENBQUM7QUFDSixDQUFDLENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-fast-json-stringify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "With express-fast-json-stringify, you can leverage fast-json-stringify in your Express application",
|
|
5
5
|
"main": "build/main/index.js",
|
|
6
6
|
"typings": "build/main/index.d.ts",
|