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
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
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
"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
"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"; | |
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
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
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
# Ask for the user password | |
# Script only works if sudo caches the password for a few minutes | |
sudo true | |
# Install kernel extra's to enable docker aufs support | |
# sudo apt-get -y install linux-image-extra-$(uname -r) | |
# Add Docker PPA and install latest version | |
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" |
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
// Credit: http://web.archive.org/web/20120918093154/http://lehelk.com/2011/05/06/script-to-remove-diacritics | |
var defaultDiacriticsRemovalMap = [ | |
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g}, | |
{'base':'AA','letters':/[\uA732]/g}, | |
{'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g}, | |
{'base':'AO','letters':/[\uA734]/g}, | |
{'base':'AU','letters':/[\uA736]/g}, | |
{'base':'AV','letters':/[\uA738\uA73A]/g}, | |
{'base':'AY','letters':/[\uA73C]/g}, |