@twin.org/api-server-fastify 0.9.1-next.6 → 0.9.1-next.8

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.
@@ -7,14 +7,9 @@ import { Server } from "socket.io";
7
7
  const fastifySocketIO = fp(async (fastify, opts) => {
8
8
  const ioServer = new Server(fastify.server, opts);
9
9
  fastify.decorate("io", ioServer);
10
- fastify.addHook("preClose", done => {
10
+ fastify.addHook("preClose", async () => {
11
11
  ioServer.disconnectSockets();
12
- ioServer
13
- .close()
14
- // eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise
15
- .then(() => done())
16
- // eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise
17
- .catch(() => done());
12
+ await ioServer.close();
18
13
  });
19
14
  }, { fastify: ">=5.x.x", name: "socket.io" });
20
15
  export default fastifySocketIO;
@@ -1 +1 @@
1
- {"version":3,"file":"fastifySocketIo.js","sourceRoot":"","sources":["../../src/fastifySocketIo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAsB,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,MAAM,eAAe,GAA+C,EAAE,CACrE,KAAK,EAAE,OAAwB,EAAE,IAA4B,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE;QAClC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC7B,QAAQ;aACN,KAAK,EAAE;YACR,wFAAwF;aACvF,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;YACnB,wFAAwF;aACvF,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACJ,CAAC,EACD,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CACzC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fp from \"fastify-plugin\";\nimport { Server, type ServerOptions } from \"socket.io\";\n\n/**\n * Fastify plugin that attaches a Socket.IO server to the Fastify HTTP server.\n * Cloned from fastify-socket.io to support recent Fastify versions.\n */\nconst fastifySocketIO: FastifyPluginAsync<Partial<ServerOptions>> = fp(\n\tasync (fastify: FastifyInstance, opts: Partial<ServerOptions>) => {\n\t\tconst ioServer = new Server(fastify.server, opts);\n\n\t\tfastify.decorate(\"io\", ioServer);\n\t\tfastify.addHook(\"preClose\", done => {\n\t\t\tioServer.disconnectSockets();\n\t\t\tioServer\n\t\t\t\t.close()\n\t\t\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise\n\t\t\t\t.then(() => done())\n\t\t\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/no-callback-in-promise\n\t\t\t\t.catch(() => done());\n\t\t});\n\t},\n\t{ fastify: \">=5.x.x\", name: \"socket.io\" }\n);\n\nexport default fastifySocketIO;\n"]}
1
+ {"version":3,"file":"fastifySocketIo.js","sourceRoot":"","sources":["../../src/fastifySocketIo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAsB,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,MAAM,eAAe,GAA+C,EAAE,CACrE,KAAK,EAAE,OAAwB,EAAE,IAA4B,EAAE,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;QACtC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAE7B,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACJ,CAAC,EACD,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CACzC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { FastifyInstance, FastifyPluginAsync } from \"fastify\";\nimport fp from \"fastify-plugin\";\nimport { Server, type ServerOptions } from \"socket.io\";\n\n/**\n * Fastify plugin that attaches a Socket.IO server to the Fastify HTTP server.\n * Cloned from fastify-socket.io to support recent Fastify versions.\n */\nconst fastifySocketIO: FastifyPluginAsync<Partial<ServerOptions>> = fp(\n\tasync (fastify: FastifyInstance, opts: Partial<ServerOptions>) => {\n\t\tconst ioServer = new Server(fastify.server, opts);\n\n\t\tfastify.decorate(\"io\", ioServer);\n\t\tfastify.addHook(\"preClose\", async () => {\n\t\t\tioServer.disconnectSockets();\n\n\t\t\tawait ioServer.close();\n\t\t});\n\t},\n\t{ fastify: \">=5.x.x\", name: \"socket.io\" }\n);\n\nexport default fastifySocketIO;\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.1-next.8](https://github.com/iotaledger/twin-api/compare/api-server-fastify-v0.9.1-next.7...api-server-fastify-v0.9.1-next.8) (2026-07-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * async socket closedown ([e35f628](https://github.com/iotaledger/twin-api/commit/e35f62874c75f6c8dc175bd9713db9c2d062f697))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-core bumped from 0.9.1-next.7 to 0.9.1-next.8
16
+ * @twin.org/api-models bumped from 0.9.1-next.7 to 0.9.1-next.8
17
+ * @twin.org/api-processors bumped from 0.9.1-next.7 to 0.9.1-next.8
18
+
19
+ ## [0.9.1-next.7](https://github.com/iotaledger/twin-api/compare/api-server-fastify-v0.9.1-next.6...api-server-fastify-v0.9.1-next.7) (2026-07-02)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * socket.io cleanup ([554324c](https://github.com/iotaledger/twin-api/commit/554324c0349a79b6722e32f042fc0a77572b4c9b))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/api-core bumped from 0.9.1-next.6 to 0.9.1-next.7
32
+ * @twin.org/api-models bumped from 0.9.1-next.6 to 0.9.1-next.7
33
+ * @twin.org/api-processors bumped from 0.9.1-next.6 to 0.9.1-next.7
34
+
3
35
  ## [0.9.1-next.6](https://github.com/iotaledger/twin-api/compare/api-server-fastify-v0.9.1-next.5...api-server-fastify-v0.9.1-next.6) (2026-06-30)
4
36
 
5
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-server-fastify",
3
- "version": "0.9.1-next.6",
3
+ "version": "0.9.1-next.8",
4
4
  "description": "Fastify web server integration for exposing API routes with consistent runtime behaviour.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,9 +16,9 @@
16
16
  "dependencies": {
17
17
  "@fastify/compress": "9.0.0",
18
18
  "@fastify/cors": "11.2.0",
19
- "@twin.org/api-core": "0.9.1-next.6",
20
- "@twin.org/api-models": "0.9.1-next.6",
21
- "@twin.org/api-processors": "0.9.1-next.6",
19
+ "@twin.org/api-core": "0.9.1-next.8",
20
+ "@twin.org/api-models": "0.9.1-next.8",
21
+ "@twin.org/api-processors": "0.9.1-next.8",
22
22
  "@twin.org/context": "next",
23
23
  "@twin.org/core": "next",
24
24
  "@twin.org/logging-models": "next",