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
const { ServiceBroker } = require("moleculer"); | |
// Create broker | |
const broker = new ServiceBroker(); | |
// Create a service | |
broker.createService({ | |
name: "math", | |
actions: { | |
add(ctx) { | |
return Number(ctx.params.a) + Number(ctx.params.b); |
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
FROM node:6 | |
RUN mkdir /app | |
WORKDIR /app | |
COPY package.json . | |
RUN npm install --production | |
COPY . . |
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"; | |
let ServiceBroker = require("../src/service-broker"); | |
let BaseValidator = require("../src/validator"); | |
let { ValidationError } = require("../src/errors"); | |
// --- JOI VALIDATOR CLASS --- | |
class JoiValidator extends BaseValidator { | |
constructor() { | |
super(); |
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"; | |
let ServiceBroker = require("../src/service-broker"); | |
let broker = new ServiceBroker({ | |
logger: true, | |
logLevel: "debug", | |
}); | |
broker.createService({ |
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 ServiceBroker = require("../src/service-broker"); | |
/** | |
* Proof-of-Concept middleware to convert context params | |
* @param {Function} handler | |
* @param {Action} action | |
*/ | |
function paramConverterMiddleware(handler, action) { |
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
const ServiceBroker = require("moleculer"); | |
const SafeJSONSerializer = require("./safe-json-serializer.js"); | |
const broker = new ServiceBroker({ | |
logger: true, | |
serializer: new SafeJSONSerializer() | |
}); |
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
const MyService = { | |
name: "my", | |
actions: { | |
getImportantData() { | |
return ctx.call("other.get") | |
.then(res => { | |
return { | |
id: 1, | |
data: res | |
}; |
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 defaultsDeep = require("lodash/defaultsDeep"); | |
/** | |
* | |
* | |
* @class StatRequestStore | |
*/ | |
class StatRequestStore { |
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"; | |
// Generate webpack config with CLI service | |
const webpackConfig = require("@vue/cli-service/webpack.config.js"); | |
// Create express app | |
const express = require("express"); | |
const app = express(); | |
// Configure webpack as middleware |
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
const { ServiceBroker } = require('moleculer'); | |
let broker = new ServiceBroker({ | |
logger: console, | |
logLevel: 'info', | |
transporter: "nats://demo.nats.io:4222" | |
}); | |
broker.createService({ | |
name: 'math', |