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 rules from "../rbac-rules"; | |
const check = (rules, role, action, data) => { | |
const permissions = rules[role]; | |
if (!permissions) { | |
// role is not present in the rules | |
return false; | |
} | |
const staticPermissions = permissions.static; |
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 React, { useContext, useCallback } from 'react'; | |
export const FeatureFlagContext = React.createContext<string[]>([]); | |
export const useFeatureFlag = () => { | |
const features = useContext<string[]>(FeatureFlagContext); | |
const hasFeature = useCallback( | |
(feature: string) => { | |
return features.includes(feature); |
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 path = require('path'); | |
const nodeExternals = require('webpack-node-externals'); | |
const cwd = process.cwd(); | |
export const outputPath = path.join(cwd, '.webpack'); | |
export const outputFilename = 'bundle.js'; | |
export default { |
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
{ | |
version: 1, | |
startTime: '2020-03-31T15:25:05.747Z', | |
endTime: '2020-03-31T15:25:05.747Z', | |
duration: 3130, | |
execution: { | |
resolvers: [ | |
{ | |
path: [ 'posts', 'analytics', 'quantity' ], | |
parentType: 'User', |
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 { SubscribeFunction, Observable } from 'relay-runtime'; | |
import { SubscriptionClient } from 'subscriptions-transport-ws'; | |
import config from '../config'; | |
import { getToken } from '../components/auth/security'; | |
export const setupSubscription: SubscribeFunction = (request, variables) => { | |
const query = request.text; | |
const authorization = getToken(); |
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 App = React.memo( | |
({ | |
node: { | |
items: { totalCount, ...items } | |
}, | |
relay | |
}) => { | |
const [fulltext, setFulltext] = useState('') | |
const fulltextDebounced = useDebounce(fulltext, 300) | |
const [{ sort, order }, updateSort] = useSort({ sort: 'name', order: 'asc' }) |
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 { useCallback } from 'react'; | |
import { matchRoutes, MatchedRoute, RouteConfig } from 'react-router-config'; | |
const prepareMatches = <Params extends { [K in keyof Params]?: string }>(matches: Array<MatchedRoute<Params>>) => { | |
return matches.map(match => { | |
const { route, match: matchData } = match; | |
const prepared = route.prepare ? route.prepare(matchData.params) : {}; | |
const Component = route.component.get(); | |
if (Component == null) { | |
route.component.load(); // eagerly load |
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
// eslint-disable-next-line | |
import { mongooseLoader } from '@entria/graphql-mongoose-loader'; | |
import DataLoader from 'dataloader'; | |
import { ConnectionArguments } from 'graphql-relay'; | |
import { Model, Types } from 'mongoose'; | |
import { buildMongoConditionsFromFilters } from '@entria/graphql-mongo-helpers'; | |
import { validateContextUser } from './validateContextUser'; | |
import { withConnectionCursor } from './withConnectionCursor'; |
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 { useState, useEffect } from 'react'; | |
import NetInfo from '@react-native-community/netinfo'; | |
const useInternetReachable = () => { | |
const [isReachable, setIsReachable] = useState(false); | |
const [isLoading, setIsLoading] = useState(true); | |
useEffect(() => { | |
const unsubscribe = NetInfo.addEventListener(({ isInternetReachable }) => { | |
if (typeof isInternetReachable !== 'boolean') return; |
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 { ROOT_ID } from 'relay-runtime'; | |
import { useRelayEnvironment } from 'react-relay/hooks'; | |
import { useLocation, useHistory } from 'react-router-dom'; | |
import { commitLocalUpdate } from 'react-relay' | |
import { useMutation } from 'relay-hooks/lib'; | |
import { AuthUserMutation } from 'mutations/AuthUserMutation'; | |
export const TOKEN_KEY = 'KEY'; |