@naturalcycles/bench-lib 2.1.0 → 2.1.1

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.
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expressSyncFunctionFactory = exports.expressFunctionFactory = exports.expressWithMiddlewaresServerFactory = exports.bareExpressServerFactory = exports.bareNodeServerFactory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_http_1 = tslib_1.__importDefault(require("node:http"));
6
- const express_1 = tslib_1.__importDefault(require("express"));
7
- const helmet_1 = tslib_1.__importDefault(require("helmet"));
8
6
  const bareNodeServerFactory = async () => {
9
7
  return node_http_1.default.createServer((req, res) => {
10
8
  res.setHeader('content-type', 'application/json; charset=utf-8');
@@ -13,7 +11,7 @@ const bareNodeServerFactory = async () => {
13
11
  };
14
12
  exports.bareNodeServerFactory = bareNodeServerFactory;
15
13
  const bareExpressServerFactory = async () => {
16
- const app = (0, express_1.default)();
14
+ const app = require('express')();
17
15
  app.disable('etag');
18
16
  app.disable('x-powered-by');
19
17
  app.get('/', (req, res) => res.json({ hello: 'world' }));
@@ -24,16 +22,17 @@ exports.bareExpressServerFactory = bareExpressServerFactory;
24
22
  * Based on: https://github.com/fastify/benchmarks/blob/master/benchmarks/express-with-middlewares.js
25
23
  */
26
24
  const expressWithMiddlewaresServerFactory = async () => {
27
- const app = (0, express_1.default)();
25
+ const app = require('express')();
26
+ const helmet = require('helmet');
28
27
  app.disable('etag');
29
28
  app.disable('x-powered-by');
30
29
  app.use(require('cors')());
31
- app.use(helmet_1.default.dnsPrefetchControl());
32
- app.use(helmet_1.default.frameguard());
33
- app.use(helmet_1.default.hidePoweredBy());
34
- app.use(helmet_1.default.hsts());
35
- app.use(helmet_1.default.ieNoOpen());
36
- app.use(helmet_1.default.xssFilter());
30
+ app.use(helmet.dnsPrefetchControl());
31
+ app.use(helmet.frameguard());
32
+ app.use(helmet.hidePoweredBy());
33
+ app.use(helmet.hsts());
34
+ app.use(helmet.ieNoOpen());
35
+ app.use(helmet.xssFilter());
37
36
  app.get('/', (req, res) => res.json({ hello: 'world' }));
38
37
  return node_http_1.default.createServer(app);
39
38
  };
@@ -43,7 +42,7 @@ exports.expressWithMiddlewaresServerFactory = expressWithMiddlewaresServerFactor
43
42
  */
44
43
  function expressFunctionFactory(fn) {
45
44
  return async () => {
46
- const app = (0, express_1.default)();
45
+ const app = require('express')();
47
46
  app.disable('etag');
48
47
  app.disable('x-powered-by');
49
48
  app.get('/', async (req, res) => res.json(await fn()));
@@ -53,7 +52,7 @@ function expressFunctionFactory(fn) {
53
52
  exports.expressFunctionFactory = expressFunctionFactory;
54
53
  function expressSyncFunctionFactory(fn) {
55
54
  return async () => {
56
- const app = (0, express_1.default)();
55
+ const app = require('express')();
57
56
  app.disable('etag');
58
57
  app.disable('x-powered-by');
59
58
  app.get('/', (req, res) => res.json(fn()));
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  "engines": {
35
35
  "node": ">=18.12.0"
36
36
  },
37
- "version": "2.1.0",
37
+ "version": "2.1.1",
38
38
  "description": "Benchmarking library, based on Benchmark.js and Autocannon",
39
39
  "author": "Natural Cycles Team",
40
40
  "license": "MIT"