Skip to content

Instantly share code, notes, and snippets.

@goldytech
Created October 20, 2020 15:11
Show Gist options
  • Save goldytech/1ca35374f497d738621ca17e7e5e7fc5 to your computer and use it in GitHub Desktop.
Save goldytech/1ca35374f497d738621ca17e7e5e7fc5 to your computer and use it in GitHub Desktop.
"use strict";
const db = require("../database");
/**
* @typedef {import('moleculer').Context} Context Moleculer's Context
*/
module.exports = {
name: "greeter",
/**
* Settings
*/
settings: {
},
/**
* Dependencies
*/
dependencies: [],
/**
* Actions
*/
actions: {
/**
* Say a 'Hello' action.
*
* @returns
*/
hello: {
rest: {
method: "GET",
path: "/hello"
},
async handler() {
return "Hello Moleculer";
}
},
/**
* Welcome, a username
*
* @param {String} name - User name
*/
welcome: {
rest: "/welcome",
params: {
name: "string"
},
/** @param {Context} ctx */
async handler(ctx) {
return `Welcome, ${ctx.params.name}`;
}
}
},
/**
* Events
*/
events: {
},
/**
* Methods
*/
methods: {
},
/**
* Service created lifecycle event handler
*/
async created() {
await db.sequelize.sync({alter:true});
},
/**
* Service started lifecycle event handler
*/
async started() {
},
/**
* Service stopped lifecycle event handler
*/
async stopped() {
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment