This file contains hidden or 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 'isomorphic-fetch'; | |
| import Koa from 'koa'; | |
| import bodyParser from 'koa-bodyparser'; | |
| import convert from 'koa-convert'; | |
| import cors from 'koa-cors'; | |
| import koaLogger from 'koa-logger'; | |
| import Router from '@koa/router'; | |
| const app = new Koa(); |
This file contains hidden or 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 { createServer, proxy } from 'aws-serverless-express'; | |
| import connectDatabase from './database'; | |
| import app from './app'; | |
| export const handler = (event, ctx) => { | |
| // This will re-use `cachedMongoConn` between function calls. | |
| // See https://www.mongodb.com/blog/post/serverless-development-with-nodejs-aws-lambda-mongodb-atlas | |
| // See https://docs.atlas.mongodb.com/best-practices-connecting-to-aws-lambda/ |
This file contains hidden or 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 mongoose from 'mongoose'; | |
| import { MONGO_URI } from './config'; | |
| let cachedMongoConn = null; | |
| export default function connectDatabase() { | |
| return new Promise((resolve, reject) => { | |
| mongoose.Promise = global.Promise; | |
| mongoose.connection |
This file contains hidden or 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
| /** | |
| * Metro configuration for React Native | |
| * https://github.com/facebook/react-native | |
| * | |
| * @format | |
| */ | |
| const path = require('path'); | |
| const { FileStore } = require('metro-cache'); |
This file contains hidden or 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 hidden or 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 by https://stackoverflow.com/questions/105034/how-to-create-guid-uuid/2117523#2117523 | |
| // @TODO - improve this | |
| export function uuidv4() { | |
| return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
| const r = (Math.random() * 16) | 0, | |
| v = c == 'x' ? r : (r & 0x3) | 0x8; | |
| return v.toString(16); | |
| }); | |
| } |
This file contains hidden or 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 fs = require('fs'); | |
| const _ = require('lodash'); | |
| const exec = require('child_process').exec; | |
| const path = require('path'); | |
| // Concatenate root directory path with our backup folder. | |
| const backupDirPath = path.join(__dirname, 'database-backup'); | |
| const dbOptions = { | |
| user: '<databaseUsername>', |
This file contains hidden or 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
| function mapAsync<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]> { | |
| return Promise.all(array.map(callbackfn)); | |
| } | |
| async function filterAsync<T>(array: T[], callbackfn: (value: T, index: number, array: T[]) => Promise<boolean>): Promise<T[]> { | |
| const filterMap = await mapAsync(array, callbackfn); | |
| return array.filter((value, index) => filterMap[index]); | |
| } |
This file contains hidden or 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
| /* @flow */ | |
| export type ExtractReturn<Fn> = $Call<<T>((...Iterable<any>) => T) => T, Fn>; | |
| const mapStateToProps = state => ({ | |
| fromAnotherApp: state.app.fromAnotherApp, | |
| }); | |
| type ReduxProps = ExtractReturn<typeof mapStateToProps>; |
This file contains hidden or 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 listeners = [] | |
| const state = {} | |
| let noop = x => x | |
| function subscribe (fn) { | |
| listeners.push(fn) | |
| } | |
| function unsubscribe (fn) { | |
| listeners.splice(listeners.indexOf(fn), 1) |