hapi-terminator 0.3.0 → 0.3.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.
@@ -73,21 +73,28 @@ function validateRoute(request, h, options) {
73
73
  }
74
74
  if (limit === true) {
75
75
  const result = response(0).takeover();
76
- request.raw.res.once('finish', () => {
77
- request.raw.req.socket.end();
78
- });
76
+ closeSocketsOnFinish(request);
79
77
  return result;
80
78
  }
81
79
  if (contentLength <= limit) {
82
80
  return h.continue;
83
81
  }
84
82
  const result = response(limit).takeover();
85
- request.raw.res.once('finish', () => {
86
- request.raw.req.socket.end();
87
- });
83
+ closeSocketsOnFinish(request);
88
84
  return result;
89
85
  };
90
86
  }
87
+ function closeSocketsOnFinish(request) {
88
+ request.raw.res.once('finish', () => {
89
+ const socket = request.raw.req.socket;
90
+ if (socket.destroy) {
91
+ socket.destroy();
92
+ }
93
+ else {
94
+ socket.end();
95
+ }
96
+ });
97
+ }
91
98
  function getRoutePluginSettings(matchedRoute) {
92
99
  return TerminatorRouteOptionsSchema.safeParse(matchedRoute?.settings.plugins).data;
93
100
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "hapi-terminator",
3
- "main": "dist/index.js",
4
- "typings": "dist/index.d.ts",
3
+ "main": "index.js",
4
+ "typings": "index.d.ts",
5
5
  "type": "module",
6
- "version": "0.3.0",
6
+ "version": "0.3.1",
7
7
  "license": "MIT",
8
8
  "author": {
9
9
  "name": "Kamaal Farah"
@@ -47,6 +47,7 @@
47
47
  "access": "public"
48
48
  },
49
49
  "files": [
50
- "dist"
50
+ "index.js",
51
+ "index.d.ts"
51
52
  ]
52
53
  }
package/dist/package.json DELETED
@@ -1,52 +0,0 @@
1
- {
2
- "name": "hapi-terminator",
3
- "main": "dist/index.js",
4
- "typings": "dist/index.d.ts",
5
- "type": "module",
6
- "version": "0.3.0",
7
- "license": "MIT",
8
- "author": {
9
- "name": "Kamaal Farah"
10
- },
11
- "devDependencies": {
12
- "@eslint/js": "^9.39.2",
13
- "@hapi/hapi": "^21.4.4",
14
- "@kamaalio/prettier-config": "^0.1.2",
15
- "@types/bun": "latest",
16
- "eslint": "^9.39.2",
17
- "globals": "^17.0.0",
18
- "husky": "^9.1.7",
19
- "jiti": "^2.6.1",
20
- "lint-staged": "^16.2.7",
21
- "prettier": "^3.7.4",
22
- "typescript": "^5.9.3",
23
- "typescript-eslint": "^8.52.0"
24
- },
25
- "dependencies": {
26
- "zod": "^4.3.5"
27
- },
28
- "prettier": "@kamaalio/prettier-config",
29
- "lint-staged": {
30
- "**/*.{js,ts,tsx}": [
31
- "eslint --fix"
32
- ],
33
- "**/*": "prettier --write --ignore-unknown"
34
- },
35
- "scripts": {
36
- "compile": "tsc --project tsconfig.build.json",
37
- "format": "prettier --write .",
38
- "format:check": "prettier --check .",
39
- "lint": "eslint .",
40
- "prepare": "bunx husky",
41
- "prepack": "rm -rf dist && bun run compile",
42
- "quality": "bun run format:check && bun run lint && bun run typecheck",
43
- "test": "bun test",
44
- "typecheck": "tsc --noEmit"
45
- },
46
- "publishConfig": {
47
- "access": "public"
48
- },
49
- "files": [
50
- "dist"
51
- ]
52
- }
File without changes