Last active
April 26, 2019 16:34
-
-
Save rzvdaniel/8e31835330c1ccb1872dbd4f96b0edcd to your computer and use it in GitHub Desktop.
[Medium] Moleculer Mixins - A short introduction - greeter.service.js with Mixins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const WorldService = require("./world.service"); | |
module.exports = { | |
name: "greeter", | |
mixins: [WorldService], | |
/** | |
* Actions | |
*/ | |
actions: { | |
/** | |
* Say a 'Hello' | |
* | |
* @returns | |
*/ | |
hello() { | |
return "Hello Moleculer"; | |
}, | |
/** | |
* Welcome a username | |
* | |
* @param {String} name - User name | |
*/ | |
welcome: { | |
params: { | |
name: "string" | |
}, | |
handler(ctx) { | |
return `Welcome, ${ctx.params.name}`; | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment