Skip to content

Instantly share code, notes, and snippets.

Ryan Gasparini rxgx

Block or report user

Report or block rxgx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rxgx
rxgx / config.yml
Created Oct 30, 2019
CircleCI config for json-calendar
View config.yml
version: 2.1
orbs:
codecov: codecov/codecov@1.0.5
executors:
nodejs:
docker:
- image: circleci/node:10.16
working_directory: ~/json-calendar
@rxgx
rxgx / Gateway.md
Created Oct 2, 2019
Graph as a Gateway
View Gateway.md

GraphQL as a Gateway Architecture Flow

Objectives

  • Create a promotion based deployment flow for clients, instances of graphs, and backend resolvers.
  • Each node in this network has the potential to be live but only those which are tested and reliable are production-worthy.
  • Data and the metal are always guaranteed to be the latest usable pieces of the platform.

Flow

@rxgx
rxgx / newWithHooks.ts
Last active Sep 18, 2019
Apollo HoC to Hooks
View newWithHooks.ts
import React from 'react';
import { useQuery, QueryHookOptions } from '@apollo/react-hooks';
import ErrorBoundary from 'components/ErrorBoundary';
import PagePreloader from 'components/PagePreloader';
import getVendors from 'pages/Admin/queries/getVendors';
import VendorListTable from './VendorListTable';
const options: QueryHookOptions = {
fetchPolicy: 'no-cache',
variables: { isCorporate: true },
@rxgx
rxgx / client.js
Created Aug 22, 2019
GraphQL request client
View client.js
import { GraphQLClient } from 'graphql-request';
import authn from 'clients/authn';
import config from 'config';
const accessToken = authn.getToken('access_token');
const idToken = authn.getToken('id_token');
const graphQLClient = new GraphQLClient(config.apiGatewayUrl, {
headers: {
Authorization: accessToken,
@rxgx
rxgx / authn.md
Last active Sep 6, 2019
SPA Authn Options
View authn.md
@rxgx
rxgx / rename-flow-to-typescript.js
Created Aug 1, 2019
Rename files with Flow annotation to TypeScript
View rename-flow-to-typescript.js
const { genSummarizedReport } = require('flow-annotation-check');
const fs = require('fs');
const options = {
include: ['src/**/*.js'],
exclude: ['+(node_modules|build|flow-typed)/**/*.js'],
absolute: true,
};
function renameFile(srcPath, srcExt, destExt) {
@rxgx
rxgx / rename-to-jsx.js
Created Jul 31, 2019
Rename JS to JSX with ESLint JSON output
View rename-to-jsx.js
// Run eslint with the rule 'react/jsx-filename-extension' as 'error'
// eslint -o json > files.json
const fs = require('fs');
const json = require('./files.json')
console.log('run...', json.length);
json
.filter(entry => entry.messages.length)
View asyncExample.js
const AWS = require('aws-sdk');
const client = new AWS.SecretsManager({});
// Call the AWS API and return a Promise
function getAwsSecret(secretName) {
return client.getSecretValue({ SecretId: secretName }).promise();
}
// Create a async function to use the Promise
@rxgx
rxgx / addEncryptedToken.js
Last active Apr 18, 2018
Auth0 rule to save an encrypted version of Google's refresh token to a user's app_metadata
View addEncryptedToken.js
function (user, context, callback) {
const namespace = 'https://grateful.digital/';
if (
user.app_metadata &&
user.app_metadata.refresh_token_encrypted
) {
const refreshTokenEncrypted = user.app_metadata.refresh_token_encrypted;
context.idToken[namespace + 'refresh_token_encrypted'] = refreshTokenEncrypted;
}
@rxgx
rxgx / server.js
Last active Mar 16, 2018
Express initial config
View server.js
const express = require('express');
app = express();
const server = app.listen(3000, () => {
const host = server.address().address;
const port = server.address().port;
console.info('Express now listening on http://%s:%s', host, port);
});
You can’t perform that action at this time.