UNPKG

mservice-node

Version:

minimal node micro service framework on top of fastify

22 lines (20 loc) 711 B
const { ServiceHandler } = require('../../index'); const handler = new ServiceHandler(); async function init(service_log) { service_log.info({ home_handler_config: this.config }) } const hi = async (request, reply) => { const name = request.params != null && request.params.name != null ? request.params.name : null; if (name == "error") { throw new Error("Error") } reply.send(`hi${name != null ? ` ${name}` : ""}${request.user != null ? `, ${JSON.stringify(request.user)}` : ""}`) } function close(service_log) { service_log.info(`close home hanlder`) } handler.hi = hi; handler.hiUser = hi; handler.initHandler = init; handler.closeHandler = close; module.exports = handler;