Skip to content

Instantly share code, notes, and snippets.

View icebob's full-sized avatar

Icebob icebob

View GitHub Profile
@icebob
icebob / k3s_helm_install.sh
Last active March 27, 2024 12:04
K3S + Helm installing
# Install K3S
curl -sfL https://get.k3s.io | sh -
# Copy k3s config
mkdir $HOME/.kube
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
sudo chmod 644 $HOME/.kube/config
# Check K3S
kubectl get pods -n kube-system
@icebob
icebob / docker-compose.yml
Last active November 1, 2023 06:02
Start K3S Cluster on Docker
version: '3'
services:
server:
image: "rancher/k3s:latest"
command: server
tmpfs:
- /run
- /var/run
privileged: true
@icebob
icebob / README.md
Last active October 22, 2023 19:50
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
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
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 October 18, 2022 16:12
Loki logger for Moleculer microservices framework

Loki logger for Moleculer microservices framework

It sends the Moleculer log messages to a Grafana Loki server directly. I'm using it to send logs from Fly.io moleculer app to Grafana Cloud.

For Kubernetes, I recommend to use Grafana Agent to send log messages because Agent adds K8s pod relevant labels to the messages.

Usage

// moleculer.config.js
@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
@icebob
icebob / joi-validator.js
Created September 11, 2017 09:23
Example Joi validator for Moleculer
"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();
@icebob
icebob / LICENSE.md
Last active September 2, 2021 09:04
Mailtrap API helper for NodeJS

Copyright 2021 Icebob

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL