Skip to content

Instantly share code, notes, and snippets.

View icebob's full-sized avatar

Icebob icebob

View GitHub Profile
@icebob
icebob / README.md
Last active November 8, 2024 09:41
Health-check middleware for Moleculer (for Kubernetes liveness readiness checks)
@icebob
icebob / saga-sample.js
Last active October 2, 2023 10:47
Saga middleware PoC for Moleculer
"use strict";
const _ = require("lodash");
const chalk = require("chalk");
const Promise = require("bluebird");
const ServiceBroker = require("../src/service-broker");
const { MoleculerError } = require("../src/errors");
// --- SAGA MIDDLEWARE ---
const SagaMiddleware = function() {
@icebob
icebob / README.md
Created January 10, 2019 20:14
Inter-namespace middleware

Inter-namespace middleware

This middleware can connect to other namespaces.

Usage

Connect to other namespaces with the same broker options

moleculer.config.js

const InterNamespaceMiddleware = require("./inter-namespace.js");
@icebob
icebob / README.md
Last active December 14, 2018 11:34
Secure IDs with `hashids`

Secure IDs

This mixin created two methods to encode & decode your IDs in order to be more secure. Read more about it in hashids.js readme. It generates a Youtube-like ID from Number IDs or Mongo ObjectID.

Usage

Please note, you should define a salt for HashID with HASHID_SALT environment variables.

const SecureID = require("../mixins/secure-id.mixin");
@icebob
icebob / README.md
Created December 14, 2018 11:22
Memoize mixin for Moleculer services

Memoize mixin for Moleculer services

Add caching for Moleculer service methods too. This mixin creates a memoize method which caches responses in service methods.

Usage

const Memoize = require("../mixins/memoize.mixin");

module.exports = {
 name: "acl",
@icebob
icebob / README.md
Last active March 18, 2023 09:27
DB service mixin for Moleculer DB

DB handler mixin for Moleculer DB

It supports using MongoDB at development & production and using NeDB at unit testing.

Features

  • use NeDB memory DB for unit testing (NODE_ENV=test).
  • use NeDB file storage if NEDB_FOLDER is defined.
  • use other empty MongoDB database for E2E testing (NODE_ENV=test TEST_E2E=true).
  • create collection indexes.
  • generate entity changed broker messages. E.g. posts.entity.created, posts.entity.updated, posts.entity.removed
@icebob
icebob / README.md
Last active April 30, 2020 23:45
Cacher cleaner mixin for Moleculer DB service

Cache cleaner mixin for Moleculer DB service

Usage

const DbService	= require("moleculer-db");

module.exports = {
    name: "boards",
@icebob
icebob / ALTERNATIVES.adoc
Created October 30, 2018 15:53 — forked from mbbx6spp/ALTERNATIVES.adoc
Super quick list of alternatives to Jira and/or Confluence, Stash, Crucible, etc.
@icebob
icebob / __replit_main__
Created October 28, 2018 12:29
moleculer-demo created by icebob - https://repl.it/@icebob/moleculer-demo
const { ServiceBroker } = require('moleculer');
let broker = new ServiceBroker({
logger: console,
logLevel: 'info',
transporter: "nats://demo.nats.io:4222"
});
broker.createService({
name: 'math',
@icebob
icebob / serve.js
Last active May 1, 2022 16:31
Running Vue CLI 3 generated project with custom Express server
"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