Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Damnhorns nodkz

View GitHub Profile
@nodkz
nodkz / user.js
Created Nov 8, 2017
Mongoose with flow example
View user.js
/* @flow */
/* eslint-disable func-names */
import { Schema } from 'mongoose';
import DB from 'schema/db';
import composeWithMongoose from 'graphql-compose-mongoose';
import composeWithRelay from 'graphql-compose-relay';
import crypto from 'crypto';
import bcrypt from 'bcrypt';
import type { $Request } from 'express';
@nodkz
nodkz / react-relay_vx.x.x.js
Created Oct 18, 2017
react-relay flowtype declaration
View react-relay_vx.x.x.js
import * as React from "react";
declare class RelayComponentClass<Props> extends React$Component<Props, any> {
static getFragment: Function;
};
declare type createFragmentContainer = <TBase>(
Component: Class<React$Component<TBase, any>> | (props: TBase) => React.Node,
fragmentSpec: any
) => Class<RelayComponentClass<TBase>>;
View .flowconfig
[ignore]
.*/build/.*
.*/tools/.*
.*/node_modules/.*/test/.*
.*/node_modules/.*/tests/.*
.*/node_modules/ajv.*
.*/node_modules/acorn.*
.*/node_modules/async.*
.*/node_modules/babel.*
.*/node_modules/bluebird.*
@nodkz
nodkz / mongoose.flowtype.js
Last active Jun 16, 2018
Covering mongoose models with flowtype
View mongoose.flowtype.js
/* @flow */
/* eslint-disable */
import mongoose from 'mongoose';
export type MongoId = typeof mongoose.Types.ObjectId | {
toString(): string,
};
export type MongoOrScalarId = MongoId | string | number;
@nodkz
nodkz / .babelrc.js
Last active Jan 10, 2021
Babel 7.0 with .babelrc.js DEPRECATED! This config was created when babel 7 was in beta
View .babelrc.js
/* eslint-disable prefer-template */
const path = require('path');
const aliases = require('./aliases');
// ///////////////////////////////////////////////////////////////
// ////////////////// PLUGINS ////////////////////////////////
// ///////////////////////////////////////////////////////////////
const commonPlugins = [
@nodkz
nodkz / server.js
Created Feb 7, 2017
Sentry/raven manual config
View server.js
import path from 'path';
import express from 'express';
import { merge } from 'lodash';
import graphqlHTTP from 'express-graphql';
import PrettyError from 'pretty-error';
import expressHttpProxy from 'express-http-proxy';
import bodyParser from 'body-parser';
import raven from 'raven';
import morgan from 'morgan';
import { PORT, PUBLIC_URL } from 'config';
@nodkz
nodkz / apolloServer2019.ts
Last active Dec 6, 2020
GraphQL error tracking with sentry.io (ApolloServer 2019)
View apolloServer2019.ts
import express from 'express';
import { ApolloServer } from 'apollo-server-express';
import { ApolloServerPlugin } from 'apollo-server-plugin-base';
import * as Sentry from '@sentry/node';
Sentry.init({
environment: process.env.APP_ENV,
// see why we use APP_NAME here: https://github.com/getsentry/sentry-cli/issues/482
release: `${process.env.APP_NAME}-${process.env.APP_REVISION}` || '0.0.1',
dsn: process.env.SENTRY_DSN,
@nodkz
nodkz / relayStore.js
Last active Jun 29, 2017
relayStore with `reset` and simplified `mutate` methods
View relayStore.js
let relayStore;
function relayCreateStore() {
const env = new Relay.Environment();
env.injectNetworkLayer(new Relay.DefaultNetworkLayer('/graphql'));
if (__DEV__) {
RelayNetworkDebug.init(env);
}
env.reset = () => relayCreateStore();
env.mutate = ({
query,
@nodkz
nodkz / buildNodeImage.js
Created Dec 8, 2016
Building `node:slim` docker container with your node_modules via `node:build` container on Mac.
View buildNodeImage.js
/* eslint-disable no-use-before-define, camelcase */
import cp from 'child_process';
import fsExtra from 'fs-extra';
import hashFiles from 'hash-files';
import chalk from 'chalk';
import {
repositoryName,
rootDir,
buildEnv,
View routes.js
import React from 'react';
import Relay from 'react-relay';
import { relayStore } from 'app/clientStores'; // relayStore = Relay.Store;
import App from 'app/_components/App/App';
import Menu from 'app/Menu/Menu';
import MainPage from 'app/MainPage/MainPage';
import Page404 from 'app/_components/Page404/Page404';
import LoadingPage from 'app/_components/LoadingPage/LoadingPage';
import BrokenPage from 'app/_components/BrokenPage/BrokenPage';
You can’t perform that action at this time.