Skip to content

Commit 050dada

Browse files
committed
update channel types
1 parent 5b92c0e commit 050dada

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"graphql-type-json": "^0.3.2",
8282
{{/apiGQL}}
8383
{{#needChannels}}
84-
"@moleculer/channels": "^0.2.0",
84+
"@moleculer/channels": "github:moleculerjs/moleculer-channels#next",
8585
{{/needChannels}}
8686
{{#needWorkflows}}
8787
"@moleculer/workflows": "^0.1.2",

template/services/inventory.service.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import type { Context, ServiceSchema } from "moleculer";
1+
import type { Context, ServiceSchema, ServiceSettingSchema } from "moleculer";
22

33
interface ReserveParams {
44
productId: string;
55
quantity: number;
66
}
7+
interface LocalMethods {
8+
uppercase(text: string): string;
9+
}
710

8-
const InventoryService: ServiceSchema = {
11+
const InventoryService: ServiceSchema<ServiceSettingSchema, LocalMethods> = {
912
name: "inventory",
1013

1114
/**
@@ -25,6 +28,8 @@ const InventoryService: ServiceSchema = {
2528
`Reserve ${ctx.params.quantity} pieces of the ${ctx.params.productId} product in the inventory.`
2629
);
2730

31+
this.uppercase("Hello");
32+
2833
await ctx.emit("inventory.reserved", {
2934
productId: ctx.params.productId,
3035
quantity: ctx.params.quantity
@@ -62,6 +67,12 @@ const InventoryService: ServiceSchema = {
6267
return true;
6368
}
6469
}
70+
},
71+
72+
methods: {
73+
uppercase(text: string): string {
74+
return text.toUpperCase();
75+
}
6576
}
6677
};
6778

0 commit comments

Comments
 (0)