@pluv/platform-node 0.2.0 → 0.3.0

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/platform-node@0.2.0 build /home/runner/work/pluv/pluv/packages/platform-node
2
+ > @pluv/platform-node@0.3.0 build /home/runner/work/pluv/pluv/packages/platform-node
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,10 +8,10 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 6.15 KB
12
- ESM ⚡️ Build success in 84ms
13
- CJS dist/index.js 7.97 KB
14
- CJS ⚡️ Build success in 85ms
11
+ CJS dist/index.js 7.98 KB
12
+ CJS ⚡️ Build success in 69ms
13
+ ESM dist/index.mjs 6.16 KB
14
+ ESM ⚡️ Build success in 85ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5893ms
17
- DTS dist/index.d.ts 2.72 KB
16
+ DTS ⚡️ Build success in 7185ms
17
+ DTS dist/index.d.ts 2.77 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pluv/platform-node
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ae4e1f1: added platform-specific contexts to expose env in cloudflare and req in node.js
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ae4e1f1]
12
+ - @pluv/io@0.5.0
13
+
14
+ ## 0.2.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [8917309]
19
+ - @pluv/io@0.4.2
20
+
3
21
  ## 0.2.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbstractWebSocket, AbstractEventMap, AbstractListener, AbstractWebSocketConfig, AbstractPersistance, AbstractPubSub, AbstractPlatform, ConvertWebSocketConfig, PluvIO } from '@pluv/io';
2
2
  import { MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize, InferIOAuthorizeRequired } from '@pluv/types';
3
- import Http from 'http';
3
+ import Http, { IncomingMessage } from 'http';
4
4
  import WS, { WebSocket } from 'ws';
5
5
  export { WebSocket } from 'ws';
6
6
 
@@ -23,7 +23,9 @@ type NodePlatformOptions = {
23
23
  persistance: AbstractPersistance;
24
24
  pubSub: AbstractPubSub;
25
25
  };
26
- declare class NodePlatform extends AbstractPlatform<WebSocket> {
26
+ declare class NodePlatform extends AbstractPlatform<WebSocket, {
27
+ req: IncomingMessage;
28
+ }> {
27
29
  constructor(options?: NodePlatformOptions);
28
30
  convertWebSocket(webSocket: WebSocket, config: ConvertWebSocketConfig): NodeWebSocket;
29
31
  parseData(data: string | ArrayBuffer): Record<string, any>;
package/dist/index.js CHANGED
@@ -98,8 +98,8 @@ var createPluvHandler = (config) => {
98
98
  const token = ((_a = parsed.query) == null ? void 0 : _a.token) || void 0;
99
99
  if (Array.isArray(token))
100
100
  return onError.invalidToken();
101
- const room = io.getRoom(roomId);
102
- yield room.register(ws, { token });
101
+ const room = io.getRoom(roomId, { req });
102
+ yield room.register(ws, { req, token });
103
103
  return { matched: true };
104
104
  });
105
105
  const createWsServer = () => {
package/dist/index.mjs CHANGED
@@ -62,8 +62,8 @@ var createPluvHandler = (config) => {
62
62
  const token = ((_a = parsed.query) == null ? void 0 : _a.token) || void 0;
63
63
  if (Array.isArray(token))
64
64
  return onError.invalidToken();
65
- const room = io.getRoom(roomId);
66
- yield room.register(ws, { token });
65
+ const room = io.getRoom(roomId, { req });
66
+ yield room.register(ws, { req, token });
67
67
  return { matched: true };
68
68
  });
69
69
  const createWsServer = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-node",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "@pluv/io adapter for node.js",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,10 +17,10 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@types/node": "^20.1.4",
20
+ "@types/node": "^20.2.1",
21
21
  "@types/ws": "^8.5.4",
22
22
  "path-to-regexp": "^6.2.1",
23
- "@pluv/io": "^0.4.1",
23
+ "@pluv/io": "^0.5.0",
24
24
  "@pluv/types": "^0.2.0"
25
25
  },
26
26
  "devDependencies": {
@@ -4,6 +4,7 @@ import crypto from "crypto";
4
4
  import { TextDecoder } from "util";
5
5
  import type { WebSocket } from "ws";
6
6
  import { NodeWebSocket } from "./NodeWebSocket";
7
+ import { IncomingMessage, ServerResponse } from "http";
7
8
 
8
9
  export type NodePlatformOptions =
9
10
  | { persistance?: undefined; pubSub?: undefined }
@@ -12,7 +13,10 @@ export type NodePlatformOptions =
12
13
  pubSub: AbstractPubSub;
13
14
  };
14
15
 
15
- export class NodePlatform extends AbstractPlatform<WebSocket> {
16
+ export class NodePlatform extends AbstractPlatform<
17
+ WebSocket,
18
+ { req: IncomingMessage }
19
+ > {
16
20
  constructor(options: NodePlatformOptions = {}) {
17
21
  const { persistance, pubSub } = options;
18
22
 
@@ -108,9 +108,9 @@ export const createPluvHandler = <
108
108
 
109
109
  if (Array.isArray(token)) return onError.invalidToken();
110
110
 
111
- const room = io.getRoom(roomId);
111
+ const room = io.getRoom(roomId, { req });
112
112
 
113
- await room.register(ws, { token });
113
+ await room.register(ws, { req, token });
114
114
 
115
115
  return { matched: true };
116
116
  };