Skip to content

Instantly share code, notes, and snippets.

View ziedHamdi's full-sized avatar
💭
Exploring opportunities

Zied Hamdi ziedHamdi

💭
Exploring opportunities
View GitHub Profile
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');
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";
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;
}
import ExtendableError from './ExtendableError'
import {error} from "winston";
const AuthenticationErrors = {
NOT_AUTHENTICATED: 401,
BAD_CREDENTIALS: 402
}
class AuthenticationError extends ExtendableError {
static errors = AuthenticationErrors
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'