ts-game-decorators 1.0.7 → 1.0.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.
|
@@ -16,21 +16,21 @@ function RouterController(basePath = '') {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function Get(path) {
|
|
19
|
-
return (target, propertyKey) => {
|
|
19
|
+
return (target, propertyKey, descriptor) => {
|
|
20
20
|
const routes = Reflect.getMetadata(ROUTES_META, target.constructor) || [];
|
|
21
21
|
routes.push({ method: 'get', path, handler: propertyKey });
|
|
22
22
|
Reflect.defineMetadata(ROUTES_META, routes, target.constructor);
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function Post(path) {
|
|
26
|
-
return (target, propertyKey) => {
|
|
26
|
+
return (target, propertyKey, descriptor) => {
|
|
27
27
|
const routes = Reflect.getMetadata(ROUTES_META, target.constructor) || [];
|
|
28
28
|
routes.push({ method: 'post', path, handler: propertyKey });
|
|
29
29
|
Reflect.defineMetadata(ROUTES_META, routes, target.constructor);
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
function Authen() {
|
|
33
|
-
return (target, propertyKey) => {
|
|
33
|
+
return (target, propertyKey, descriptor) => {
|
|
34
34
|
if (propertyKey) {
|
|
35
35
|
// Method
|
|
36
36
|
const authenMethods = Reflect.getMetadata(AUTHEN_META, target.constructor) || [];
|
|
@@ -12,7 +12,7 @@ const SOCKET_EVENTS_META = Symbol('socket_events');
|
|
|
12
12
|
const SOCKET_AUTHEN_META = Symbol('socket_authen');
|
|
13
13
|
// Decorator cho xác thực socket
|
|
14
14
|
function AuthenSocket() {
|
|
15
|
-
return (target, propertyKey) => {
|
|
15
|
+
return (target, propertyKey, descriptor) => {
|
|
16
16
|
if (propertyKey) {
|
|
17
17
|
// Method
|
|
18
18
|
const authenMethods = Reflect.getMetadata(SOCKET_AUTHEN_META, target.constructor) || [];
|
|
@@ -31,21 +31,21 @@ function SocketService() {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
function OnEvent(event) {
|
|
34
|
-
return (target, propertyKey) => {
|
|
34
|
+
return (target, propertyKey, descriptor) => {
|
|
35
35
|
const events = Reflect.getMetadata(SOCKET_EVENTS_META, target.constructor) || [];
|
|
36
36
|
events.push({ type: 'event', event, handler: propertyKey });
|
|
37
37
|
Reflect.defineMetadata(SOCKET_EVENTS_META, events, target.constructor);
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
function OnDisconnect() {
|
|
41
|
-
return (target, propertyKey) => {
|
|
41
|
+
return (target, propertyKey, descriptor) => {
|
|
42
42
|
const events = Reflect.getMetadata(SOCKET_EVENTS_META, target.constructor) || [];
|
|
43
43
|
events.push({ type: 'disconnect', handler: propertyKey });
|
|
44
44
|
Reflect.defineMetadata(SOCKET_EVENTS_META, events, target.constructor);
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
function OnError() {
|
|
48
|
-
return (target, propertyKey) => {
|
|
48
|
+
return (target, propertyKey, descriptor) => {
|
|
49
49
|
const events = Reflect.getMetadata(SOCKET_EVENTS_META, target.constructor) || [];
|
|
50
50
|
events.push({ type: 'error', handler: propertyKey });
|
|
51
51
|
Reflect.defineMetadata(SOCKET_EVENTS_META, events, target.constructor);
|
package/package.json
CHANGED