@bmstravel/nvp-plop-templates 0.2.63 → 0.2.64
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
import moleculer, { Errors } from "moleculer";
|
4
|
-
import { Service, Action, Method, ActionService, MethodService, HookService, EventService } from "@bmstravel/nvp-decorator";
|
4
|
+
import { Service, Action, Method, Event, ActionService, MethodService, HookService, EventService } from "@bmstravel/nvp-decorator";
|
5
5
|
import { VERSION, Config, VISIBILITY } from "@src/common";
|
6
6
|
|
7
7
|
const serviceName = "{{camelCase serviceName}}"
|
@@ -97,6 +97,44 @@ export default class {{pascalCase serviceName}}Service extends moleculer.Service
|
|
97
97
|
}
|
98
98
|
{{/if}}
|
99
99
|
|
100
|
+
/**
|
101
|
+
* Event called to one of instance of service when started
|
102
|
+
* is being call by broker.emit(...)
|
103
|
+
* @param _payload
|
104
|
+
* @param _sender
|
105
|
+
* @param _name
|
106
|
+
* @param _ctx
|
107
|
+
* @returns void
|
108
|
+
*/
|
109
|
+
@Event({})
|
110
|
+
async "$service.bootstap"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
111
|
+
/* const $this: IBaseService = this as any
|
112
|
+
try {
|
113
|
+
// implements here
|
114
|
+
} catch (err) {
|
115
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
116
|
+
} */
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Event called to each instance of service when started
|
121
|
+
* is being call by broker.broadcastLocal(...)
|
122
|
+
* @param _payload
|
123
|
+
* @param _sender
|
124
|
+
* @param _name
|
125
|
+
* @param _ctx
|
126
|
+
* @returns void
|
127
|
+
*/
|
128
|
+
@Event({})
|
129
|
+
async "$broker.started"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
130
|
+
/* const $this: IBaseService = this as any
|
131
|
+
try {
|
132
|
+
// implements here
|
133
|
+
} catch (err) {
|
134
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
135
|
+
} */
|
136
|
+
}
|
137
|
+
|
100
138
|
public created() {
|
101
139
|
// Fired when created
|
102
140
|
}
|
@@ -9,6 +9,7 @@ import {
|
|
9
9
|
{{#if hasSeedDb}}
|
10
10
|
Method,
|
11
11
|
{{/if}}
|
12
|
+
Event,
|
12
13
|
Service,
|
13
14
|
ActionService,
|
14
15
|
MethodService,
|
@@ -168,6 +169,44 @@ export default class {{pascalCase serviceName}}Service extends MoleculerDBServic
|
|
168
169
|
}
|
169
170
|
{{/if}}
|
170
171
|
|
172
|
+
/**
|
173
|
+
* Event called to one of instance of service when started
|
174
|
+
* is being call by broker.emit(...)
|
175
|
+
* @param _payload
|
176
|
+
* @param _sender
|
177
|
+
* @param _name
|
178
|
+
* @param _ctx
|
179
|
+
* @returns void
|
180
|
+
*/
|
181
|
+
@Event({})
|
182
|
+
async "$service.bootstap"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
183
|
+
/* const $this: IBaseService = this as any
|
184
|
+
try {
|
185
|
+
// implements here
|
186
|
+
} catch (err) {
|
187
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
188
|
+
} */
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Event called to each instance of service when started
|
193
|
+
* is being call by broker.broadcastLocal(...)
|
194
|
+
* @param _payload
|
195
|
+
* @param _sender
|
196
|
+
* @param _name
|
197
|
+
* @param _ctx
|
198
|
+
* @returns void
|
199
|
+
*/
|
200
|
+
@Event({})
|
201
|
+
async "$broker.started"(_payload: Record<string, any>, _sender: string, _name: string, _ctx: moleculer.Context) {
|
202
|
+
/* const $this: IBaseService = this as any
|
203
|
+
try {
|
204
|
+
// implements here
|
205
|
+
} catch (err) {
|
206
|
+
$this.logger.error(`🔥 ~ $service.bootstap:`, err)
|
207
|
+
} */
|
208
|
+
}
|
209
|
+
|
171
210
|
public created() {
|
172
211
|
// Fired when created
|
173
212
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bmstravel/nvp-plop-templates",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.64",
|
4
4
|
"description": "🏆 Using for plop templates",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "lib/index.js",
|
@@ -15,5 +15,5 @@
|
|
15
15
|
"phongnv86 <phongnguyenvan86@gmail.com>",
|
16
16
|
"phongnv86 <phongnv@media-one.vn>"
|
17
17
|
],
|
18
|
-
"gitHead": "
|
18
|
+
"gitHead": "0cf09176d0c1738657b2615a5cdf0e0f7b118df8"
|
19
19
|
}
|