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
[ | |
{ | |
"id": "01", | |
"name": "Alabama", | |
"abbr": "AL" | |
}, | |
{ | |
"id": "02", | |
"name": "Alaska", | |
"abbr": "AK" |
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
// *********************************************************************** | |
// Validator Lib | |
// *********************************************************************** | |
const { Success, Failure } = require('folktale/validation') | |
const fieldPath = (...args) => args.join('.') | |
const optional = args => ([ | |
(path, prop) => { | |
let assertions = args.map(x => x(path, prop)) |
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
// ***************************************************************** | |
// Extend pubsub with request-response pattern | |
// Pubsub instance should conform to this interface: | |
// https://github.com/apollographql/graphql-subscriptions/blob/master/src/pubsub-engine.ts | |
// ***************************************************************** | |
// ***************************************************************** | |
// API | |
// request(topic, args) | |
// respond(topic, ({ args, pass, request }) => {}) |
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 express = require('express') | |
const R = require('ramda') | |
const uuid = require('uuid') | |
const request = require('request') | |
// ******************************************************* | |
// Models | |
// ******************************************************* | |
// RequestSummary | |
// { |
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
// Serve a single page application (web-client) | |
const path = require('path') | |
const Express = require('express') | |
module.exports = function serveSpa ({ app, omit, public }) { | |
if (!omit) omit = () => false | |
app | |
.use(Express.static(public)) | |
.get('*', (req, res, next) => { | |
if (req.accepts('html') && !omit(req)) { |
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
// Usage with Jest | |
// | |
// const loginForm = [ | |
// { | |
// selector: '#login_username', | |
// property: 'username' | |
// }, | |
// { | |
// selector: '#login_password', | |
// property: 'password' |
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 { Directory } = require('./Directory') | |
const AWS = require('aws-sdk') | |
const { PassThrough } = require('stream') | |
const s3 = new AWS.S3({ apiVersion: '2006-03-01' }) | |
module.exports = class S3Directory extends Directory { | |
constructor (opts) { | |
super(opts) | |
this.Bucket = opts.Bucket |
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 { join } = require('path') | |
const fs = require('fs') | |
const pump = require('pump') | |
class Directory { | |
constructor ({ dir = '' }) { | |
this.dir = dir | |
this.init() | |
} | |
init () {} |
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 { Builder, until } = require('selenium-webdriver') | |
async function setupSeleniumDriver (config) { | |
let driver = await new Builder().forBrowser(config.BROWSER) | |
if (config.HUB_HOST) { | |
driver = driver.usingServer(`http://${config.HUB_HOST}:${config.HUB_PORT}/wd/hub`) | |
} | |
driver = driver.build() | |
await driver.manage().window().setPosition(0, 0) | |
await driver.manage().window().setSize(1280, 1024) |
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
// Small wrapper to enhance the fetch API and handle errors | |
// Requires Promise, fetch, and Object.assign polyfills | |
function checkFetchResponse (response) { | |
if (response.ok) return response | |
return response.text().then(function (text) { | |
const error = new Error(text || response.statusText) | |
error.status = response.status | |
error.statusText = response.statusText | |
throw error |
NewerOlder