Skip to content

Instantly share code, notes, and snippets.

View rhythnic's full-sized avatar

Nick Baroni rhythnic

View GitHub Profile
@rhythnic
rhythnic / request-response-over-pubsub.js
Last active October 12, 2019 12:16
Request/Response on top of pubsub
// *****************************************************************
// 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 }) => {})
// ***********************************************************************
// 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))
@rhythnic
rhythnic / us-states.json
Last active August 11, 2021 06:31
Name, abbreviation, and numeric code for all 50 US states and some territories.
[
{
"id": "01",
"name": "Alabama",
"abbr": "AL"
},
{
"id": "02",
"name": "Alaska",
"abbr": "AK"