This file contains 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 asynchronousCall = async () => { | |
try { | |
const res = await fetch(...); | |
if (!res.ok) { | |
// Boomify the error response (See: Boom). | |
throw Boom(res.status, res.statusText); | |
} | |
} catch (err) { | |
throw err; |
This file contains 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 { map, isArray } = require('lodash'); | |
module.exports = (exchange, key, options = {}, channel) => (messages) => { | |
const defaultOptions = { | |
priority: 0, | |
deliveryMode: 'persistent', | |
contentEncoding: 'utf-8', | |
contentType: 'application/json' | |
}; |
This file contains 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 R = require('ramda'); | |
const acl = [ | |
{ | |
roles: ['USER_ADMIN'], | |
allows: [ | |
{ resource: '/test', permissions: ['get', 'post'] }, | |
{ resource: '/plus', permissions: ['put'] } | |
] |
This file contains 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
var express = require('express') | |
, jwtMiddleware = require('express-jwt') | |
, bodyParser = require('body-parser') | |
, cookieParser = require('cookie-parser') | |
, cors = require('cors'); | |
// We pass a secret token into the NodeJS process via an environment variable. | |
// We will use this token to sign cookies and JWTs | |
var SECRET_TOKEN = process.env.SECRET_TOKEN; |
This file contains 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
function factory() { | |
const config = { | |
data: [] | |
}; | |
return { | |
add(...nodes) { | |
nodes.forEach((item) => { |
This file contains 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
function buildStack(routes) { | |
const router = express.Router(); | |
each(routes, (config, path) => { | |
const { chain, method } = config; | |
router[method](path, chain); | |
}); | |
return router; |
This file contains 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
# Version key/value should be on his own line | |
PACKAGE_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g') | |
echo $PACKAGE_VERSION |
This file contains 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
/* "Thunks, Trampolines, and Continuation Passing" | |
* Python implementation from http://jtauber.com/blog/2008/03/30/ | |
* JavaScript implementation by Thomas Darr <me@trdarr.com>. | |
*/ | |
// thunk = lambda name: lambda *args: lambda: name(*args) | |
var thunk = function thunk(fn) { | |
return function _thunk() { | |
var splat = Array.prototype.slice.apply(arguments); | |
return function __thunk() { return fn.apply(this, splat); }; |
This file contains 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
import { Component } from "React"; | |
export var Enhance = ComposedComponent => class extends Component { | |
constructor() { | |
this.state = { data: null }; | |
} | |
componentDidMount() { | |
this.setState({ data: 'Hello' }); | |
} | |
render() { |
This file contains 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
import whilst from 'async/whilst'; | |
const buffer = { | |
data: [], | |
page: -1, | |
cursor: 0, |