Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
const marky = require('marky') | |
const render = Vue.prototype._render | |
const update = Vue.prototype._update | |
const camelize = str => str && Vue.util.camelize(str) | |
function getName (vm) { | |
if (!vm.$parent) return 'root' | |
return ( | |
camelize(vm.$options.name) || | |
camelize(vm.$options._componentTag) || |
# Consider the record contains the time stamp of the event in a record key called 'timestamp' | |
# e.g. "timestamp": "1502217900063" | |
# The below will add a new record called `formatted_date` that will include an iso8601(3) formatted date string with milliseconds, | |
# the trick was to extract from the long epoch value the seconds & remaining milliseconds and convert it to microseconds since Time.at() accepts: | |
# `Time.at(seconds, microseconds_with_frac) → time` | |
<filter tag.*> | |
@type record_modifier | |
<record> |
const ApiGateway = require("moleculer-web"); | |
const CorsMixin = require('./cors.service'); | |
module.exports = { | |
name: "api", | |
mixins: [CorsMixin,ApiGateway], | |
settings: { | |
port: process.env.PORT || 3000, | |
allowedOrigins: ['http://localhost:8080'], |
# Initializes cluster master node: | |
kubeadm init --apiserver-advertise-address $(hostname -i) | |
# Initialize cluster networking: | |
kubectl apply -n kube-system -f \ | |
"https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" | |
# (Optional) Initialize kube-dashboard: |
const Benchmark = require('benchmark') | |
const co = require('co') | |
const bluebird = require('bluebird') | |
const suite = new Benchmark.Suite | |
suite | |
.add('co generators', { | |
defer: true, | |
fn: deferred => { |
#!/bin/bash | |
# Written 2018-11-15 by 4410287 | |
# This script will create a backup file of a postgres database and compress it. It is capable of access a local or remote server to pull the backup. After creating a new backup, it will delete backups that are older than 15 days, with the exception of backups created the first of every month. It is recommended to create a seperate database user specifically for backup purposes, and to set the permissions of this script to prevent access to the login details. Backup scripts for different databases should be run in seperate folders or they will overwrite each other. | |
HOSTNAME= | |
USERNAME= | |
PASSWORD= | |
DATABASE= |
#!/bin/sh | |
# | |
# This script deploys the given manifest, | |
# tracks the deployment, and rolls back on failure. | |
# | |
# First execute this with "myapp.yaml" and then try it with "myapp.failing.yaml" | |
# | |
MANIFEST_PATH=$1 | |
DEPLOYMENT_NAME=myapp |
'use strict'; | |
const path = require('path'); | |
const fs = require('fs'); | |
const YAML = require('yaml'); | |
function WebpackMoleculerServicePlugin(options) { | |
options = options || {}; | |
if (typeof options === 'string') { | |
this.options = { output: options }; |