@bmstravel/nvp-plop-templates 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
|
|
1
|
-
import { IBaseAction, IBaseAdapter, I{{pascalCase serviceName}}Service,
|
1
|
+
import { IBaseAction, IBaseAdapter, I{{pascalCase serviceName}}Service, UserAuthMeta } from "@src/types";
|
2
2
|
import { Context } from "moleculer";
|
3
3
|
import { VISIBILITY, ERR_SYSTEM } from "@src/common";
|
4
4
|
import { MoleculerRegularError } from "@src/errors";
|
@@ -89,7 +89,7 @@ const {{pascalCase actionName}}Action: IBaseAction = {
|
|
89
89
|
{{/eq}}
|
90
90
|
params: {
|
91
91
|
},
|
92
|
-
async handler(ctx: Context<{{pascalCase actionName}}Params,
|
92
|
+
async handler(ctx: Context<{{pascalCase actionName}}Params, UserAuthMeta>) {
|
93
93
|
const $this: I{{pascalCase serviceName}}Service = this;
|
94
94
|
const $adapter: IBaseAdapter = $this.adapter;
|
95
95
|
const i18next = ctx.broker.i18next
|
@@ -8,7 +8,12 @@ import { STATUS } from "@src/common"
|
|
8
8
|
|
9
9
|
export interface I{{pascalCase name}} {
|
10
10
|
{{#if hasId}}
|
11
|
+
{{#eq dataTypeId "integer"}}
|
11
12
|
id: number;
|
13
|
+
{{/eq}}
|
14
|
+
{{#eq dataTypeId "uuid"}}
|
15
|
+
id: string;
|
16
|
+
{{/eq}}
|
12
17
|
{{/if}}
|
13
18
|
// BEGIN addition here
|
14
19
|
|
@@ -36,7 +41,9 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
|
|
36
41
|
{{/eq}}
|
37
42
|
{{#eq dataTypeId "uuid"}}
|
38
43
|
type: DataTypes.STRING,
|
39
|
-
defaultValue:
|
44
|
+
defaultValue: function () {
|
45
|
+
return generateUuid({ _prefix: '{{truncate (camelCase name) 4}}', length: 19, replaceDash: true })
|
46
|
+
},
|
40
47
|
{{/eq}}
|
41
48
|
primaryKey: true,
|
42
49
|
},
|
@@ -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-
|
4
|
+
import { Service, Action, Method, 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}}"
|
@@ -32,6 +32,7 @@ const serviceName = '{{camelCase serviceName}}'
|
|
32
32
|
new DbServiceMixin("{{camelCase model}}", {
|
33
33
|
adapter: {
|
34
34
|
model: {{camelCase model}}Model,
|
35
|
+
logging: false,
|
35
36
|
// dbUri: Config.SEQUELIZE_URI,
|
36
37
|
// dbType: "mysql",
|
37
38
|
// dbHost: Config.DB_HOST,
|
@@ -67,19 +68,7 @@ const serviceName = '{{camelCase serviceName}}'
|
|
67
68
|
name: "string|min:3",
|
68
69
|
price: "number|positive",
|
69
70
|
}, */
|
70
|
-
}
|
71
|
-
hooks: {
|
72
|
-
before: {
|
73
|
-
/**
|
74
|
-
* Register a before hook for the `create` action.
|
75
|
-
*
|
76
|
-
* @param {Context} ctx
|
77
|
-
*/
|
78
|
-
create: (_ctx: moleculer.Context<any, any>) => {
|
79
|
-
// ctx.params.quantity = 0;
|
80
|
-
},
|
81
|
-
},
|
82
|
-
},
|
71
|
+
}
|
83
72
|
})
|
84
73
|
@ActionService({ serviceName })
|
85
74
|
@MethodService({ serviceName })
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bmstravel/nvp-plop-templates",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
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": "c5c074227eee5a84dfd178ad31324a4ba452f0dd"
|
19
19
|
}
|