@midwayjs/decorator 3.4.0-beta.4 → 3.4.0-beta.7

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.
@@ -2,10 +2,9 @@ import { MiddlewareParamArray } from '../../interface';
2
2
  export interface WSControllerOption {
3
3
  namespace: string;
4
4
  routerOptions: {
5
+ connectionMiddleware?: MiddlewareParamArray;
5
6
  middleware?: MiddlewareParamArray;
6
7
  };
7
8
  }
8
- export declare function WSController(namespace?: string | RegExp, routerOptions?: {
9
- middleware?: MiddlewareParamArray;
10
- }): ClassDecorator;
9
+ export declare function WSController(namespace?: string | RegExp, routerOptions?: WSControllerOption['routerOptions']): ClassDecorator;
11
10
  //# sourceMappingURL=webSocketController.d.ts.map
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WSController = void 0;
4
4
  const common_1 = require("../common");
5
5
  const __1 = require("../../");
6
- function WSController(namespace = '/', routerOptions = { middleware: [] }) {
6
+ function WSController(namespace = '/', routerOptions = {
7
+ middleware: [],
8
+ connectionMiddleware: [],
9
+ }) {
7
10
  return (target) => {
8
11
  (0, __1.saveModule)(__1.WS_CONTROLLER_KEY, target);
9
12
  (0, __1.saveClassMetadata)(__1.WS_CONTROLLER_KEY, {
@@ -1,3 +1,4 @@
1
+ import { MiddlewareParamArray } from '../../';
1
2
  export declare enum WSEventTypeEnum {
2
3
  ON_CONNECTION = "ws:onConnection",
3
4
  ON_DISCONNECTION = "ws:onDisconnection",
@@ -24,10 +25,20 @@ export interface WSEventInfo {
24
25
  * the room name to emit
25
26
  */
26
27
  roomName?: string[];
28
+ /**
29
+ * event options, like middleware
30
+ */
31
+ eventOptions?: {
32
+ middleware?: MiddlewareParamArray;
33
+ };
27
34
  }
28
- export declare function OnWSConnection(): MethodDecorator;
35
+ export declare function OnWSConnection(eventOptions?: {
36
+ middleware?: MiddlewareParamArray;
37
+ }): MethodDecorator;
29
38
  export declare function OnWSDisConnection(): MethodDecorator;
30
- export declare function OnWSMessage(eventName: string): MethodDecorator;
39
+ export declare function OnWSMessage(eventName: string, eventOptions?: {
40
+ middleware?: MiddlewareParamArray;
41
+ }): MethodDecorator;
31
42
  export declare function WSEmit(messageName: string, roomName?: string | string[]): MethodDecorator;
32
43
  export declare function WSBroadCast(messageName?: string, roomName?: string | string[]): MethodDecorator;
33
44
  /**
@@ -11,11 +11,12 @@ var WSEventTypeEnum;
11
11
  WSEventTypeEnum["EMIT"] = "ws:Emit";
12
12
  WSEventTypeEnum["BROADCAST"] = "ws:broadcast";
13
13
  })(WSEventTypeEnum = exports.WSEventTypeEnum || (exports.WSEventTypeEnum = {}));
14
- function OnWSConnection() {
14
+ function OnWSConnection(eventOptions = {}) {
15
15
  return (target, propertyKey, descriptor) => {
16
16
  (0, __1.attachClassMetadata)(__1.WS_EVENT_KEY, {
17
17
  eventType: WSEventTypeEnum.ON_CONNECTION,
18
18
  propertyName: propertyKey,
19
+ eventOptions,
19
20
  descriptor,
20
21
  }, target.constructor);
21
22
  };
@@ -31,12 +32,13 @@ function OnWSDisConnection() {
31
32
  };
32
33
  }
33
34
  exports.OnWSDisConnection = OnWSDisConnection;
34
- function OnWSMessage(eventName) {
35
+ function OnWSMessage(eventName, eventOptions = {}) {
35
36
  return (target, propertyKey, descriptor) => {
36
37
  (0, __1.attachClassMetadata)(__1.WS_EVENT_KEY, {
37
38
  eventType: WSEventTypeEnum.ON_MESSAGE,
38
39
  messageEventName: eventName,
39
40
  propertyName: propertyKey,
41
+ eventOptions,
40
42
  descriptor,
41
43
  }, target.constructor);
42
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/decorator",
3
- "version": "3.4.0-beta.4",
3
+ "version": "3.4.0-beta.7",
4
4
  "description": "definition decorator for midway project",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "3b686101f7802f87d47b8c9d25561339d556e573"
39
+ "gitHead": "4d5cc59a7a33e49beeaf20fcfaf766438649959c"
40
40
  }