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 complaintUpdateById = updateById.wrapResolve(next => async rp => { | |
const {user} = rp.context | |
const {_id, record} = rp.args; | |
let state = record['state']; | |
// allows us to save draft and then only throw auth error | |
let throwAuthError = false | |
if (isPublished(state) && (!user || !user.id) ) { | |
//do not save as published if error will be thrown | |
state = 'DRAFT' |
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 ExtendableError from './ExtendableError' | |
import {error} from "winston"; | |
const AuthenticationErrors = { | |
NOT_AUTHENTICATED: 401, | |
BAD_CREDENTIALS: 402 | |
} | |
class AuthenticationError extends ExtendableError { | |
static errors = AuthenticationErrors |
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
class ExtendableError extends Error { | |
constructor(message, errorCode) { | |
super(JSON.stringify( {text:message, code:errorCode} )) | |
this.name = this.constructor.name; | |
// this.errorCode = errorCode | |
if (typeof Error.captureStackTrace === 'function') { | |
Error.captureStackTrace(this, this.constructor); | |
} else { | |
this.stack = (new Error(message)).stack; | |
} |
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 {useMemo} from 'react' | |
import {ApolloClient, gql} from '@apollo/client' | |
// import {HttpLink} from '@apollo/client/link/http' | |
import {from, HttpLink} from '@apollo/client' | |
import { onError } from "@apollo/client/link/error"; | |
import merge from 'deepmerge' | |
import {createCache} from './cache' | |
import {isSSR} from "../constants/util"; | |
import isEqual from 'lodash/isEqual' | |
import logger from "../lib/logger"; |
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 {setUserAccessToken} from "../facebook"; | |
import {Session, User} from '../db' | |
import jwt from 'jsonwebtoken' | |
import {TOKEN_SECRET} from "../constants/other"; | |
import logger from "../../lib/logger"; | |
const GraphQlSchema = require('../graphql').default | |
const {graphqlHTTP} = require('express-graphql'); |
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 {useContext} from 'react'; | |
import {ToastContext} from '../ToastContextProvider'; | |
function useToast(timeout) { | |
const {toasts, addToast: originalAddToast, removeToast} = useContext(ToastContext); | |
function addToast(toast) { | |
originalAddToast(toast) | |
let appliedTimeout = toast.timeout ?? timeout | |
if (appliedTimeout > 0) |
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
/** | |
* inspired from https://www.yld.io/blog/global-notifications-with-reacts-context-api/ | |
*/ | |
import React, { useState, useCallback } from 'react'; | |
export const ToastContext = React.createContext({ | |
toasts: null, | |
addToast: () => {}, | |
removeToast: () => {}, | |
}); |
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 {useMemo} from 'react' | |
import {ApolloClient, gql} from '@apollo/client' | |
import merge from 'deepmerge' | |
import {cache} from './cache' | |
import {isSSR} from "../constants/util"; | |
import isEqual from 'lodash/isEqual' | |
export const APOLLO_STATE_PROP_NAME = '__APOLLO_STATE__' | |
const typeDefs = gql` |
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
#!/bin/bash | |
# GRAPHQL_SERVER_VERSION=$1 | |
# NEXT_SERVER_VERSION=$2 | |
# set variables from .env to system: https://gist.github.com/mihow/9c7f559807069a03e302605691f85572 | |
if [ -f .env ] | |
then | |
export $(cat .env | sed 's/#.*//g' | xargs) | |
fi |
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
#!/bin/bash | |
# GRAPHQL_SERVER_VERSION=$1 | |
# NEXT_SERVER_VERSION=$2 | |
# set variables from .env to system: https://gist.github.com/mihow/9c7f559807069a03e302605691f85572 | |
if [ -f .env ] | |
then | |
export $(cat .env | sed 's/#.*//g' | xargs) | |
fi |
NewerOlder