@bmstravel/nvp-plop-templates 0.0.5 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,13 @@
|
|
1
|
-
import { I{{pascalCase serviceName}}Service } from "@src/types";
|
1
|
+
import { I{{pascalCase serviceName}}Service, IBaseAdapter } from "@src/types";
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
export type {{pascalCase methodName}}Params = {
|
4
|
+
|
5
|
+
}
|
6
|
+
|
7
|
+
async function {{camelCase methodName}}(payload: {{pascalCase methodName}}Params) {
|
8
|
+
const $this: I{{pascalCase serviceName}}Service = this;
|
9
|
+
const $adapter: IBaseAdapter = $this.adapter
|
10
|
+
const $cacher = $this.broker.cacher
|
5
11
|
return new $this.Promise((resolve, _reject) => {
|
6
12
|
$this.logger.info("{{pascalCase methodName}} :", payload);
|
7
13
|
resolve('ok');
|
@@ -43,7 +43,7 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
|
|
43
43
|
type: DataTypes.STRING,
|
44
44
|
defaultValue: function () {
|
45
45
|
return generateUuid({ _prefix: '{{truncate (camelCase name) 4}}', length: 19, replaceDash: true })
|
46
|
-
}
|
46
|
+
},
|
47
47
|
{{/eq}}
|
48
48
|
primaryKey: true,
|
49
49
|
},
|
@@ -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 })
|
@@ -1,20 +1,17 @@
|
|
1
1
|
import { Options } from '@bmstravel/nvp-decorator';
|
2
2
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3
3
|
import { ServiceActionsSchema } from "moleculer";
|
4
|
-
import { DbServiceSettings } from 'moleculer-db';
|
5
4
|
import {
|
6
5
|
IBaseService,
|
7
6
|
IBaseServiceActions,
|
8
7
|
IBaseServiceMethods,
|
9
8
|
} from "./db.service-interface";
|
10
9
|
|
11
|
-
export interface {{pascalCase serviceName}}ServiceSettingsOptions
|
10
|
+
export interface {{pascalCase serviceName}}ServiceSettingsOptions {
|
12
11
|
/**
|
13
12
|
* if implements will replace /v1/{{camelCase serviceName}}/* to /{{camelCase serviceName}}/*
|
14
13
|
*/
|
15
14
|
rest?: "/{{camelCase serviceName}}";
|
16
|
-
fields?: (keyof Required<any>)[];
|
17
|
-
populates?: any;
|
18
15
|
[x: string]: any;
|
19
16
|
}
|
20
17
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { Options } from '@bmstravel/nvp-decorator';
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3
|
+
import { ServiceActionsSchema } from "moleculer";
|
4
|
+
import { DbServiceSettings } from 'moleculer-db';
|
5
|
+
import {
|
6
|
+
IBaseService,
|
7
|
+
IBaseServiceActions,
|
8
|
+
IBaseServiceMethods,
|
9
|
+
} from "./db.service-interface";
|
10
|
+
|
11
|
+
export interface {{pascalCase serviceName}}ServiceSettingsOptions extends Omit<DbServiceSettings, "fields"> {
|
12
|
+
/**
|
13
|
+
* if implements will replace /v1/{{camelCase serviceName}}/* to /{{camelCase serviceName}}/*
|
14
|
+
*/
|
15
|
+
rest?: "/{{camelCase serviceName}}";
|
16
|
+
fields?: (keyof Required<any>)[];
|
17
|
+
populates?: any;
|
18
|
+
[x: string]: any;
|
19
|
+
}
|
20
|
+
|
21
|
+
export interface {{pascalCase serviceName}}ServiceOptions extends Options {
|
22
|
+
name: '{{camelCase serviceName}}';
|
23
|
+
settings: {{pascalCase serviceName}}ServiceSettingsOptions;
|
24
|
+
}
|
25
|
+
|
26
|
+
export enum {{pascalCase serviceName}}Action {
|
27
|
+
// DELETED = 'user.deleted'
|
28
|
+
}
|
29
|
+
|
30
|
+
export enum {{pascalCase serviceName}}Event {
|
31
|
+
// DELETED = 'user.deleted'
|
32
|
+
}
|
33
|
+
|
34
|
+
export enum {{pascalCase serviceName}}RouterAlias {
|
35
|
+
// {{constantCase serviceName}} = "v1.{{pascalCase serviceName}}",
|
36
|
+
}
|
37
|
+
|
38
|
+
export interface I{{pascalCase serviceName}}Actions extends IBaseServiceActions {
|
39
|
+
/* MOL_ACTION */
|
40
|
+
{{#if hasHelloAction}}
|
41
|
+
hello: ServiceActionsSchema;
|
42
|
+
{{/if}}
|
43
|
+
}
|
44
|
+
|
45
|
+
export interface I{{pascalCase serviceName}}Methods extends IBaseServiceMethods {
|
46
|
+
/* MOL_METHOD */
|
47
|
+
}
|
48
|
+
|
49
|
+
export interface I{{pascalCase serviceName}}Service extends IBaseService<I{{pascalCase serviceName}}Actions, I{{pascalCase serviceName}}Methods>, I{{pascalCase serviceName}}Methods {
|
50
|
+
actions: I{{pascalCase serviceName}}Actions;
|
51
|
+
methods: I{{pascalCase serviceName}}Methods;
|
52
|
+
}
|
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.8",
|
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": "880febbd450ae91a020097f58140922fea1beb1e"
|
19
19
|
}
|