├── .nvmrc ├── Procfile ├── repl └── nodemon.json ├── .flowconfig ├── src ├── model │ ├── index.js │ ├── User.js │ └── Event.js ├── loader │ ├── index.js │ ├── UserLoader.js │ └── EventLoader.js ├── pubSub.js ├── type │ ├── SubscriptionType.js │ ├── LocationType.js │ ├── ScheduleType.js │ ├── MutationType.js │ ├── UserType.js │ ├── __tests__ │ │ └── UserType.spec.js │ ├── QueryType.js │ └── EventType.js ├── TypeDefinition.js ├── schema.js ├── connection │ ├── EventsConnection.js │ └── UserConnection.js ├── mutation │ ├── ScheduleInputType.js │ ├── LocationInputType.js │ ├── ChangePasswordMutation.js │ ├── LoginEmailMutation.js │ ├── RegisterEmailMutation.js │ ├── AttendToEventMutation.js │ ├── MoveToPresenceListMutation.js │ ├── CantGoToEventMutation.js │ ├── __tests__ │ │ ├── RegisterEmailMutation.spec.js │ │ ├── ChangePasswordMutation.spec.js │ │ └── LoginEmailMutation.spec.js │ ├── EventAddMutation.js │ └── EventEditMutation.js ├── database.js ├── auth.js ├── subscriptions │ └── UserAdded.js ├── interface │ ├── __tests__ │ │ └── NodeInterface.spec.js │ └── NodeInterface.js ├── config.js ├── index.js ├── __tests__ │ └── auth.spec.js └── app.js ├── .env.example ├── circle.yml ├── .env ├── .env.dev ├── flow-typed └── npm │ ├── flow-bin_v0.x.x.js │ ├── isomorphic-fetch_v2.x.x.js │ ├── koa-logger_vx.x.x.js │ ├── koa-compose_vx.x.x.js │ ├── repl.history_vx.x.x.js │ ├── repl-promised_vx.x.x.js │ ├── koa-bodyparser_vx.x.x.js │ ├── babel-preset-flow_vx.x.x.js │ ├── koa-graphql-batch_vx.x.x.js │ ├── babel-preset-es2015_vx.x.x.js │ ├── babel-preset-stage-0_vx.x.x.js │ ├── rimraf_vx.x.x.js │ ├── koa-convert_vx.x.x.js │ ├── koa-router_vx.x.x.js │ ├── koa-graphql_vx.x.x.js │ ├── bcrypt-as-promised_vx.x.x.js │ ├── repl_vx.x.x.js │ ├── dotenv-safe_vx.x.x.js │ ├── koa_vx.x.x.js │ ├── koa-cors_vx.x.x.js │ ├── babel-polyfill_vx.x.x.js │ ├── eslint-config-airbnb_vx.x.x.js │ ├── graphql-relay_vx.x.x.js │ ├── babel-eslint_vx.x.x.js │ ├── babel-cli_vx.x.x.js │ ├── bcryptjs_vx.x.x.js │ ├── nodemon_vx.x.x.js │ ├── jsonwebtoken_vx.x.x.js │ ├── reify_vx.x.x.js │ ├── express_v4.16.x.js │ ├── jest-cli_vx.x.x.js │ ├── eslint-plugin-import_vx.x.x.js │ ├── koa_v2.x.x.js │ └── jest_v20.x.x.js ├── Dockerfile ├── .babelrc ├── .eslintrc ├── .gitignore ├── docker-compose.test.yml ├── scripts ├── copySchemaToProject.js └── updateSchema.js ├── docker-compose.yml ├── test ├── mongooseConnection.js └── helper.js ├── .yarnclean ├── .circleci └── config.yml ├── README.md ├── repl.js ├── package.json ├── #package.json# └── data └── schema.graphql /.nvmrc: -------------------------------------------------------------------------------- 1 | 8.9.4 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: npm start 2 | -------------------------------------------------------------------------------- /repl/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartable": false 3 | } 4 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | -------------------------------------------------------------------------------- /src/model/index.js: -------------------------------------------------------------------------------- 1 | export User from './User'; 2 | export Event from './Event'; 3 | -------------------------------------------------------------------------------- /src/loader/index.js: -------------------------------------------------------------------------------- 1 | export * as UserLoader from './UserLoader'; 2 | export * as EventLoader from './EventLoader'; 3 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | #Enviroment 2 | NODE_ENV=development 3 | 4 | #GraphQL settings 5 | GRAPHQL_PORT=5000 6 | 7 | #Security 8 | JWT_KEY=awesome_secret_key 9 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | node: 3 | version: 4.4.7 4 | post: 5 | - npm install -g npm@3.x.x 6 | test: 7 | post: 8 | - bash <(curl -s https://codecov.io/bash) 9 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | #Enviroment 2 | NODE_ENV=development 3 | 4 | #GraphQL settings 5 | GRAPHQL_PORT=5001 6 | MONGO_URL=mongodb://localhost/database 7 | 8 | #Security 9 | JWT_KEY=awesome_secret_key 10 | -------------------------------------------------------------------------------- /.env.dev: -------------------------------------------------------------------------------- 1 | #Enviroment 2 | NODE_ENV=development 3 | 4 | #GraphQL settings 5 | GRAPHQL_PORT=5001 6 | MONGO_URL=mongodb://localhost/database 7 | 8 | #Security 9 | JWT_KEY=awesome_secret_key 10 | -------------------------------------------------------------------------------- /src/pubSub.js: -------------------------------------------------------------------------------- 1 | import { PubSub } from 'graphql-subscriptions'; 2 | 3 | export const EVENTS = { 4 | USER: { 5 | ADDED: 'USER_ADDED', 6 | }, 7 | }; 8 | 9 | export default new PubSub(); 10 | -------------------------------------------------------------------------------- /flow-typed/npm/flow-bin_v0.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583 2 | // flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x 3 | 4 | declare module "flow-bin" { 5 | declare module.exports: string; 6 | } 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:8 2 | 3 | MAINTAINER Entria 4 | 5 | RUN mkdir -p /app 6 | WORKDIR /app 7 | 8 | COPY package.json /app 9 | RUN npm i 10 | 11 | COPY . /app 12 | 13 | #cachable 14 | RUN npm run build 15 | 16 | CMD ["npm", "start"] 17 | -------------------------------------------------------------------------------- /src/type/SubscriptionType.js: -------------------------------------------------------------------------------- 1 | // external imports 2 | import { GraphQLObjectType } from 'graphql'; 3 | // local imports 4 | import UserAdded from '../subscriptions/UserAdded'; 5 | 6 | export default new GraphQLObjectType({ 7 | name: 'Subscription', 8 | fields: { 9 | UserAdded, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /flow-typed/npm/isomorphic-fetch_v2.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 28ad27471ba2cb831af6a1f17b7f0cf0 2 | // flow-typed version: f3161dc07c/isomorphic-fetch_v2.x.x/flow_>=v0.25.x 3 | 4 | 5 | declare module 'isomorphic-fetch' { 6 | declare module.exports: (input: string | Request, init?: RequestOptions) => Promise; 7 | } 8 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "flow", 4 | ["env", { 5 | "targets": { 6 | "node": "current" 7 | } 8 | }] 9 | ], 10 | "plugins": [ 11 | "transform-object-rest-spread", 12 | "transform-class-properties", 13 | "transform-export-extensions", 14 | "transform-async-to-generator" 15 | ] 16 | } -------------------------------------------------------------------------------- /src/TypeDefinition.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | import type Dataloader from 'dataloader'; 3 | import type { UserType } from './loader/UserLoader'; 4 | 5 | type Key = string; 6 | 7 | export type Dataloaders = { 8 | UserLoader: Dataloader, 9 | }; 10 | 11 | export type GraphQLContext = { 12 | user?: UserType, 13 | dataloaders: Dataloaders, 14 | }; 15 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb/base", 3 | "parser": "babel-eslint", 4 | "rules": { 5 | "no-console": 0, 6 | "max-len": [1, 120, 2], 7 | "no-param-reassign": [2, { "props": false }], 8 | "no-continue": 0, 9 | "no-underscore-dangle": 0, 10 | "generator-star-spacing": 0, 11 | }, 12 | "env": { 13 | "jest": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/schema.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLSchema } from 'graphql'; 4 | 5 | import QueryType from './type/QueryType'; 6 | import MutationType from './type/MutationType'; 7 | import SubscriptionType from './type/SubscriptionType'; 8 | 9 | export const schema = new GraphQLSchema({ 10 | query: QueryType, 11 | mutation: MutationType, 12 | subscription: SubscriptionType, 13 | }); 14 | -------------------------------------------------------------------------------- /src/connection/EventsConnection.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLInt } from 'graphql'; 4 | 5 | import { connectionDefinitions } from 'graphql-relay'; 6 | 7 | import EventType from '../type/EventType'; 8 | 9 | export default connectionDefinitions({ 10 | name: 'Event', 11 | nodeType: EventType, 12 | connectionFields: { 13 | count: { 14 | type: GraphQLInt, 15 | }, 16 | }, 17 | }); 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sublime-project 3 | *.sublime-workspace 4 | .idea/ 5 | .vscode/ 6 | package-lock.json 7 | 8 | lib-cov 9 | *.seed 10 | *.log 11 | *.csv 12 | *.dat 13 | *.out 14 | *.pid 15 | *.gz 16 | *.map 17 | 18 | pids 19 | logs 20 | results 21 | 22 | node_modules 23 | npm-debug.log 24 | 25 | dump.rdb 26 | bundle.js 27 | 28 | dist 29 | coverage 30 | .nyc_output 31 | flow-coverage 32 | 33 | .reify-cache/ -------------------------------------------------------------------------------- /src/connection/UserConnection.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLInt, 5 | } from 'graphql'; 6 | 7 | import { 8 | connectionDefinitions, 9 | } from 'graphql-relay'; 10 | 11 | import UserType from '../type/UserType'; 12 | 13 | export default connectionDefinitions({ 14 | name: 'User', 15 | nodeType: UserType, 16 | connectionFields: { 17 | count: { 18 | type: GraphQLInt, 19 | }, 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | test-jest: 4 | build: . 5 | depends_on: 6 | - mongo 7 | links: 8 | - mongo 9 | environment: 10 | NODE_ENV: test 11 | MONGO_URL: mongodb://mongo/test 12 | volumes: 13 | - "./src:/app/src" 14 | entrypoint: "npm run test:watch" 15 | mongo: 16 | image: mongo 17 | -------------------------------------------------------------------------------- /scripts/copySchemaToProject.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs-extra-promise'; // eslint-disable-line import/no-extraneous-dependencies 2 | 3 | const copySchemaToProject = async () => { 4 | try { 5 | await fs.copy('./data', '../reactconfbr-app/data'); 6 | 7 | console.info('Schema successfully copied to reactconf-app'); 8 | } catch (error) { 9 | console.error('There was an error while trying to copy schema to confapp', error); 10 | } 11 | }; 12 | 13 | copySchemaToProject(); 14 | -------------------------------------------------------------------------------- /src/mutation/ScheduleInputType.js: -------------------------------------------------------------------------------- 1 | import { GraphQLString, GraphQLInputObjectType } from 'graphql'; 2 | 3 | export default new GraphQLInputObjectType({ 4 | name: 'schedule', 5 | description: 'event schedule', 6 | fields: () => ({ 7 | talker: { 8 | type: GraphQLString, 9 | }, 10 | title: { 11 | type: GraphQLString, 12 | }, 13 | description: { 14 | type: GraphQLString, 15 | }, 16 | time: { 17 | type: GraphQLString, 18 | }, 19 | }), 20 | }); 21 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | graph-api: 4 | build: . 5 | depends_on: 6 | - mongo 7 | links: 8 | - mongo 9 | environment: 10 | NODE_ENV: development 11 | MONGO_URL: mongodb://mongo/database 12 | ports: 13 | - "5000:5000" 14 | volumes: 15 | - "./src:/app/src" 16 | - "./dist:/app/dist" 17 | entrypoint: "npm run watch" 18 | 19 | mongo: 20 | image: mongo 21 | -------------------------------------------------------------------------------- /src/type/LocationType.js: -------------------------------------------------------------------------------- 1 | import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLFloat } from 'graphql'; 2 | 3 | export default new GraphQLObjectType({ 4 | name: 'Location', 5 | description: 'Location Type', 6 | fields: () => ({ 7 | coordinates: { 8 | type: new GraphQLList(GraphQLFloat), 9 | }, 10 | cep: { 11 | type: GraphQLString, 12 | }, 13 | street: { 14 | type: GraphQLString, 15 | }, 16 | number: { 17 | type: GraphQLString, 18 | }, 19 | }), 20 | }); 21 | -------------------------------------------------------------------------------- /src/database.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import mongoose from 'mongoose'; 4 | import { databaseConfig } from './config'; 5 | 6 | export function connectDatabase() { 7 | return new Promise((resolve, reject) => { 8 | mongoose.Promise = global.Promise; 9 | mongoose.connection 10 | .on('error', error => reject(error)) 11 | .on('close', () => console.log('Database connection closed.')) 12 | .once('open', () => resolve(mongoose.connections[0])); 13 | 14 | mongoose.connect(databaseConfig); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /src/mutation/LocationInputType.js: -------------------------------------------------------------------------------- 1 | import { GraphQLString, GraphQLInputObjectType, GraphQLList, GraphQLFloat } from 'graphql'; 2 | 3 | export default new GraphQLInputObjectType({ 4 | name: 'location', 5 | description: 'event location', 6 | fields: () => ({ 7 | coordinates: { 8 | type: GraphQLList(GraphQLFloat), 9 | }, 10 | cep: { 11 | type: GraphQLString, 12 | }, 13 | street: { 14 | type: GraphQLString, 15 | }, 16 | number: { 17 | type: GraphQLString, 18 | }, 19 | }), 20 | }); 21 | -------------------------------------------------------------------------------- /test/mongooseConnection.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | 3 | const mongoUri = 'mongodb://localhost/test'; 4 | 5 | // mongoose.set('debug', true); 6 | 7 | mongoose.Promise = Promise; 8 | mongoose.connect(mongoUri, { 9 | auto_reconnect: true, 10 | reconnectTries: Number.MAX_VALUE, 11 | reconnectInterval: 1000, 12 | }); 13 | 14 | export const connection = mongoose.connection; 15 | 16 | connection.on('error', e => { 17 | if (e.message.code === 'ETIMEDOUT') { 18 | console.log(e); 19 | mongoose.connect(mongoUri, opts); 20 | } 21 | console.log(e); 22 | }); 23 | 24 | connection.once('open', () => { 25 | console.log(`MongoDB successfully connected to ${mongoUri}`); 26 | }); 27 | -------------------------------------------------------------------------------- /src/auth.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import jwt from 'jsonwebtoken'; 4 | import { User } from './model'; 5 | import { jwtSecret } from './config'; 6 | 7 | export async function getUser(token: string) { 8 | if (!token) return { user: null }; 9 | 10 | try { 11 | const decodedToken = jwt.verify(token.substring(4), jwtSecret); 12 | 13 | const user = await User.findOne({ _id: decodedToken.id }); 14 | 15 | return { 16 | user, 17 | }; 18 | } catch (err) { 19 | return { user: null }; 20 | } 21 | } 22 | 23 | type UserType = { 24 | _id: string, 25 | }; 26 | 27 | export function generateToken(user: UserType) { 28 | return `JWT ${jwt.sign({ id: user._id }, jwtSecret)}`; 29 | } 30 | -------------------------------------------------------------------------------- /.yarnclean: -------------------------------------------------------------------------------- 1 | # test directories 2 | __tests__ 3 | test 4 | tests 5 | powered-test 6 | 7 | # asset directories 8 | docs 9 | doc 10 | website 11 | images 12 | assets 13 | !istanbul-reports/lib/html/assets 14 | 15 | # examples 16 | example 17 | examples 18 | 19 | # code coverage directories 20 | coverage 21 | .nyc_output 22 | 23 | # build scripts 24 | Makefile 25 | Gulpfile.js 26 | Gruntfile.js 27 | 28 | # configs 29 | appveyor.yml 30 | circle.yml 31 | codeship-services.yml 32 | codeship-steps.yml 33 | wercker.yml 34 | .tern-project 35 | .gitattributes 36 | .editorconfig 37 | .*ignore 38 | .eslintrc 39 | .jshintrc 40 | .flowconfig 41 | .documentup.json 42 | .yarn-metadata.json 43 | .travis.yml 44 | 45 | # misc 46 | *.md 47 | -------------------------------------------------------------------------------- /src/type/ScheduleType.js: -------------------------------------------------------------------------------- 1 | import { GraphQLObjectType, GraphQLString } from 'graphql'; 2 | 3 | export default new GraphQLObjectType({ 4 | name: 'Schedule', 5 | description: 'Represents Schedules', 6 | fields: () => ({ 7 | _id: { 8 | type: GraphQLString, 9 | resolve: ({ _id }) => _id, 10 | }, 11 | talker: { 12 | type: GraphQLString, 13 | resolve: obj => obj.talker, 14 | }, 15 | title: { 16 | type: GraphQLString, 17 | resolve: obj => obj.title, 18 | }, 19 | description: { 20 | type: GraphQLString, 21 | resolve: obj => obj.description, 22 | }, 23 | time: { 24 | type: GraphQLString, 25 | resolve: obj => obj.time, 26 | }, 27 | }), 28 | }); 29 | -------------------------------------------------------------------------------- /src/subscriptions/UserAdded.js: -------------------------------------------------------------------------------- 1 | import { GraphQLObjectType } from 'graphql'; 2 | import { offsetToCursor } from 'graphql-relay'; 3 | import UserConnection from '../connection/UserConnection'; 4 | 5 | import pubSub, { EVENTS } from '../pubSub'; 6 | 7 | const UserAddedPayloadType = new GraphQLObjectType({ 8 | name: 'UserAddedPayload', 9 | fields: () => ({ 10 | userEdge: { 11 | type: UserConnection.edgeType, 12 | resolve: ({ user }) => { 13 | // TODO - figure it out how to get loaders from subscription context 14 | return { 15 | cursor: offsetToCursor(user.id), 16 | node: user, 17 | }; 18 | }, 19 | }, 20 | }), 21 | }); 22 | 23 | const userAdded = { 24 | type: UserAddedPayloadType, 25 | subscribe: () => pubSub.asyncIterator(EVENTS.USER.ADDED), 26 | }; 27 | 28 | export default userAdded; 29 | -------------------------------------------------------------------------------- /src/interface/__tests__/NodeInterface.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { toGlobalId } from 'graphql-relay'; 3 | import { schema } from '../../schema'; 4 | import { User } from '../../model'; 5 | import { getContext, setupTest } from '../../../test/helper'; 6 | 7 | beforeEach(async () => await setupTest()); 8 | 9 | it('should load User', async () => { 10 | const user = new User({ 11 | name: 'user', 12 | email: 'user@example.com', 13 | password: '123', 14 | }); 15 | await user.save(); 16 | 17 | //language=GraphQL 18 | const query = ` 19 | query Q { 20 | node(id: "${toGlobalId('User', user._id)}") { 21 | ... on User { 22 | name 23 | } 24 | } 25 | } 26 | `; 27 | 28 | const rootValue = {}; 29 | const context = getContext(); 30 | 31 | const result = await graphql(schema, query, rootValue, context); 32 | const { node } = result.data; 33 | 34 | expect(node.name).toBe(user.name); 35 | }); 36 | -------------------------------------------------------------------------------- /src/interface/NodeInterface.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { nodeDefinitions, fromGlobalId } from 'graphql-relay'; 4 | 5 | import User from '../loader/UserLoader'; 6 | import { UserLoader } from '../loader'; 7 | 8 | import QueryType from '../type/QueryType'; 9 | import UserType from '../type/UserType'; 10 | 11 | const { nodeField, nodeInterface } = nodeDefinitions( 12 | // A method that maps from a global id to an object 13 | async (globalId, context) => { 14 | const { id, type } = fromGlobalId(globalId); 15 | 16 | // console.log('id, type: ', type, id, globalId); 17 | if (type === 'User') { 18 | return await UserLoader.load(context, id); 19 | } 20 | }, 21 | // A method that maps from an object to a type 22 | obj => { 23 | // console.log('obj: ', typeof obj, obj.constructor); 24 | if (obj instanceof User) { 25 | return UserType; 26 | } 27 | }, 28 | ); 29 | 30 | export const NodeInterface = nodeInterface; 31 | export const NodeField = nodeField; 32 | -------------------------------------------------------------------------------- /src/type/MutationType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLObjectType } from 'graphql'; 4 | 5 | import LoginEmail from '../mutation/LoginEmailMutation'; 6 | import RegisterEmail from '../mutation/RegisterEmailMutation'; 7 | import ChangePassword from '../mutation/ChangePasswordMutation'; 8 | 9 | import EventAdd from '../mutation/EventAddMutation'; 10 | import EventEdit from '../mutation/EventEditMutation'; 11 | import AttendToEvent from '../mutation/AttendToEventMutation'; 12 | import CantGoToEvent from '../mutation/CantGoToEventMutation'; 13 | import MoveToPresenceList from '../mutation/MoveToPresenceListMutation'; 14 | 15 | export default new GraphQLObjectType({ 16 | name: 'Mutation', 17 | fields: () => ({ 18 | // auth 19 | LoginEmail, 20 | RegisterEmail, 21 | ChangePassword, 22 | 23 | // events 24 | EventAdd, 25 | EventEdit, 26 | 27 | // event list management 28 | AttendToEvent, 29 | CantGoToEvent, 30 | MoveToPresenceList, 31 | }), 32 | }); 33 | -------------------------------------------------------------------------------- /src/config.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import path from 'path'; 3 | import dotenvSafe from 'dotenv-safe'; 4 | 5 | const root = path.join.bind(this, __dirname, '../'); 6 | 7 | dotenvSafe.load({ 8 | path: root('.env'), 9 | sample: root('.env.example'), 10 | }); 11 | 12 | const ENV = ((process.env: any): { 13 | MONGO_URL: string, 14 | NODE_ENV: string, 15 | GRAPHQL_PORT: string, 16 | JWT_KEY: string, 17 | [string]: ?string, 18 | }); 19 | 20 | // Database Settings 21 | const dBdevelopment = ENV.MONGO_URL || 'mongodb://localhost/database'; 22 | const dBproduction = ENV.MONGO_URL || 'mongodb://localhost/database'; 23 | 24 | // Test Database Settings 25 | // const test = 'mongodb://localhost/awesome-test'; 26 | 27 | // Export DB Settings 28 | export const databaseConfig = ENV.NODE_ENV === 'production' ? dBproduction : dBdevelopment; 29 | 30 | // Export GraphQL Server settings 31 | export const graphqlPort = ENV.PORT || ENV.GRAPHQL_PORT || 5000; 32 | export const jwtSecret = ENV.JWT_KEY || 'secret_key'; 33 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-logger_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: a9c7f49a73f83723d24c91bb87b3b15b 2 | // flow-typed version: <>/koa-logger_v^2.0.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-logger' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-logger' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | 26 | 27 | // Filename aliases 28 | declare module 'koa-logger/index' { 29 | declare module.exports: $Exports<'koa-logger'>; 30 | } 31 | declare module 'koa-logger/index.js' { 32 | declare module.exports: $Exports<'koa-logger'>; 33 | } 34 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-compose_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: ecfb1138a666eba69173c6cfe3f1bac2 2 | // flow-typed version: <>/koa-compose_v^4.0.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-compose' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-compose' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | 26 | 27 | // Filename aliases 28 | declare module 'koa-compose/index' { 29 | declare module.exports: $Exports<'koa-compose'>; 30 | } 31 | declare module 'koa-compose/index.js' { 32 | declare module.exports: $Exports<'koa-compose'>; 33 | } 34 | -------------------------------------------------------------------------------- /flow-typed/npm/repl.history_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 2e8e406a416c4adee333aeab14221385 2 | // flow-typed version: <>/repl.history_v^0.1.4/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'repl.history' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'repl.history' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | 26 | 27 | // Filename aliases 28 | declare module 'repl.history/index' { 29 | declare module.exports: $Exports<'repl.history'>; 30 | } 31 | declare module 'repl.history/index.js' { 32 | declare module.exports: $Exports<'repl.history'>; 33 | } 34 | -------------------------------------------------------------------------------- /flow-typed/npm/repl-promised_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 706d69a61911e3538005b850629cf0ec 2 | // flow-typed version: <>/repl-promised_v^0.1.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'repl-promised' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'repl-promised' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | 26 | 27 | // Filename aliases 28 | declare module 'repl-promised/index' { 29 | declare module.exports: $Exports<'repl-promised'>; 30 | } 31 | declare module 'repl-promised/index.js' { 32 | declare module.exports: $Exports<'repl-promised'>; 33 | } 34 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-bodyparser_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: ef2abddb0428f9283902c978fcf7025c 2 | // flow-typed version: <>/koa-bodyparser_v^2.2.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-bodyparser' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-bodyparser' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | 26 | 27 | // Filename aliases 28 | declare module 'koa-bodyparser/index' { 29 | declare module.exports: $Exports<'koa-bodyparser'>; 30 | } 31 | declare module 'koa-bodyparser/index.js' { 32 | declare module.exports: $Exports<'koa-bodyparser'>; 33 | } 34 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-flow_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: c39acea7c78146fcb5cc8be37f7ea134 2 | // flow-typed version: <>/babel-preset-flow_v^6.23.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-flow' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-flow' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-flow/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-flow/lib/index.js' { 31 | declare module.exports: $Exports<'babel-preset-flow/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-graphql-batch_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 8b1a206c18e12996dff61f8a245048fa 2 | // flow-typed version: <>/koa-graphql-batch_v^1.1.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-graphql-batch' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-graphql-batch' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'koa-graphql-batch/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'koa-graphql-batch/lib/index.js' { 31 | declare module.exports: $Exports<'koa-graphql-batch/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-es2015_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: cc52b4874d48c8e5eeafb8fade9fbdbd 2 | // flow-typed version: <>/babel-preset-es2015_v^6.24.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-es2015' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-es2015' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-es2015/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-es2015/lib/index.js' { 31 | declare module.exports: $Exports<'babel-preset-es2015/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-stage-0_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 1dc8e15c75f281dffdace778720e0eab 2 | // flow-typed version: <>/babel-preset-stage-0_v^6.24.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-stage-0' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-stage-0' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-stage-0/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-stage-0/lib/index.js' { 31 | declare module.exports: $Exports<'babel-preset-stage-0/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /src/type/UserType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLObjectType, GraphQLString, GraphQLBoolean } from 'graphql'; 4 | import { globalIdField } from 'graphql-relay'; 5 | import { NodeInterface } from '../interface/NodeInterface'; 6 | 7 | type UserType = { 8 | _id: string, 9 | name: string, 10 | email: string, 11 | role: string, 12 | active: string, 13 | }; 14 | 15 | export default new GraphQLObjectType({ 16 | name: 'User', 17 | description: 'User data', 18 | fields: () => ({ 19 | id: globalIdField('User'), 20 | _id: { 21 | type: GraphQLString, 22 | resolve: (user: UserType) => user._id, 23 | }, 24 | name: { 25 | type: GraphQLString, 26 | resolve: (user: UserType) => user.name, 27 | }, 28 | email: { 29 | type: GraphQLString, 30 | resolve: (user: UserType) => user.email, 31 | }, 32 | role: { 33 | type: GraphQLString, 34 | resolve: (user: UserType) => user.role, 35 | }, 36 | active: { 37 | type: GraphQLBoolean, 38 | resolve: (user: UserType) => user.active, 39 | }, 40 | }), 41 | interfaces: () => [NodeInterface], 42 | }); 43 | -------------------------------------------------------------------------------- /flow-typed/npm/rimraf_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 3ebb7dc9640f087ab46c79a1c365e10a 2 | // flow-typed version: <>/rimraf_v^2.6.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'rimraf' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'rimraf' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'rimraf/bin' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'rimraf/rimraf' { 30 | declare module.exports: any; 31 | } 32 | 33 | // Filename aliases 34 | declare module 'rimraf/bin.js' { 35 | declare module.exports: $Exports<'rimraf/bin'>; 36 | } 37 | declare module 'rimraf/rimraf.js' { 38 | declare module.exports: $Exports<'rimraf/rimraf'>; 39 | } 40 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-convert_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 35ee626f330ad40d82f15951426b6bd3 2 | // flow-typed version: <>/koa-convert_v^1.2.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-convert' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-convert' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'koa-convert/test' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'koa-convert/index' { 31 | declare module.exports: $Exports<'koa-convert'>; 32 | } 33 | declare module 'koa-convert/index.js' { 34 | declare module.exports: $Exports<'koa-convert'>; 35 | } 36 | declare module 'koa-convert/test.js' { 37 | declare module.exports: $Exports<'koa-convert/test'>; 38 | } 39 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-router_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 9b38c1239716a494c252fe5f4ed23e92 2 | // flow-typed version: <>/koa-router_v^7.1.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-router' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-router' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'koa-router/lib/layer' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'koa-router/lib/router' { 30 | declare module.exports: any; 31 | } 32 | 33 | // Filename aliases 34 | declare module 'koa-router/lib/layer.js' { 35 | declare module.exports: $Exports<'koa-router/lib/layer'>; 36 | } 37 | declare module 'koa-router/lib/router.js' { 38 | declare module.exports: $Exports<'koa-router/lib/router'>; 39 | } 40 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-graphql_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 2716bccab7716f0d52a5be0ffe60bf84 2 | // flow-typed version: <>/koa-graphql_v^0.6.2/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-graphql' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-graphql' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'koa-graphql/dist/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'koa-graphql/dist/renderGraphiQL' { 30 | declare module.exports: any; 31 | } 32 | 33 | // Filename aliases 34 | declare module 'koa-graphql/dist/index.js' { 35 | declare module.exports: $Exports<'koa-graphql/dist/index'>; 36 | } 37 | declare module 'koa-graphql/dist/renderGraphiQL.js' { 38 | declare module.exports: $Exports<'koa-graphql/dist/renderGraphiQL'>; 39 | } 40 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Javascript Node CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-javascript/ for more details 4 | # 5 | version: 2 6 | 7 | deployment: 8 | staging: 9 | branch: master 10 | heroku: 11 | appname: reactconfapp 12 | 13 | jobs: 14 | build: 15 | docker: 16 | # specify the version you desire here 17 | - image: circleci/node:7.10 18 | 19 | # Specify service dependencies here if necessary 20 | # CircleCI maintains a library of pre-built images 21 | # documented at https://circleci.com/docs/2.0/circleci-images/ 22 | # - image: circleci/mongo:3.4.4 23 | 24 | working_directory: ~/repo 25 | 26 | steps: 27 | - checkout 28 | 29 | # Download and cache dependencies 30 | - restore_cache: 31 | keys: 32 | - v1-dependencies-{{ checksum "package.json" }} 33 | # fallback to using the latest cache if no exact match is found 34 | - v1-dependencies- 35 | 36 | - run: yarn install 37 | 38 | - save_cache: 39 | paths: 40 | - node_modules 41 | key: v1-dependencies-{{ checksum "package.json" }} 42 | 43 | # run tests! commented 44 | #- run: yarn test 45 | -------------------------------------------------------------------------------- /flow-typed/npm/bcrypt-as-promised_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 1337b7210d228fc438075ecd083ad4d2 2 | // flow-typed version: <>/bcrypt-as-promised_v^1.1.0/flow_v0.44.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'bcrypt-as-promised' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'bcrypt-as-promised' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'bcrypt-as-promised/test/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'bcrypt-as-promised/index' { 31 | declare module.exports: $Exports<'bcrypt-as-promised'>; 32 | } 33 | declare module 'bcrypt-as-promised/index.js' { 34 | declare module.exports: $Exports<'bcrypt-as-promised'>; 35 | } 36 | declare module 'bcrypt-as-promised/test/index.js' { 37 | declare module.exports: $Exports<'bcrypt-as-promised/test/index'>; 38 | } 39 | -------------------------------------------------------------------------------- /flow-typed/npm/repl_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6628a14954ed2d7f4be14b3124b0fb07 2 | // flow-typed version: <>/repl_v^0.1.3/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'repl' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'repl' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'repl/lib/repl' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'repl/test' { 30 | declare module.exports: any; 31 | } 32 | 33 | // Filename aliases 34 | declare module 'repl/index' { 35 | declare module.exports: $Exports<'repl'>; 36 | } 37 | declare module 'repl/index.js' { 38 | declare module.exports: $Exports<'repl'>; 39 | } 40 | declare module 'repl/lib/repl.js' { 41 | declare module.exports: $Exports<'repl/lib/repl'>; 42 | } 43 | declare module 'repl/test.js' { 44 | declare module.exports: $Exports<'repl/test'>; 45 | } 46 | -------------------------------------------------------------------------------- /src/type/__tests__/UserType.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { User } from '../../model'; 4 | import { getContext, setupTest } from '../../../test/helper'; 5 | 6 | beforeEach(async () => await setupTest()); 7 | 8 | it('should not show email of other users', async () => { 9 | const user = new User({ 10 | name: 'user', 11 | email: 'user@example.com', 12 | password: '123', 13 | }); 14 | await user.save(); 15 | 16 | const user1 = new User({ 17 | name: 'awesome', 18 | email: 'awesome@example.com', 19 | password: '123', 20 | }); 21 | await user1.save(); 22 | 23 | //language=GraphQL 24 | const query = ` 25 | query Q { 26 | users(first: 2) { 27 | edges { 28 | node { 29 | _id 30 | name 31 | email 32 | active 33 | } 34 | } 35 | } 36 | } 37 | `; 38 | 39 | const rootValue = {}; 40 | const context = getContext({ user }); 41 | 42 | const result = await graphql(schema, query, rootValue, context); 43 | const { edges } = result.data.users; 44 | 45 | expect(edges[0].node.name).toBe(user1.name); 46 | expect(edges[0].node.email).toBe(null); 47 | 48 | expect(edges[1].node.name).toBe(user.name); 49 | expect(edges[1].node.email).toBe(user.email); 50 | }); 51 | -------------------------------------------------------------------------------- /src/mutation/ChangePasswordMutation.js: -------------------------------------------------------------------------------- 1 | import { 2 | GraphQLString, 3 | GraphQLNonNull, 4 | } from 'graphql'; 5 | import { 6 | mutationWithClientMutationId, 7 | } from 'graphql-relay'; 8 | 9 | import UserType from '../type/UserType'; 10 | import { UserLoader } from '../loader'; 11 | 12 | export default mutationWithClientMutationId({ 13 | name: 'ChangePassword', 14 | inputFields: { 15 | oldPassword: { 16 | type: new GraphQLNonNull(GraphQLString), 17 | }, 18 | password: { 19 | type: new GraphQLNonNull(GraphQLString), 20 | description: 'user new password', 21 | }, 22 | }, 23 | mutateAndGetPayload: async ({ oldPassword, password }, { user }) => { 24 | if (!user) { 25 | throw new Error('invalid user'); 26 | } 27 | 28 | const correctPassword = user.authenticate(oldPassword); 29 | 30 | if (!correctPassword) { 31 | return { 32 | error: 'INVALID_PASSWORD', 33 | }; 34 | } 35 | 36 | user.password = password; 37 | await user.save(); 38 | 39 | return { 40 | error: null, 41 | }; 42 | }, 43 | outputFields: { 44 | error: { 45 | type: GraphQLString, 46 | resolve: ({ error }) => error, 47 | }, 48 | me: { 49 | type: UserType, 50 | resolve: (obj, args, context) => UserLoader.load(context, context.user.id), 51 | }, 52 | }, 53 | }); 54 | -------------------------------------------------------------------------------- /src/model/User.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import mongoose from 'mongoose'; 3 | import bcrypt from 'bcryptjs'; 4 | 5 | const ROLES = { 6 | ADMIN: 'ADMIN', 7 | REGULAR: 'REGULAR', 8 | }; 9 | const Schema = new mongoose.Schema( 10 | { 11 | name: { 12 | type: String, 13 | required: true, 14 | }, 15 | password: { 16 | type: String, 17 | hidden: true, 18 | }, 19 | role: { 20 | type: String, 21 | required: true, 22 | default: ROLES.REGULAR, 23 | }, 24 | email: { 25 | type: String, 26 | required: false, 27 | index: true, 28 | }, 29 | active: { 30 | type: Boolean, 31 | default: true, 32 | }, 33 | }, 34 | { 35 | timestamps: { 36 | createdAt: 'createdAt', 37 | updatedAt: 'updatedAt', 38 | }, 39 | collection: 'user', 40 | }, 41 | ); 42 | 43 | Schema.pre('save', function(next) { 44 | // Hash the password 45 | if (this.isModified('password')) { 46 | this.password = this.encryptPassword(this.password); 47 | } 48 | 49 | return next(); 50 | }); 51 | 52 | Schema.methods = { 53 | authenticate(plainTextPassword) { 54 | return bcrypt.compareSync(plainTextPassword, this.password); 55 | }, 56 | encryptPassword(password) { 57 | return bcrypt.hashSync(password, 8); 58 | }, 59 | }; 60 | 61 | export default mongoose.model('User', Schema); 62 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import 'babel-polyfill'; 3 | import { createServer } from 'http'; 4 | import app from './app'; 5 | import { connectDatabase } from './database'; 6 | import { graphqlPort } from './config'; 7 | 8 | import { SubscriptionServer } from 'subscriptions-transport-ws'; 9 | import { execute, subscribe } from 'graphql'; 10 | 11 | import { schema } from './schema'; 12 | 13 | (async () => { 14 | try { 15 | const info = await connectDatabase(); 16 | console.log(`Connected to ${info.host}:${info.port}/${info.name}`); 17 | } catch (error) { 18 | console.error('Unable to connect to database'); 19 | process.exit(1); 20 | } 21 | 22 | const server = createServer(app.callback()); 23 | 24 | server.listen(graphqlPort, () => { 25 | console.log(`server now listening at :${graphqlPort}`); 26 | SubscriptionServer.create( 27 | { 28 | onConnect: connectionParams => console.log('client subscription connected!', connectionParams), 29 | onDisconnect: () => console.log('client subscription disconnected!'), 30 | execute, 31 | subscribe, 32 | schema, 33 | }, 34 | { 35 | server, 36 | path: '/subscriptions', 37 | }, 38 | ); 39 | }); 40 | console.log(`Playground started at localhost:${graphqlPort}/playground`); 41 | console.log(`Server started on port ${graphqlPort}`); 42 | })(); 43 | -------------------------------------------------------------------------------- /src/mutation/LoginEmailMutation.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import { GraphQLString, GraphQLNonNull } from 'graphql'; 3 | import { mutationWithClientMutationId } from 'graphql-relay'; 4 | 5 | import { User } from '../model'; 6 | import { generateToken } from '../auth'; 7 | 8 | import type { UserType } from '../loader/UserLoader'; 9 | 10 | export default mutationWithClientMutationId({ 11 | name: 'LoginEmail', 12 | inputFields: { 13 | email: { 14 | type: new GraphQLNonNull(GraphQLString), 15 | }, 16 | password: { 17 | type: new GraphQLNonNull(GraphQLString), 18 | }, 19 | }, 20 | mutateAndGetPayload: async ({ email, password }: UserType) => { 21 | const user = await User.findOne({ email: email.toLowerCase() }); 22 | 23 | if (!user) { 24 | return { 25 | token: null, 26 | error: 'Invalid email or password', 27 | }; 28 | } 29 | 30 | const correctPassword = user.authenticate(password); 31 | 32 | if (!correctPassword) { 33 | return { 34 | token: null, 35 | error: 'Invalid email or password', 36 | }; 37 | } 38 | 39 | return { 40 | token: generateToken(user), 41 | error: null, 42 | }; 43 | }, 44 | outputFields: { 45 | token: { 46 | type: GraphQLString, 47 | resolve: ({ token }) => token, 48 | }, 49 | error: { 50 | type: GraphQLString, 51 | resolve: ({ error }) => error, 52 | }, 53 | }, 54 | }); 55 | -------------------------------------------------------------------------------- /flow-typed/npm/dotenv-safe_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 73472b296fb6b664764cf68ecb14ed35 2 | // flow-typed version: <>/dotenv-safe_v^4.0.4/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'dotenv-safe' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'dotenv-safe' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'dotenv-safe/config' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'dotenv-safe/MissingEnvVarsError' { 30 | declare module.exports: any; 31 | } 32 | 33 | // Filename aliases 34 | declare module 'dotenv-safe/config.js' { 35 | declare module.exports: $Exports<'dotenv-safe/config'>; 36 | } 37 | declare module 'dotenv-safe/index' { 38 | declare module.exports: $Exports<'dotenv-safe'>; 39 | } 40 | declare module 'dotenv-safe/index.js' { 41 | declare module.exports: $Exports<'dotenv-safe'>; 42 | } 43 | declare module 'dotenv-safe/MissingEnvVarsError.js' { 44 | declare module.exports: $Exports<'dotenv-safe/MissingEnvVarsError'>; 45 | } 46 | -------------------------------------------------------------------------------- /src/mutation/RegisterEmailMutation.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import { GraphQLString, GraphQLNonNull } from 'graphql'; 3 | import { mutationWithClientMutationId } from 'graphql-relay'; 4 | import { User } from '../model'; 5 | import { generateToken } from '../auth'; 6 | import pubSub, { EVENTS } from '../pubSub'; 7 | 8 | export default mutationWithClientMutationId({ 9 | name: 'RegisterEmail', 10 | inputFields: { 11 | name: { 12 | type: new GraphQLNonNull(GraphQLString), 13 | }, 14 | email: { 15 | type: new GraphQLNonNull(GraphQLString), 16 | }, 17 | password: { 18 | type: new GraphQLNonNull(GraphQLString), 19 | }, 20 | }, 21 | mutateAndGetPayload: async ({ name, email, password }) => { 22 | let user = await User.findOne({ email: email.toLowerCase() }); 23 | 24 | if (user) { 25 | return { 26 | token: null, 27 | error: 'The email is already in use', 28 | }; 29 | } 30 | 31 | user = new User({ 32 | name, 33 | email, 34 | password, 35 | }); 36 | await user.save(); 37 | 38 | await pubSub.publish(EVENTS.USER.ADDED, { UserAdded: { user } }); 39 | 40 | return { 41 | token: generateToken(user), 42 | error: null, 43 | }; 44 | }, 45 | outputFields: { 46 | token: { 47 | type: GraphQLString, 48 | resolve: ({ token }) => token, 49 | }, 50 | error: { 51 | type: GraphQLString, 52 | resolve: ({ error }) => error, 53 | }, 54 | }, 55 | }); 56 | -------------------------------------------------------------------------------- /src/__tests__/auth.spec.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | import { graphql } from 'graphql'; 3 | import { schema } from '../schema'; 4 | import { User } from '../model'; 5 | import { setupTest } from '../../test/helper'; 6 | 7 | import { getUser, generateToken } from '../auth'; 8 | 9 | const { ObjectId } = mongoose.Types; 10 | 11 | beforeEach(async () => await setupTest()); 12 | 13 | describe('getUser', () => { 14 | it('should return an user null when token is null', async () => { 15 | const token = null; 16 | const { user } = await getUser(token); 17 | 18 | expect(user).toBe(null); 19 | }); 20 | 21 | it('should return null when token is invalid', async () => { 22 | const token = 'invalid token'; 23 | const { user } = await getUser(token); 24 | 25 | expect(user).toBe(null); 26 | }); 27 | 28 | it('should return null when token do not represent a valid user', async () => { 29 | const token = generateToken({ _id: new ObjectId() }); 30 | const { user } = await getUser(token); 31 | 32 | expect(user).toBe(null); 33 | }); 34 | 35 | it('should return user from a valid token', async () => { 36 | const me = new User({ 37 | name: 'user', 38 | email: 'user@example.com', 39 | password: '123', 40 | }); 41 | await me.save(); 42 | 43 | const token = generateToken(me); 44 | const { user } = await getUser(token); 45 | 46 | expect(user.name).toBe(me.name); 47 | expect(user.email).toBe(me.email); 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /flow-typed/npm/koa_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: ae61fc7076a2b7f9238d0ee175b2e90c 2 | // flow-typed version: <>/koa_v^2.2.0/flow_v0.44.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'koa/lib/application' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'koa/lib/context' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'koa/lib/request' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'koa/lib/response' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'koa/lib/application.js' { 43 | declare module.exports: $Exports<'koa/lib/application'>; 44 | } 45 | declare module 'koa/lib/context.js' { 46 | declare module.exports: $Exports<'koa/lib/context'>; 47 | } 48 | declare module 'koa/lib/request.js' { 49 | declare module.exports: $Exports<'koa/lib/request'>; 50 | } 51 | declare module 'koa/lib/response.js' { 52 | declare module.exports: $Exports<'koa/lib/response'>; 53 | } 54 | -------------------------------------------------------------------------------- /scripts/updateSchema.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env babel-node --optional es7.asyncFunctions 2 | /** 3 | * This file provided by Facebook is for non-commercial testing and evaluation 4 | * purposes only. Facebook reserves all rights not expressly granted. 5 | * 6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 9 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 10 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 11 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | */ 13 | 14 | import fs from 'fs'; 15 | import path from 'path'; 16 | import { schema } from '../src/schema'; 17 | import { graphql } from 'graphql'; 18 | import { introspectionQuery, printSchema } from 'graphql/utilities'; 19 | 20 | // Save JSON of full schema introspection for Babel Relay Plugin to use 21 | (async () => { 22 | const result = await (graphql(schema, introspectionQuery)); 23 | if (result.errors) { 24 | console.error( 25 | 'ERROR introspecting schema: ', 26 | JSON.stringify(result.errors, null, 2) 27 | ); 28 | } else { 29 | fs.writeFileSync( 30 | path.join(__dirname, '../data/schema.json'), 31 | JSON.stringify(result, null, 2) 32 | ); 33 | 34 | process.exit(0); 35 | } 36 | })(); 37 | 38 | // Save user readable type system shorthand of schema 39 | fs.writeFileSync( 40 | path.join(__dirname, '../data/schema.graphql'), 41 | printSchema(schema) 42 | ); 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React conf Server 2 | 3 | ## Create-GraphQL 4 | If you want to move faster you should use [create-graphql](https://github.com/lucasbento/create-graphql) to simplify the creation of a GraphQL Server 5 | 6 | ## Command 7 | 8 | #### Setup 9 | ```bash 10 | npm install 11 | ``` 12 | Note: If you do not have mongodb installed, please install it: 13 | ```bash 14 | brew install mongodb 15 | ``` 16 | #### Develop 17 | ```bash 18 | npm run watch 19 | ``` 20 | 21 | ### Test 22 | ```bash 23 | npm test 24 | ``` 25 | 26 | Or 27 | ```bash 28 | npm run test:watch 29 | ``` 30 | 31 | #### Docker and docker-compose 32 | No needs for installing dependencies or running `mongod` in another terminal window 33 | 34 | ```bash 35 | docker-compose build && docker-compose up 36 | ``` 37 | 38 | Test 39 | ```bash 40 | docker-compose -f docker-compose.test.yml build && docker-compose -f docker-compose.test.yml up 41 | ``` 42 | 43 | #### Production 44 | ```bash 45 | # first compile the code 46 | npm run build 47 | 48 | # run graphql compiled server 49 | npm start 50 | ``` 51 | 52 | ### Flow 53 | ```bash 54 | npm run flow 55 | ``` 56 | 57 | Or 58 | ```bash 59 | flow 60 | ``` 61 | 62 | ### REPL server 63 | ```bash 64 | npm run repl 65 | 66 | awesome > const user = await M.User.find() 67 | ``` 68 | 69 | Yep, await syntax works on the repl, it is awesome, tks @princejwesley (https://gist.github.com/princejwesley/a66d514d86ea174270210561c44b71ba) 70 | 71 | ### Schema 72 | Update your schema 73 | ```bash 74 | npm run update-schema 75 | ``` 76 | 77 | Take a look on the [Schema](https://github.com/sibelius/graphql-dataloader-boilerplate/blob/master/data/schema.graphql) 78 | -------------------------------------------------------------------------------- /src/model/Event.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import mongoose from 'mongoose'; 3 | const { ObjectId } = mongoose.Schema.Types; 4 | 5 | const SchemaSchedule = new mongoose.Schema({ 6 | talker: { 7 | type: String, 8 | }, 9 | title: { 10 | type: String, 11 | }, 12 | description: { 13 | type: String, 14 | }, 15 | time: { 16 | type: String, 17 | }, 18 | }); 19 | 20 | const Schema = new mongoose.Schema( 21 | { 22 | title: { 23 | type: String, 24 | }, 25 | createdBy: { 26 | type: ObjectId, 27 | ref: 'User', 28 | required: true, 29 | description: 'User that created this event', 30 | }, 31 | description: { 32 | type: String, 33 | }, 34 | date: { 35 | type: String, 36 | }, 37 | location: { 38 | type: { type: String, default: 'Point' }, 39 | coordinates: { type: [Number, Number], default: [0, 0] }, 40 | cep: { type: String }, 41 | street: { type: String }, 42 | number: { type: String }, 43 | }, 44 | publicLimit: { 45 | type: String, 46 | }, 47 | publicList: { 48 | type: [String], 49 | required: true, 50 | default: [], 51 | }, 52 | waitList: { 53 | type: [String], 54 | required: true, 55 | default: [], 56 | }, 57 | notGoingList: { 58 | type: [String], 59 | required: true, 60 | default: [], 61 | }, 62 | image: { 63 | type: String, 64 | }, 65 | schedule: [SchemaSchedule], 66 | }, 67 | { 68 | timestamps: { 69 | createdAt: 'createdAt', 70 | updatedAt: 'updatedAt', 71 | }, 72 | collection: 'event', 73 | }, 74 | ); 75 | 76 | Schema.index({ location: '2dsphere' }); 77 | 78 | export default mongoose.model('Event', Schema); 79 | -------------------------------------------------------------------------------- /flow-typed/npm/koa-cors_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 02d812c520427cb211b82d27b5865a9e 2 | // flow-typed version: <>/koa-cors_v0.0.16/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'koa-cors' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'koa-cors' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'koa-cors/examples/basic-auth-and-cors' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'koa-cors/examples/custom-options' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'koa-cors/examples/defaults-options' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'koa-cors/test/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'koa-cors/examples/basic-auth-and-cors.js' { 43 | declare module.exports: $Exports<'koa-cors/examples/basic-auth-and-cors'>; 44 | } 45 | declare module 'koa-cors/examples/custom-options.js' { 46 | declare module.exports: $Exports<'koa-cors/examples/custom-options'>; 47 | } 48 | declare module 'koa-cors/examples/defaults-options.js' { 49 | declare module.exports: $Exports<'koa-cors/examples/defaults-options'>; 50 | } 51 | declare module 'koa-cors/index' { 52 | declare module.exports: $Exports<'koa-cors'>; 53 | } 54 | declare module 'koa-cors/index.js' { 55 | declare module.exports: $Exports<'koa-cors'>; 56 | } 57 | declare module 'koa-cors/test/index.js' { 58 | declare module.exports: $Exports<'koa-cors/test/index'>; 59 | } 60 | -------------------------------------------------------------------------------- /src/mutation/AttendToEventMutation.js: -------------------------------------------------------------------------------- 1 | import { GraphQLString, GraphQLNonNull, GraphQLID } from 'graphql'; 2 | 3 | import { fromGlobalId, mutationWithClientMutationId } from 'graphql-relay'; 4 | 5 | import { Event as EventModel } from '../model'; 6 | import type { GraphQLContext } from '../TypeDefinition'; 7 | 8 | type Arguments = { 9 | eventId: string, 10 | }; 11 | 12 | type Output = { 13 | message: string, 14 | error: string, 15 | }; 16 | 17 | export default mutationWithClientMutationId({ 18 | name: 'AttendToEvent', 19 | inputFields: { 20 | eventId: { 21 | type: new GraphQLNonNull(GraphQLID), 22 | }, 23 | }, 24 | mutateAndGetPayload: async (args: Arguments, { user }: GraphQLContext) => { 25 | if (!user) { 26 | return { 27 | message: 'Invalid User', 28 | error: 'INVALID_USER', 29 | }; 30 | } 31 | 32 | const { eventId } = args; 33 | 34 | const event = await EventModel.findOne({ 35 | _id: fromGlobalId(eventId).id, 36 | }); 37 | 38 | if (!event) { 39 | return { 40 | message: 'Event does not exists', 41 | error: 'INVALID_EVENT', 42 | }; 43 | } 44 | 45 | const { publicList, publicLimit, waitList } = event; 46 | 47 | if (publicList.length >= parseInt(publicLimit)) { 48 | await event.update({ 49 | waitList: [...waitList, user._id], 50 | }); 51 | return { 52 | message: 'You have been added to the wait list', 53 | error: null, 54 | }; 55 | } 56 | 57 | await event.update({ 58 | publicList: [...publicList, user._id], 59 | }); 60 | 61 | return { 62 | message: 'You have been added to eventList', 63 | error: null, 64 | }; 65 | }, 66 | outputFields: { 67 | message: { 68 | type: GraphQLString, 69 | resolve: ({ message }: Output) => message, 70 | }, 71 | error: { 72 | type: GraphQLString, 73 | resolve: ({ error }: Output) => error, 74 | }, 75 | }, 76 | }); 77 | -------------------------------------------------------------------------------- /test/helper.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import mongoose from 'mongoose'; 3 | import * as loaders from '../src/loader'; 4 | 5 | const { ObjectId } = mongoose.Types; 6 | 7 | process.env.NODE_ENV = 'test'; 8 | 9 | const MONGO_URL = process.env.MONGO_URL || 'mongodb://localhost/test'; 10 | 11 | const config = { 12 | db: { 13 | test: MONGO_URL, 14 | }, 15 | connection: null, 16 | }; 17 | 18 | function connect() { 19 | return new Promise((resolve, reject) => { 20 | if (config.connection) { 21 | return resolve(); 22 | } 23 | 24 | mongoose.Promise = Promise; 25 | 26 | const options = { 27 | auto_reconnect: true, 28 | reconnectTries: Number.MAX_VALUE, 29 | reconnectInterval: 1000, 30 | }; 31 | 32 | mongoose.connect(MONGO_URL, options); 33 | 34 | config.connection = mongoose.connection; 35 | 36 | config.connection.once('open', resolve).on('error', e => { 37 | if (e.message.code === 'ETIMEDOUT') { 38 | console.log(e); 39 | 40 | mongoose.connect(MONGO_URL, options); 41 | } 42 | 43 | console.log(e); 44 | reject(e); 45 | }); 46 | }); 47 | } 48 | 49 | function clearDatabase() { 50 | return new Promise(resolve => { 51 | let cont = 0; 52 | let max = Object.keys(mongoose.connection.collections).length; 53 | for (const i in mongoose.connection.collections) { 54 | mongoose.connection.collections[i].remove(function() { 55 | cont++; 56 | if (cont >= max) { 57 | resolve(); 58 | } 59 | }); 60 | } 61 | }); 62 | } 63 | 64 | export function getContext(context: Object) { 65 | const dataloaders = Object.keys(loaders).reduce( 66 | (dataloaders, loaderKey) => ({ 67 | ...dataloaders, 68 | [loaderKey]: loaders[loaderKey].getLoader(), 69 | }), 70 | {}, 71 | ); 72 | 73 | return { 74 | ...context, 75 | req: {}, 76 | dataloaders, 77 | }; 78 | } 79 | 80 | export async function setupTest() { 81 | await connect(); 82 | await clearDatabase(); 83 | } 84 | -------------------------------------------------------------------------------- /src/mutation/MoveToPresenceListMutation.js: -------------------------------------------------------------------------------- 1 | import { GraphQLString, GraphQLNonNull, GraphQLID } from 'graphql'; 2 | 3 | import { mutationWithClientMutationId } from 'graphql-relay'; 4 | 5 | import { Event as EventModel } from '../model'; 6 | import type { GraphQLContext } from '../TypeDefinition'; 7 | 8 | type Arguments = { 9 | eventId: string, 10 | }; 11 | 12 | type Output = { 13 | message: string, 14 | error: string, 15 | }; 16 | 17 | export default mutationWithClientMutationId({ 18 | name: 'MoveToPresenceList', 19 | inputFields: { 20 | eventId: { 21 | type: new GraphQLNonNull(GraphQLID), 22 | }, 23 | }, 24 | mutateAndGetPayload: async (args: Arguments, { user }: GraphQLContext) => { 25 | if (!user) { 26 | return { 27 | message: 'Invalid User', 28 | error: 'INVALID_USER', 29 | }; 30 | } 31 | 32 | const { eventId } = args; 33 | 34 | const event = await EventModel.findOne({ 35 | _id: eventId, 36 | }); 37 | 38 | if (!event) { 39 | return { 40 | message: 'Event does not exists', 41 | error: 'INVALID_EVENT', 42 | }; 43 | } 44 | 45 | const { publicList, publicLimit, waitList } = event; 46 | 47 | if (publicList.length === parseInt(publicLimit)) { 48 | return { 49 | message: "There's no more room on the presence list", 50 | error: 'NO_MORE_ROOM', 51 | }; 52 | } 53 | 54 | const newWaitList = waitList.filter(person => person === user._id); 55 | console.log(newWaitList); 56 | 57 | await event.update({ 58 | waitList: [...newWaitList], 59 | publicList: [...publicList, user._id], 60 | }); 61 | 62 | return { 63 | message: 'You have been moved to the presence list', 64 | error: null, 65 | }; 66 | }, 67 | outputFields: { 68 | message: { 69 | type: GraphQLString, 70 | resolve: ({ message }: Output) => message, 71 | }, 72 | error: { 73 | type: GraphQLString, 74 | resolve: ({ error }: Output) => error, 75 | }, 76 | }, 77 | }); 78 | -------------------------------------------------------------------------------- /src/mutation/CantGoToEventMutation.js: -------------------------------------------------------------------------------- 1 | import { GraphQLString, GraphQLNonNull, GraphQLID } from 'graphql'; 2 | 3 | import { fromGlobalId, mutationWithClientMutationId } from 'graphql-relay'; 4 | 5 | import { Event as EventModel } from '../model'; 6 | import type { GraphQLContext } from '../TypeDefinition'; 7 | 8 | type Arguments = { 9 | eventId: string, 10 | }; 11 | 12 | type Output = { 13 | message: string, 14 | error: string, 15 | }; 16 | 17 | export default mutationWithClientMutationId({ 18 | name: 'CantGoToEvent', 19 | inputFields: { 20 | eventId: { 21 | type: new GraphQLNonNull(GraphQLID), 22 | }, 23 | }, 24 | mutateAndGetPayload: async (args: Arguments, { user }: GraphQLContext) => { 25 | if (!user) { 26 | return { 27 | message: 'Invalid User', 28 | error: 'INVALID_USER', 29 | }; 30 | } 31 | 32 | const { eventId } = args; 33 | 34 | const event = await EventModel.findOne({ 35 | _id: fromGlobalId(eventId).id, 36 | }); 37 | 38 | if (!event) { 39 | return { 40 | message: 'Event does not exists', 41 | error: 'INVALID_EVENT', 42 | }; 43 | } 44 | 45 | const { notGoingList, publicList } = event; 46 | 47 | console.log(publicList.includes(user._id)); 48 | 49 | if (publicList.indexOf(user._id) === 0) { 50 | const newPublicList = publicList.filter(person => person === user._id); 51 | await event.update({ 52 | publicList: [...newPublicList], 53 | notGoingList: [...notGoingList, user._id], 54 | }); 55 | return { 56 | message: 'Thanks for warning us that you cant go to the event', 57 | }; 58 | } 59 | 60 | await event.update({ 61 | notGoingList: [...notGoingList, user._id], 62 | }); 63 | 64 | return { 65 | message: 'Ok! we have added you to not going list', 66 | error: null, 67 | }; 68 | }, 69 | outputFields: { 70 | message: { 71 | type: GraphQLString, 72 | resolve: ({ message }: Output) => message, 73 | }, 74 | error: { 75 | type: GraphQLString, 76 | resolve: ({ error }: Output) => error, 77 | }, 78 | }, 79 | }); 80 | -------------------------------------------------------------------------------- /src/mutation/__tests__/RegisterEmailMutation.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../model'; 6 | import { generateToken } from '../../auth'; 7 | import { 8 | getContext, 9 | setupTest, 10 | } from '../../../test/helper'; 11 | 12 | beforeEach(async () => await setupTest()); 13 | 14 | it('should not register with the an existing email', async () => { 15 | const name = 'awesome'; 16 | const email = 'awesome@example.com'; 17 | 18 | const user = new User({ 19 | name, 20 | email, 21 | password: '123', 22 | }); 23 | await user.save(); 24 | 25 | //language=GraphQL 26 | const query = ` 27 | mutation M { 28 | RegisterEmail(input: { 29 | clientMutationId: "abc" 30 | name: "Awesome" 31 | email: "${email}" 32 | password: "awesome" 33 | }) { 34 | clientMutationId 35 | token 36 | error 37 | } 38 | } 39 | `; 40 | 41 | const rootValue = {}; 42 | const context = getContext(); 43 | 44 | const result = await graphql(schema, query, rootValue, context); 45 | const { RegisterEmail } = result.data; 46 | 47 | expect(RegisterEmail.token).toBe(null); 48 | expect(RegisterEmail.error).toBe('EMAIL_ALREADY_IN_USE'); 49 | }); 50 | 51 | it('should create a new user with parameters are valid', async () => { 52 | const email = 'awesome@example.com'; 53 | 54 | //language=GraphQL 55 | const query = ` 56 | mutation M { 57 | RegisterEmail(input: { 58 | clientMutationId: "abc" 59 | name: "Awesome" 60 | email: "${email}" 61 | password: "awesome" 62 | }) { 63 | clientMutationId 64 | token 65 | error 66 | } 67 | } 68 | `; 69 | 70 | const rootValue = {}; 71 | const context = getContext(); 72 | 73 | const result = await graphql(schema, query, rootValue, context); 74 | const { RegisterEmail } = result.data; 75 | 76 | const user = await User.findOne({ 77 | email, 78 | }); 79 | 80 | expect(user).not.toBe(null); 81 | expect(RegisterEmail.token).toBe(generateToken(user)); 82 | expect(RegisterEmail.error).toBe(null); 83 | }); 84 | -------------------------------------------------------------------------------- /src/loader/UserLoader.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import DataLoader from 'dataloader'; 3 | import { User as UserModel } from '../model'; 4 | import { connectionFromMongoCursor, mongooseLoader } from '@entria/graphql-mongoose-loader'; 5 | 6 | import type { ConnectionArguments } from 'graphql-relay'; 7 | import type { GraphQLContext } from '../TypeDefinition'; 8 | 9 | export type UserType = { 10 | id: string, 11 | _id: string, 12 | name: string, 13 | password: string, 14 | email: string, 15 | active: boolean, 16 | role: string, 17 | }; 18 | 19 | export default class User { 20 | id: string; 21 | _id: string; 22 | name: string; 23 | email: string; 24 | active: boolean; 25 | role: string; 26 | 27 | constructor(data: UserType, { user }: GraphQLContext) { 28 | this.id = data.id; 29 | this._id = data._id; 30 | this.name = data.name; 31 | this.role = data.role; 32 | 33 | // you can only see your own email, and your active status 34 | if (user && user._id.equals(data._id)) { 35 | this.email = data.email; 36 | this.active = data.active; 37 | } 38 | } 39 | } 40 | 41 | export const getLoader = () => new DataLoader(ids => mongooseLoader(UserModel, ids)); 42 | 43 | const viewerCanSee = (context, data) => 44 | // Anyone can see another user 45 | true; 46 | 47 | export const load = async (context: GraphQLContext, id: string): Promise => { 48 | if (!id) { 49 | return null; 50 | } 51 | 52 | let data; 53 | try { 54 | data = await context.dataloaders.UserLoader.load(id); 55 | } catch (err) { 56 | return null; 57 | } 58 | return viewerCanSee(context, data) ? new User(data, context) : null; 59 | }; 60 | 61 | export const clearCache = ({ dataloaders }: GraphQLContext, id: string) => dataloaders.UserLoader.clear(id.toString()); 62 | 63 | export const loadUsers = async (context: GraphQLContext, args: ConnectionArguments) => { 64 | const where = args.search ? { name: { $regex: new RegExp(`^${args.search}`, 'ig') } } : {}; 65 | const users = UserModel.find(where, { _id: 1 }).sort({ createdAt: -1 }); 66 | 67 | return connectionFromMongoCursor({ 68 | cursor: users, 69 | context, 70 | args, 71 | loader: load, 72 | }); 73 | }; 74 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-polyfill_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: c6f558fc8ba25b565b624d19c1c0f1d1 2 | // flow-typed version: <>/babel-polyfill_v^6.23.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-polyfill' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-polyfill' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-polyfill/browser' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-polyfill/dist/polyfill' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-polyfill/dist/polyfill.min' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-polyfill/lib/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-polyfill/scripts/postpublish' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-polyfill/scripts/prepublish' { 46 | declare module.exports: any; 47 | } 48 | 49 | // Filename aliases 50 | declare module 'babel-polyfill/browser.js' { 51 | declare module.exports: $Exports<'babel-polyfill/browser'>; 52 | } 53 | declare module 'babel-polyfill/dist/polyfill.js' { 54 | declare module.exports: $Exports<'babel-polyfill/dist/polyfill'>; 55 | } 56 | declare module 'babel-polyfill/dist/polyfill.min.js' { 57 | declare module.exports: $Exports<'babel-polyfill/dist/polyfill.min'>; 58 | } 59 | declare module 'babel-polyfill/lib/index.js' { 60 | declare module.exports: $Exports<'babel-polyfill/lib/index'>; 61 | } 62 | declare module 'babel-polyfill/scripts/postpublish.js' { 63 | declare module.exports: $Exports<'babel-polyfill/scripts/postpublish'>; 64 | } 65 | declare module 'babel-polyfill/scripts/prepublish.js' { 66 | declare module.exports: $Exports<'babel-polyfill/scripts/prepublish'>; 67 | } 68 | -------------------------------------------------------------------------------- /repl.js: -------------------------------------------------------------------------------- 1 | import 'esm'; 2 | import 'isomorphic-fetch'; 3 | import 'babel-polyfill'; 4 | import REPL from 'repl'; 5 | import replPromised from 'repl-promised'; 6 | import history from 'repl.history'; 7 | // import babel from 'babel-core'; 8 | const babel = require('babel-core'); 9 | 10 | import { connectDatabase } from './src/database'; 11 | import * as M from './src/model'; 12 | import { generateToken } from './src/auth'; 13 | 14 | // based on https://gist.github.com/princejwesley/a66d514d86ea174270210561c44b71ba 15 | /** 16 | * Preprocess repl command to wrap await inside an async function if needed 17 | * @param input 18 | * @returns {*} 19 | */ 20 | function preprocess(input) { 21 | const awaitMatcher = /^(?:\s*(?:(?:let|var|const)\s)?\s*([^=]+)=\s*|^\s*)(await\s[\s\S]*)/; 22 | const asyncWrapper = (code, binder) => { 23 | let assign = binder ? `global.${binder} = ` : ''; 24 | return `(function(){ async function _wrap() { return ${assign}${code} } return _wrap();})()`; 25 | }; 26 | 27 | // match & transform 28 | const match = input.match(awaitMatcher); 29 | if (match) { 30 | input = `${asyncWrapper(match[2], match[1])}`; 31 | } 32 | return input; 33 | } 34 | 35 | function myEval(cmd, context, filename, callback) { 36 | const code = babel.transform(preprocess(cmd), { 37 | presets: [ 38 | 'flow', 39 | [ 40 | 'env', 41 | { 42 | targets: { 43 | node: 'current', 44 | }, 45 | }, 46 | ], 47 | ], 48 | plugins: [['babel-plugin-transform-flow-strip-types']], 49 | }).code; 50 | _eval(code, context, filename, callback); 51 | } 52 | 53 | let _eval; 54 | 55 | (async () => { 56 | try { 57 | const info = await connectDatabase(); 58 | console.log(`Connected to ${info.host}:${info.port}/${info.name}`); 59 | 60 | const repl = REPL.start({ 61 | prompt: 'awesome > ', 62 | }); 63 | _eval = repl.eval; 64 | repl.eval = myEval; 65 | 66 | repl.context.M = M; 67 | repl.context.generateToken = generateToken; 68 | 69 | history(repl, `${process.env.HOME}/.node_history`); 70 | 71 | replPromised.promisify(repl); 72 | } catch (error) { 73 | console.error('Unable to connect to database'); 74 | process.exit(1); 75 | } 76 | })(); 77 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import 'isomorphic-fetch'; 3 | 4 | import Koa from 'koa'; 5 | import bodyParser from 'koa-bodyparser'; 6 | import convert from 'koa-convert'; 7 | import cors from 'kcors'; 8 | import graphqlHttp from 'koa-graphql'; 9 | import graphqlBatchHttpWrapper from 'koa-graphql-batch'; 10 | import logger from 'koa-logger'; 11 | import Router from 'koa-router'; 12 | // import { print } from 'graphql/language'; 13 | import { graphiqlKoa } from 'apollo-server-koa'; 14 | import { koaPlayground } from 'graphql-playground-middleware'; 15 | import { schema } from './schema'; 16 | import { jwtSecret, graphqlPort } from './config'; 17 | import { getUser } from './auth'; 18 | import * as loaders from './loader'; 19 | 20 | const app = new Koa(); 21 | const router = new Router(); 22 | 23 | app.keys = jwtSecret; 24 | 25 | const graphqlSettingsPerReq = async req => { 26 | const { user } = await getUser(req.header.authorization); 27 | 28 | const dataloaders = Object.keys(loaders).reduce( 29 | (dataloaders, loaderKey) => ({ 30 | ...dataloaders, 31 | [loaderKey]: loaders[loaderKey].getLoader(), 32 | }), 33 | {}, 34 | ); 35 | 36 | return { 37 | graphiql: process.env.NODE_ENV !== 'production', 38 | schema, 39 | context: { 40 | user, 41 | req, 42 | dataloaders, 43 | }, 44 | // extensions: ({ document, variables, operationName, result }) => { 45 | // console.log(print(document)); 46 | // console.log(variables); 47 | // console.log(result); 48 | // }, 49 | formatError: error => { 50 | console.log(error.message); 51 | console.log(error.locations); 52 | console.log(error.stack); 53 | 54 | return { 55 | message: error.message, 56 | locations: error.locations, 57 | stack: error.stack, 58 | }; 59 | }, 60 | }; 61 | }; 62 | 63 | const graphqlServer = graphqlHttp(graphqlSettingsPerReq); 64 | 65 | // graphql batch query route 66 | router.all('/graphql/batch', bodyParser(), graphqlBatchHttpWrapper(graphqlServer)); 67 | router.all('/graphql', graphqlServer); 68 | router.all( 69 | '/graphiql', 70 | graphiqlKoa({ 71 | endpointURL: '/graphql', 72 | subscriptionsEndpoint: `ws://localhost:${graphqlPort}/subscriptions`, 73 | }), 74 | ); 75 | router.all( 76 | '/playground', 77 | koaPlayground({ 78 | endpoint: '/graphql', 79 | }), 80 | ); 81 | 82 | app.use(logger()); 83 | app.use(cors()); 84 | app.use(router.routes()).use(router.allowedMethods()); 85 | 86 | export default app; 87 | -------------------------------------------------------------------------------- /flow-typed/npm/eslint-config-airbnb_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 216e3488c87bcd849b648fbf5c48e83b 2 | // flow-typed version: <>/eslint-config-airbnb_v^15.0.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'eslint-config-airbnb' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'eslint-config-airbnb' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'eslint-config-airbnb/base' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'eslint-config-airbnb/legacy' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'eslint-config-airbnb/rules/react-a11y' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'eslint-config-airbnb/rules/react' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'eslint-config-airbnb/test/test-base' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'eslint-config-airbnb/test/test-react-order' { 46 | declare module.exports: any; 47 | } 48 | 49 | // Filename aliases 50 | declare module 'eslint-config-airbnb/base.js' { 51 | declare module.exports: $Exports<'eslint-config-airbnb/base'>; 52 | } 53 | declare module 'eslint-config-airbnb/index' { 54 | declare module.exports: $Exports<'eslint-config-airbnb'>; 55 | } 56 | declare module 'eslint-config-airbnb/index.js' { 57 | declare module.exports: $Exports<'eslint-config-airbnb'>; 58 | } 59 | declare module 'eslint-config-airbnb/legacy.js' { 60 | declare module.exports: $Exports<'eslint-config-airbnb/legacy'>; 61 | } 62 | declare module 'eslint-config-airbnb/rules/react-a11y.js' { 63 | declare module.exports: $Exports<'eslint-config-airbnb/rules/react-a11y'>; 64 | } 65 | declare module 'eslint-config-airbnb/rules/react.js' { 66 | declare module.exports: $Exports<'eslint-config-airbnb/rules/react'>; 67 | } 68 | declare module 'eslint-config-airbnb/test/test-base.js' { 69 | declare module.exports: $Exports<'eslint-config-airbnb/test/test-base'>; 70 | } 71 | declare module 'eslint-config-airbnb/test/test-react-order.js' { 72 | declare module.exports: $Exports<'eslint-config-airbnb/test/test-react-order'>; 73 | } 74 | -------------------------------------------------------------------------------- /src/mutation/EventAddMutation.js: -------------------------------------------------------------------------------- 1 | import { GraphQLString, GraphQLNonNull, GraphQLInputObjectType, GraphQLList, GraphQLFloat } from 'graphql'; 2 | 3 | import { mutationWithClientMutationId } from 'graphql-relay'; 4 | 5 | import { Event as EventModel } from '../model'; 6 | import EventType from '../type/EventType'; 7 | import type { EventType as EvType } from '../loader/EventLoader'; 8 | import type { GraphQLContext } from '../TypeDefinition'; 9 | import LocationInputType from './LocationInputType'; 10 | import ScheduleInputType from './ScheduleInputType'; 11 | 12 | type Output = { 13 | message: string, 14 | error: string, 15 | }; 16 | 17 | export default mutationWithClientMutationId({ 18 | name: 'EventAdd', 19 | inputFields: { 20 | title: { 21 | type: GraphQLNonNull(GraphQLString), 22 | description: 'event title', 23 | }, 24 | description: { 25 | type: GraphQLString, 26 | description: 'event description', 27 | }, 28 | date: { 29 | type: GraphQLNonNull(GraphQLString), 30 | description: 'event date', 31 | }, 32 | publicLimit: { 33 | type: GraphQLString, 34 | description: 'event date', 35 | }, 36 | image: { 37 | type: GraphQLString, 38 | description: 'event image', 39 | }, 40 | location: { 41 | type: LocationInputType, 42 | }, 43 | schedule: { 44 | type: GraphQLList(ScheduleInputType), 45 | }, 46 | }, 47 | mutateAndGetPayload: async (args: EvType, context: GraphQLContext) => { 48 | const { user } = context; 49 | if (!user) { 50 | throw new Error('invalid user'); 51 | } 52 | 53 | const { title } = args; 54 | 55 | // @TODO improve validation logic 56 | if (!title.trim() || title.trim().length < 2) { 57 | return { 58 | message: 'Invalid title', 59 | error: 'INVALID_TITLE', 60 | }; 61 | } 62 | 63 | // Create new record 64 | const data = new EventModel({ 65 | ...args, 66 | createdBy: user._id, 67 | }); 68 | const event = await data.save(); 69 | 70 | // return event; 71 | return { 72 | message: 'Event created with success', 73 | error: null, 74 | event, 75 | }; 76 | }, 77 | outputFields: { 78 | message: { 79 | type: GraphQLString, 80 | resolve: ({ message }: Output) => message, 81 | }, 82 | error: { 83 | type: GraphQLString, 84 | resolve: ({ error }: Output) => error, 85 | }, 86 | event: { 87 | type: EventType, 88 | resolve: ({ event }) => event, 89 | }, 90 | }, 91 | }); 92 | -------------------------------------------------------------------------------- /src/mutation/EventEditMutation.js: -------------------------------------------------------------------------------- 1 | import { GraphQLID, GraphQLString, GraphQLNonNull, GraphQLInputObjectType, GraphQLList, GraphQLFloat } from 'graphql'; 2 | 3 | import { mutationWithClientMutationId, fromGlobalId } from 'graphql-relay'; 4 | 5 | import { Event as EventModel } from '../model'; 6 | import EventType from '../type/EventType'; 7 | import type { EventType as EvType } from '../loader/EventLoader'; 8 | import type { GraphQLContext } from '../TypeDefinition'; 9 | import LocationInputType from './LocationInputType'; 10 | import ScheduleInputType from './ScheduleInputType'; 11 | 12 | type Output = { 13 | message: string, 14 | error: string, 15 | }; 16 | 17 | export default mutationWithClientMutationId({ 18 | name: 'EventEdit', 19 | inputFields: { 20 | id: { 21 | type: GraphQLNonNull(GraphQLID), 22 | description: 'event title', 23 | }, 24 | title: { 25 | type: GraphQLNonNull(GraphQLString), 26 | description: 'event title', 27 | }, 28 | description: { 29 | type: GraphQLString, 30 | description: 'event description', 31 | }, 32 | date: { 33 | type: GraphQLNonNull(GraphQLString), 34 | description: 'event date', 35 | }, 36 | publicLimit: { 37 | type: GraphQLString, 38 | description: 'event date', 39 | }, 40 | image: { 41 | type: GraphQLString, 42 | description: 'event image', 43 | }, 44 | location: { 45 | type: LocationInputType, 46 | }, 47 | schedule: { 48 | type: GraphQLList(ScheduleInputType), 49 | }, 50 | }, 51 | mutateAndGetPayload: async (args: EvType, context: GraphQLContext) => { 52 | const { user } = context; 53 | if (!user) { 54 | throw new Error('invalid user'); 55 | } 56 | 57 | const { title, id } = args; 58 | 59 | // @TODO improve validation logic 60 | if (!title.trim() || title.trim().length < 2) { 61 | return { 62 | message: 'Invalid title', 63 | error: 'INVALID_TITLE', 64 | }; 65 | } 66 | 67 | // Create new record 68 | const event = await EventModel.findOne({ _id: fromGlobalId(id).id }); 69 | await event 70 | .set({ 71 | ...args, 72 | }) 73 | .save(); 74 | 75 | // return event; 76 | return { 77 | message: 'Event edited with success', 78 | error: null, 79 | event, 80 | }; 81 | }, 82 | outputFields: { 83 | message: { 84 | type: GraphQLString, 85 | resolve: ({ message }: Output) => message, 86 | }, 87 | error: { 88 | type: GraphQLString, 89 | resolve: ({ error }: Output) => error, 90 | }, 91 | event: { 92 | type: EventType, 93 | resolve: ({ event }) => event, 94 | }, 95 | }, 96 | }); 97 | -------------------------------------------------------------------------------- /src/mutation/__tests__/ChangePasswordMutation.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../model'; 6 | import { generateToken } from '../../auth'; 7 | import { 8 | getContext, 9 | setupTest, 10 | } from '../../../test/helper'; 11 | 12 | beforeEach(async () => await setupTest()); 13 | 14 | it('should not change password of non authorized user', async () => { 15 | //language=GraphQL 16 | const query = ` 17 | mutation M { 18 | ChangePassword(input: { 19 | clientMutationId: "abc" 20 | oldPassword: "old" 21 | password: "new" 22 | }) { 23 | clientMutationId 24 | error 25 | } 26 | } 27 | `; 28 | 29 | const rootValue = {}; 30 | const context = getContext(); 31 | 32 | const result = await graphql(schema, query, rootValue, context); 33 | const { errors } = result; 34 | 35 | expect(errors.length).toBe(1) 36 | expect(errors[0].message).toBe('invalid user'); 37 | }); 38 | 39 | it('should not change password if oldPassword is invalid', async () => { 40 | const user = new User({ 41 | name: 'user', 42 | email: 'awesome@example.com', 43 | password: 'awesome', 44 | }); 45 | await user.save(); 46 | 47 | //language=GraphQL 48 | const query = ` 49 | mutation M { 50 | ChangePassword(input: { 51 | clientMutationId: "abc" 52 | oldPassword: "old" 53 | password: "new" 54 | }) { 55 | clientMutationId 56 | error 57 | } 58 | } 59 | `; 60 | 61 | const rootValue = {}; 62 | const context = getContext({ user }); 63 | 64 | const result = await graphql(schema, query, rootValue, context); 65 | const { ChangePassword } = result.data; 66 | 67 | expect(ChangePassword.error).toBe('INVALID_PASSWORD'); 68 | }); 69 | 70 | it('should change password if oldPassword is correct', async () => { 71 | const password = 'awesome'; 72 | 73 | const user = new User({ 74 | name: 'user', 75 | email: 'awesome@example.com', 76 | password, 77 | }); 78 | await user.save(); 79 | 80 | //language=GraphQL 81 | const query = ` 82 | mutation M { 83 | ChangePassword(input: { 84 | clientMutationId: "abc" 85 | oldPassword: "${password}" 86 | password: "new" 87 | }) { 88 | clientMutationId 89 | error 90 | } 91 | } 92 | `; 93 | 94 | const rootValue = {}; 95 | const context = getContext({ user }); 96 | 97 | const result = await graphql(schema, query, rootValue, context); 98 | const { ChangePassword } = result.data; 99 | 100 | expect(ChangePassword.error).toBe(null); 101 | }); 102 | -------------------------------------------------------------------------------- /flow-typed/npm/graphql-relay_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 1a203c9536ec8469be9ca5d234428f2c 2 | // flow-typed version: <>/graphql-relay_v^0.5.1/flow_v0.44.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'graphql-relay' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'graphql-relay' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'graphql-relay/lib/connection/arrayconnection' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'graphql-relay/lib/connection/connection' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'graphql-relay/lib/connection/connectiontypes' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'graphql-relay/lib/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'graphql-relay/lib/mutation/mutation' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'graphql-relay/lib/node/node' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'graphql-relay/lib/node/plural' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'graphql-relay/lib/utils/base64' { 54 | declare module.exports: any; 55 | } 56 | 57 | // Filename aliases 58 | declare module 'graphql-relay/lib/connection/arrayconnection.js' { 59 | declare module.exports: $Exports<'graphql-relay/lib/connection/arrayconnection'>; 60 | } 61 | declare module 'graphql-relay/lib/connection/connection.js' { 62 | declare module.exports: $Exports<'graphql-relay/lib/connection/connection'>; 63 | } 64 | declare module 'graphql-relay/lib/connection/connectiontypes.js' { 65 | declare module.exports: $Exports<'graphql-relay/lib/connection/connectiontypes'>; 66 | } 67 | declare module 'graphql-relay/lib/index.js' { 68 | declare module.exports: $Exports<'graphql-relay/lib/index'>; 69 | } 70 | declare module 'graphql-relay/lib/mutation/mutation.js' { 71 | declare module.exports: $Exports<'graphql-relay/lib/mutation/mutation'>; 72 | } 73 | declare module 'graphql-relay/lib/node/node.js' { 74 | declare module.exports: $Exports<'graphql-relay/lib/node/node'>; 75 | } 76 | declare module 'graphql-relay/lib/node/plural.js' { 77 | declare module.exports: $Exports<'graphql-relay/lib/node/plural'>; 78 | } 79 | declare module 'graphql-relay/lib/utils/base64.js' { 80 | declare module.exports: $Exports<'graphql-relay/lib/utils/base64'>; 81 | } 82 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-eslint_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 588520259adb70f153ddadc72115a81c 2 | // flow-typed version: <>/babel-eslint_v^7.2.2/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-eslint' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-eslint' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-eslint/babylon-to-espree/attachComments' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-eslint/babylon-to-espree/convertComments' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-eslint/babylon-to-espree/convertTemplateType' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-eslint/babylon-to-espree/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-eslint/babylon-to-espree/toAST' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-eslint/babylon-to-espree/toToken' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'babel-eslint/babylon-to-espree/toTokens' { 50 | declare module.exports: any; 51 | } 52 | 53 | // Filename aliases 54 | declare module 'babel-eslint/babylon-to-espree/attachComments.js' { 55 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/attachComments'>; 56 | } 57 | declare module 'babel-eslint/babylon-to-espree/convertComments.js' { 58 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/convertComments'>; 59 | } 60 | declare module 'babel-eslint/babylon-to-espree/convertTemplateType.js' { 61 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/convertTemplateType'>; 62 | } 63 | declare module 'babel-eslint/babylon-to-espree/index.js' { 64 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/index'>; 65 | } 66 | declare module 'babel-eslint/babylon-to-espree/toAST.js' { 67 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/toAST'>; 68 | } 69 | declare module 'babel-eslint/babylon-to-espree/toToken.js' { 70 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/toToken'>; 71 | } 72 | declare module 'babel-eslint/babylon-to-espree/toTokens.js' { 73 | declare module.exports: $Exports<'babel-eslint/babylon-to-espree/toTokens'>; 74 | } 75 | declare module 'babel-eslint/index' { 76 | declare module.exports: $Exports<'babel-eslint'>; 77 | } 78 | declare module 'babel-eslint/index.js' { 79 | declare module.exports: $Exports<'babel-eslint'>; 80 | } 81 | -------------------------------------------------------------------------------- /src/mutation/__tests__/LoginEmailMutation.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../model'; 6 | import { generateToken } from '../../auth'; 7 | import { 8 | getContext, 9 | setupTest, 10 | } from '../../../test/helper'; 11 | 12 | beforeEach(async () => await setupTest()); 13 | 14 | it('should not login if email is not in the database', async () => { 15 | //language=GraphQL 16 | const query = ` 17 | mutation M { 18 | LoginEmail(input: { 19 | clientMutationId: "abc" 20 | email: "awesome@example.com" 21 | password: "awesome" 22 | }) { 23 | clientMutationId 24 | token 25 | error 26 | } 27 | } 28 | `; 29 | 30 | const rootValue = {}; 31 | const context = getContext(); 32 | 33 | const result = await graphql(schema, query, rootValue, context); 34 | const { LoginEmail } = result.data; 35 | 36 | 37 | expect(LoginEmail.token).toBe(null); 38 | expect(LoginEmail.error).toBe('INVALID_EMAIL_PASSWORD'); 39 | }); 40 | 41 | it('should not login with wrong email', async () => { 42 | const user = new User({ 43 | name: 'user', 44 | email: 'awesome@example.com', 45 | password: 'awesome', 46 | }); 47 | await user.save(); 48 | 49 | //language=GraphQL 50 | const query = ` 51 | mutation M { 52 | LoginEmail(input: { 53 | clientMutationId: "abc" 54 | email: "awesome@example.com" 55 | password: "notawesome" 56 | }) { 57 | clientMutationId 58 | token 59 | error 60 | } 61 | } 62 | `; 63 | 64 | const rootValue = {}; 65 | const context = getContext(); 66 | 67 | const result = await graphql(schema, query, rootValue, context); 68 | const { LoginEmail } = result.data; 69 | 70 | expect(LoginEmail.token).toBe(null); 71 | expect(LoginEmail.error).toBe('INVALID_EMAIL_PASSWORD'); 72 | }); 73 | 74 | it('should generate token when email and password is correct', async () => { 75 | const email = 'awesome@example.com'; 76 | const password = 'awesome'; 77 | 78 | const user = new User({ 79 | name: 'user', 80 | email, 81 | password, 82 | }); 83 | await user.save(); 84 | 85 | //language=GraphQL 86 | const query = ` 87 | mutation M { 88 | LoginEmail(input: { 89 | clientMutationId: "abc" 90 | email: "${email}" 91 | password: "${password}" 92 | }) { 93 | clientMutationId 94 | token 95 | error 96 | } 97 | } 98 | `; 99 | 100 | const rootValue = {}; 101 | const context = getContext(); 102 | 103 | const result = await graphql(schema, query, rootValue, context); 104 | const { LoginEmail } = result.data; 105 | 106 | expect(LoginEmail.token).toBe(generateToken(user)); 107 | expect(LoginEmail.error).toBe(null); 108 | }); 109 | -------------------------------------------------------------------------------- /src/type/QueryType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLObjectType, 5 | GraphQLString, 6 | GraphQLNonNull, 7 | GraphQLID, 8 | GraphQLList, 9 | GraphQLFloat, 10 | GraphQLInt, 11 | } from 'graphql'; 12 | import { connectionArgs, fromGlobalId } from 'graphql-relay'; 13 | import { NodeField } from '../interface/NodeInterface'; 14 | 15 | import UserType from './UserType'; 16 | import EventType from './EventType'; 17 | import { UserLoader, EventLoader } from '../loader'; 18 | import UserConnection from '../connection/UserConnection'; 19 | import EventsConnection from '../connection/EventsConnection'; 20 | 21 | import type { GraphQLContext } from '../TypeDefinition'; 22 | import type { EventType as EventPayload } from '../loader/EventLoader'; 23 | import type { UserType as UserPayload } from '../loader/UserLoader'; 24 | 25 | type ConectionArguments = { 26 | search: string, 27 | first: number, 28 | after: String, 29 | last: number, 30 | before: string, 31 | }; 32 | 33 | type LoadByIdArgs = { 34 | id: string, 35 | }; 36 | 37 | export default new GraphQLObjectType({ 38 | name: 'Query', 39 | description: 'The root of all... queries', 40 | fields: () => ({ 41 | node: NodeField, 42 | me: { 43 | type: UserType, 44 | resolve: (root: UserPayload, args: void, context: GraphQLContext) => 45 | context.user ? UserLoader.load(context, context.user._id) : null, 46 | }, 47 | events: { 48 | type: EventsConnection.connectionType, 49 | args: { 50 | ...connectionArgs, 51 | search: { 52 | type: GraphQLString, 53 | }, 54 | distance: { 55 | type: GraphQLInt, 56 | }, 57 | days: { 58 | type: GraphQLInt, 59 | }, 60 | coordinates: { 61 | type: new GraphQLList(GraphQLFloat), 62 | }, 63 | }, 64 | resolve: (obj: EventPayload, args: ConectionArguments, context: GraphQLContext) => 65 | EventLoader.loadEvents(context, args), 66 | }, 67 | event: { 68 | type: EventType, 69 | args: { 70 | id: { 71 | type: GraphQLID, 72 | }, 73 | }, 74 | resolve: (obj: EventPayload, args: LoadByIdArgs, context: GraphQLContext) => { 75 | const { id } = fromGlobalId(args.id); 76 | return EventLoader.load(context, id); 77 | }, 78 | }, 79 | user: { 80 | type: UserType, 81 | args: { 82 | id: { 83 | type: new GraphQLNonNull(GraphQLID), 84 | }, 85 | }, 86 | resolve: (obj: UserPayload, args: LoadByIdArgs, context: GraphQLContext) => { 87 | const { id } = fromGlobalId(args.id); 88 | return UserLoader.load(context, id); 89 | }, 90 | }, 91 | users: { 92 | type: UserConnection.connectionType, 93 | args: { 94 | ...connectionArgs, 95 | search: { 96 | type: GraphQLString, 97 | }, 98 | }, 99 | resolve: (obj: UserPayload, args: ConectionArguments, context: GraphQLContext) => 100 | UserLoader.loadUsers(context, args), 101 | }, 102 | }), 103 | }); 104 | -------------------------------------------------------------------------------- /src/type/EventType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLBoolean } from 'graphql'; 4 | import { globalIdField } from 'graphql-relay'; 5 | import { NodeInterface } from '../interface/NodeInterface'; 6 | import ScheduleType from './ScheduleType'; 7 | import UserType from './UserType'; 8 | import { UserLoader } from '../loader'; 9 | import type { EventType } from '../loader/EventLoader'; 10 | import LocationType from './LocationType'; 11 | 12 | export default new GraphQLObjectType({ 13 | name: 'Event', 14 | description: 'Event data', 15 | fields: () => ({ 16 | id: globalIdField('Event'), 17 | _id: { 18 | type: GraphQLString, 19 | resolve: (obj: EventType) => obj._id, 20 | }, 21 | title: { 22 | type: GraphQLString, 23 | resolve: (obj: EventType) => obj.title, 24 | }, 25 | description: { 26 | type: GraphQLString, 27 | resolve: (obj: EventType) => obj.description, 28 | }, 29 | date: { 30 | type: GraphQLString, 31 | resolve: (obj: EventType) => obj.date, 32 | }, 33 | location: { 34 | type: LocationType, 35 | resolve: obj => obj.location, 36 | }, 37 | publicLimit: { 38 | type: GraphQLString, 39 | resolve: (obj: EventType) => obj.publicLimit, 40 | }, 41 | isOwner: { 42 | type: GraphQLString, 43 | resolve: (obj: EventType, args, context) => { 44 | const { user } = context; 45 | return obj.createdBy.equals(user._id); 46 | }, 47 | }, 48 | image: { 49 | type: GraphQLString, 50 | description: 'event image', 51 | resolve: (obj: EventType) => obj.image, 52 | }, 53 | schedule: { 54 | type: new GraphQLList(ScheduleType), 55 | description: 'schedule', 56 | resolve: (obj: EventType) => obj.schedule, 57 | }, 58 | publicList: { 59 | type: new GraphQLList(UserType), 60 | description: 'Users that attended to the event', 61 | resolve: (obj: EventType, args, context) => { 62 | const usersArray = obj.publicList.map(people => UserLoader.load(context, people)); 63 | return obj.publicList.length >= 1 ? usersArray : []; 64 | }, 65 | }, 66 | notGoingList: { 67 | type: new GraphQLList(UserType), 68 | description: 'Users that cant go to the event', 69 | resolve: (obj, args, context) => { 70 | const usersArray = obj.notGoingList.map(people => UserLoader.load(context, people)); 71 | return obj.notGoingList.length >= 1 ? usersArray : []; 72 | }, 73 | }, 74 | waitList: { 75 | type: new GraphQLList(UserType), 76 | description: 'Users that are waiting for places on the event', 77 | resolve: (obj, args, context) => { 78 | const usersArray = obj.waitList.map(people => UserLoader.load(context, people)); 79 | return obj.waitList.length >= 1 ? usersArray : []; 80 | }, 81 | }, 82 | isEventAttended: { 83 | type: GraphQLBoolean, 84 | description: 'Check if user attended to the event', 85 | resolve: (obj, args, context) => obj.publicList.includes(context.user._id.toString()), 86 | }, 87 | }), 88 | interfaces: () => [NodeInterface], 89 | }); 90 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-cli_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 2be8d574e9f7030854fc60dac99e21af 2 | // flow-typed version: <>/babel-cli_v^6.24.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-cli' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-cli' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-cli/bin/babel-doctor' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-cli/bin/babel-external-helpers' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-cli/bin/babel-node' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-cli/bin/babel' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-cli/lib/_babel-node' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-cli/lib/babel-external-helpers' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'babel-cli/lib/babel-node' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'babel-cli/lib/babel/dir' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'babel-cli/lib/babel/file' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'babel-cli/lib/babel/index' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'babel-cli/lib/babel/util' { 66 | declare module.exports: any; 67 | } 68 | 69 | // Filename aliases 70 | declare module 'babel-cli/bin/babel-doctor.js' { 71 | declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>; 72 | } 73 | declare module 'babel-cli/bin/babel-external-helpers.js' { 74 | declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>; 75 | } 76 | declare module 'babel-cli/bin/babel-node.js' { 77 | declare module.exports: $Exports<'babel-cli/bin/babel-node'>; 78 | } 79 | declare module 'babel-cli/bin/babel.js' { 80 | declare module.exports: $Exports<'babel-cli/bin/babel'>; 81 | } 82 | declare module 'babel-cli/index' { 83 | declare module.exports: $Exports<'babel-cli'>; 84 | } 85 | declare module 'babel-cli/index.js' { 86 | declare module.exports: $Exports<'babel-cli'>; 87 | } 88 | declare module 'babel-cli/lib/_babel-node.js' { 89 | declare module.exports: $Exports<'babel-cli/lib/_babel-node'>; 90 | } 91 | declare module 'babel-cli/lib/babel-external-helpers.js' { 92 | declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>; 93 | } 94 | declare module 'babel-cli/lib/babel-node.js' { 95 | declare module.exports: $Exports<'babel-cli/lib/babel-node'>; 96 | } 97 | declare module 'babel-cli/lib/babel/dir.js' { 98 | declare module.exports: $Exports<'babel-cli/lib/babel/dir'>; 99 | } 100 | declare module 'babel-cli/lib/babel/file.js' { 101 | declare module.exports: $Exports<'babel-cli/lib/babel/file'>; 102 | } 103 | declare module 'babel-cli/lib/babel/index.js' { 104 | declare module.exports: $Exports<'babel-cli/lib/babel/index'>; 105 | } 106 | declare module 'babel-cli/lib/babel/util.js' { 107 | declare module.exports: $Exports<'babel-cli/lib/babel/util'>; 108 | } 109 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-dataloader-boilerplate", 3 | "description": "GraphQL DataLoader boilerplate", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "@entria/graphql-mongoose-loader": "^1.1.1", 7 | "apollo-server-koa": "^1.3.2", 8 | "babel-polyfill": "^6.26.0", 9 | "bcryptjs": "^2.4.3", 10 | "dataloader": "^1.4.0", 11 | "dotenv-safe": "^4.0.4", 12 | "fs-extra-promise": "^1.0.1", 13 | "graphql": "^0.13.1", 14 | "graphql-playground-middleware": "^1.1.2", 15 | "graphql-relay": "^0.5.4", 16 | "graphql-subscriptions": "^0.5.8", 17 | "idx": "^2.3.0", 18 | "isomorphic-fetch": "^2.2.1", 19 | "jsonwebtoken": "^8.1.0", 20 | "kcors": "^2.2.1", 21 | "koa": "^2.5.0", 22 | "koa-bodyparser": "^4.2.0", 23 | "koa-compose": "^4.0.0", 24 | "koa-convert": "^1.2.0", 25 | "koa-graphql": "^0.7.5", 26 | "koa-graphql-batch": "^1.1.0", 27 | "koa-logger": "^3.1.0", 28 | "koa-router": "^7.4.0", 29 | "mongoose": "^5.0.8", 30 | "subscriptions-transport-ws": "^0.9.6", 31 | "rimraf": "^2.6.2" 32 | }, 33 | "devDependencies": { 34 | "babel-cli": "^6.26.0", 35 | "babel-eslint": "^8.2.2", 36 | "babel-plugin-transform-async-to-generator": "^6.24.1", 37 | "babel-plugin-transform-class-properties": "^6.24.1", 38 | "babel-plugin-transform-export-extensions": "^6.22.0", 39 | "babel-plugin-transform-flow-strip-types": "^6.22.0", 40 | "babel-plugin-transform-object-rest-spread": "^6.26.0", 41 | "babel-preset-env": "^1.6.1", 42 | "babel-preset-es2015": "^6.24.1", 43 | "babel-preset-flow": "^6.23.0", 44 | "babel-preset-stage-0": "^6.24.1", 45 | "eslint": "^4.14.0", 46 | "eslint-config-airbnb": "^16.1.0", 47 | "eslint-plugin-import": "^2.8.0", 48 | "esm": "^3.0.5", 49 | "flow-bin": "^0.66.0", 50 | "husky": "^0.14.3", 51 | "jest": "22.4.2", 52 | "jest-cli": "22.4.2", 53 | "lint-staged": "6.0.0", 54 | "nodemon": "^1.17.1", 55 | "prettier": "^1.11.1", 56 | "repl": "^0.1.3", 57 | "repl-promised": "^0.1.0", 58 | "repl.history": "^0.1.4" 59 | }, 60 | "jest": { 61 | "testEnvironment": "node", 62 | "testPathIgnorePatterns": [ 63 | "/node_modules/", 64 | "./dist" 65 | ], 66 | "coverageReporters": [ 67 | "lcov", 68 | "html" 69 | ], 70 | "coverageDirectory": "./coverage/", 71 | "collectCoverage": true, 72 | "moduleNameMapper": { 73 | "^mongoose$": "/node_modules/mongoose" 74 | }, 75 | "setupFiles": [ 76 | "babel-polyfill" 77 | ] 78 | }, 79 | "license": "MIT", 80 | "main": "index.js", 81 | "repository": { 82 | "type": "git", 83 | "url": "https://github.com/entria/graphql-dataloader-boilerplate" 84 | }, 85 | "lint-staged": { 86 | "*.js": [ 87 | "prettier --write --single-quote true --trailing-comma all --print-width 120", 88 | "git add" 89 | ] 90 | }, 91 | "scripts": { 92 | "build": "npm run clear && babel src --ignore *.spec.js --out-dir dist --copy-files", 93 | "clear": "rimraf ./dist", 94 | "flow": "flow; test $? -eq 0 -o $? -eq 2", 95 | "lint": "eslint src/**", 96 | "precommit": "lint-staged", 97 | "repl": "nodemon --config ./repl/nodemon.json ./repl.js --exec babel-node", 98 | "start": "yarn build && node dist/index.js", 99 | "test": "jest --coverage --forceExit --runInBand", 100 | "test:watch": "jest --watch --coverage", 101 | "deploy": "git push heroku master", 102 | "copy-to-project": "babel-node ./scripts/copySchemaToProject.js", 103 | "update-schema": "babel-node ./scripts/updateSchema.js && npm run copy-to-project", 104 | "graphql": "nodemon src/index.js --exec babel-node" 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /#package.json#: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-dataloader-boilerplate", 3 | "description": "GraphQL DataLoader boilerplate", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "@entria/graphql-mongoose-loader": "^1.1.1", 7 | "apollo-server-koa": "^1.3.2", 8 | "babel-polyfill": "^6.26.0", 9 | "bcryptjs": "^2.4.3", 10 | "dataloader": "^1.4.0", 11 | "dotenv-safe": "^4.0.4", 12 | "fs-extra-promise": "^1.0.1", 13 | "graphql": "^0.13.1", 14 | "graphql-playground-middleware": "^1.1.2", 15 | "graphql-relay": "^0.5.4", 16 | "graphql-subscriptions": "^0.5.8", 17 | "idx": "^2.3.0", 18 | "isomorphic-fetch": "^2.2.1", 19 | "jsonwebtoken": "^8.1.0", 20 | "kcors": "^2.2.1", 21 | "koa": "^2.5.0", 22 | "koa-bodyparser": "^4.2.0", 23 | "koa-compose": "^4.0.0", 24 | "koa-convert": "^1.2.0", 25 | "koa-graphql": "^0.7.5", 26 | "koa-graphql-batch": "^1.1.0", 27 | "koa-logger": "^3.1.0", 28 | "koa-router": "^7.4.0", 29 | "mongoose": "^5.0.8", 30 | "subscriptions-transport-ws": "^0.9.6" 31 | }, 32 | "devDependencies": { 33 | "babel-cli": "^6.26.0", 34 | "babel-eslint": "^8.2.2", 35 | "babel-plugin-transform-async-to-generator": "^6.24.1", 36 | "babel-plugin-transform-class-properties": "^6.24.1", 37 | "babel-plugin-transform-export-extensions": "^6.22.0", 38 | "babel-plugin-transform-flow-strip-types": "^6.22.0", 39 | "babel-plugin-transform-object-rest-spread": "^6.26.0", 40 | "babel-preset-env": "^1.6.1", 41 | "babel-preset-es2015": "^6.24.1", 42 | "babel-preset-flow": "^6.23.0", 43 | "babel-preset-stage-0": "^6.24.1", 44 | "eslint": "^4.14.0", 45 | "eslint-config-airbnb": "^16.1.0", 46 | "eslint-plugin-import": "^2.8.0", 47 | "esm": "^3.0.5", 48 | "flow-bin": "^0.66.0", 49 | "husky": "^0.14.3", 50 | "jest": "22.4.2", 51 | "jest-cli": "22.4.2", 52 | "lint-staged": "6.0.0", 53 | "nodemon": "^1.17.1", 54 | "prettier": "^1.11.1", 55 | "repl": "^0.1.3", 56 | "repl-promised": "^0.1.0", 57 | "repl.history": "^0.1.4", 58 | "rimraf": "^2.6.2" 59 | }, 60 | "jest": { 61 | "testEnvironment": "node", 62 | "testPathIgnorePatterns": [ 63 | "/node_modules/", 64 | "./dist" 65 | ], 66 | "coverageReporters": [ 67 | "lcov", 68 | "html" 69 | ], 70 | "coverageDirectory": "./coverage/", 71 | "collectCoverage": true, 72 | "moduleNameMapper": { 73 | "^mongoose$": "/node_modules/mongoose" 74 | }, 75 | "setupFiles": [ 76 | "babel-polyfill" 77 | ] 78 | }, 79 | "license": "MIT", 80 | "main": "index.js", 81 | "repository": { 82 | "type": "git", 83 | "url": "https://github.com/entria/graphql-dataloader-boilerplate" 84 | }, 85 | "lint-staged": { 86 | "*.js": [ 87 | "prettier --write --single-quote true --trailing-comma all --print-width 120", 88 | "git add" 89 | ] 90 | }, 91 | "scripts": { 92 | "build": "npm run clear && babel src --ignore *.spec.js --out-dir dist --copy-files", 93 | "clear": "rimraf ./dist", 94 | "flow": "flow; test $? -eq 0 -o $? -eq 2", 95 | "lint": "eslint src/**", 96 | "precommit": "lint-staged", 97 | "repl": "nodemon --config ./repl/nodemon.json ./repl.js --exec babel-node", 98 | "start": "node dist/index.js", 99 | "test": "jest --coverage --forceExit --runInBand", 100 | "test:watch": "jest --watch --coverage", 101 | "deploy": "cp .env.prod .env && git push heroku master && cp .env.dev .env", 102 | "copy-to-project": "babel-node ./scripts/copySchemaToProject.js", 103 | "update-schema": "babel-node ./scripts/updateSchema.js && npm run copy-to-project", 104 | "graphql": "nodemon src/index.js --exec babel-node" 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /flow-typed/npm/bcryptjs_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 537895aa4930204571ad8edb73424908 2 | // flow-typed version: <>/bcryptjs_v^2.4.3/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'bcryptjs' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'bcryptjs' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'bcryptjs/dist/bcrypt' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'bcryptjs/dist/bcrypt.min' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'bcryptjs/externs/bcrypt' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'bcryptjs/externs/minimal-env' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'bcryptjs/scripts/build' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'bcryptjs/src/bcrypt' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'bcryptjs/src/bcrypt/impl' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'bcryptjs/src/bcrypt/prng/accum' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'bcryptjs/src/bcrypt/prng/isaac' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'bcryptjs/src/bcrypt/util' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'bcryptjs/src/bcrypt/util/base64' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'bcryptjs/src/wrap' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'bcryptjs/tests/suite' { 74 | declare module.exports: any; 75 | } 76 | 77 | // Filename aliases 78 | declare module 'bcryptjs/dist/bcrypt.js' { 79 | declare module.exports: $Exports<'bcryptjs/dist/bcrypt'>; 80 | } 81 | declare module 'bcryptjs/dist/bcrypt.min.js' { 82 | declare module.exports: $Exports<'bcryptjs/dist/bcrypt.min'>; 83 | } 84 | declare module 'bcryptjs/externs/bcrypt.js' { 85 | declare module.exports: $Exports<'bcryptjs/externs/bcrypt'>; 86 | } 87 | declare module 'bcryptjs/externs/minimal-env.js' { 88 | declare module.exports: $Exports<'bcryptjs/externs/minimal-env'>; 89 | } 90 | declare module 'bcryptjs/index' { 91 | declare module.exports: $Exports<'bcryptjs'>; 92 | } 93 | declare module 'bcryptjs/index.js' { 94 | declare module.exports: $Exports<'bcryptjs'>; 95 | } 96 | declare module 'bcryptjs/scripts/build.js' { 97 | declare module.exports: $Exports<'bcryptjs/scripts/build'>; 98 | } 99 | declare module 'bcryptjs/src/bcrypt.js' { 100 | declare module.exports: $Exports<'bcryptjs/src/bcrypt'>; 101 | } 102 | declare module 'bcryptjs/src/bcrypt/impl.js' { 103 | declare module.exports: $Exports<'bcryptjs/src/bcrypt/impl'>; 104 | } 105 | declare module 'bcryptjs/src/bcrypt/prng/accum.js' { 106 | declare module.exports: $Exports<'bcryptjs/src/bcrypt/prng/accum'>; 107 | } 108 | declare module 'bcryptjs/src/bcrypt/prng/isaac.js' { 109 | declare module.exports: $Exports<'bcryptjs/src/bcrypt/prng/isaac'>; 110 | } 111 | declare module 'bcryptjs/src/bcrypt/util.js' { 112 | declare module.exports: $Exports<'bcryptjs/src/bcrypt/util'>; 113 | } 114 | declare module 'bcryptjs/src/bcrypt/util/base64.js' { 115 | declare module.exports: $Exports<'bcryptjs/src/bcrypt/util/base64'>; 116 | } 117 | declare module 'bcryptjs/src/wrap.js' { 118 | declare module.exports: $Exports<'bcryptjs/src/wrap'>; 119 | } 120 | declare module 'bcryptjs/tests/suite.js' { 121 | declare module.exports: $Exports<'bcryptjs/tests/suite'>; 122 | } 123 | -------------------------------------------------------------------------------- /src/loader/EventLoader.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import DataLoader from 'dataloader'; 3 | import { Event as EventModel } from '../model'; 4 | import { connectionFromMongoCursor, mongooseLoader } from '@entria/graphql-mongoose-loader'; 5 | import idx from 'idx'; 6 | import type { ConnectionArguments } from 'graphql-relay'; 7 | import type { ObjectId } from 'mongoose'; 8 | 9 | import type { GraphQLContext } from '../TypeDefinition'; 10 | 11 | type Schedule = { 12 | talker: string, 13 | title: string, 14 | description: string, 15 | time: number, 16 | }; 17 | 18 | type LocationType = { 19 | coordinates: Array, 20 | cep: string, 21 | type: string, 22 | street: string, 23 | number: string, 24 | }; 25 | 26 | export type EventType = { 27 | id: string, 28 | _id: ObjectId, 29 | image: string, 30 | title: string, 31 | description: string, 32 | date: string, 33 | publicLimit: string, 34 | active: boolean, 35 | schedule: Array, 36 | location: LocationType, 37 | publicList: Array, 38 | waitList: Array, 39 | notGoingList: Array, 40 | createdBy: ObjectId, 41 | }; 42 | 43 | export default class Event { 44 | id: string; 45 | _id: ObjectId; 46 | image: string; 47 | title: string; 48 | description: string; 49 | date: string; 50 | publicLimit: string; 51 | active: boolean; 52 | schedule: Array; 53 | publicList: Array; 54 | waitList: Array; 55 | notGoingList: Array; 56 | location: LocationType; 57 | createdBy: ObjectId; 58 | 59 | constructor(data: EventType) { 60 | this.id = data.id; 61 | this._id = data._id; 62 | this.image = data.image; 63 | this.title = data.title; 64 | this.description = data.description; 65 | this.date = data.date; 66 | this.publicLimit = data.publicLimit; 67 | this.active = data.active; 68 | this.schedule = data.schedule; 69 | this.publicList = data.publicList; 70 | this.location = data.location; 71 | this.waitList = data.waitList; 72 | this.notGoingList = data.notGoingList; 73 | this.createdBy = data.createdBy; 74 | } 75 | } 76 | 77 | export const getLoader = () => new DataLoader(ids => mongooseLoader(EventModel, ids)); 78 | 79 | const viewerCanSee = (context, data) => 80 | // Anyone can see another user 81 | true; 82 | 83 | export const load = async (context: GraphQLContext, id: string): Promise => { 84 | if (!id) { 85 | return null; 86 | } 87 | 88 | let data; 89 | try { 90 | data = await context.dataloaders.EventLoader.load(id); 91 | } catch (err) { 92 | return null; 93 | } 94 | return viewerCanSee(context, data) ? new Event(data, context) : null; 95 | }; 96 | 97 | export const clearCache = ({ dataloaders }: GraphQLContext, id: string) => dataloaders.EventLoader.clear(id.toString()); 98 | 99 | export const loadEvents = async (context: GraphQLContext, args: ConnectionArguments) => { 100 | let conditions = {}; 101 | 102 | if (args.search) { 103 | conditions = { 104 | ...conditions, 105 | title: { 106 | $regex: new RegExp(`${args.search}`, 'ig'), 107 | }, 108 | }; 109 | } 110 | 111 | if (args.distance && idx(args, _ => _.coordinates[0])) { 112 | const longitude = args.coordinates[0]; 113 | const latitude = args.coordinates[1]; 114 | 115 | conditions = { 116 | ...conditions, 117 | location: { 118 | $near: { 119 | $geometry: { 120 | coordinates: [longitude, latitude], 121 | type: 'Point', 122 | }, 123 | $maxDistance: args.distance, 124 | $minDistance: 0, 125 | }, 126 | }, 127 | }; 128 | } 129 | 130 | console.log('args***', args); 131 | const events = EventModel.find(conditions).sort({ createdAt: -1 }); 132 | 133 | return connectionFromMongoCursor({ 134 | cursor: events, 135 | context, 136 | args, 137 | loader: load, 138 | }); 139 | }; 140 | -------------------------------------------------------------------------------- /flow-typed/npm/nodemon_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: faa11cb3895776055d93ab538a997ead 2 | // flow-typed version: <>/nodemon_v^1.10.2/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'nodemon' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'nodemon' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'nodemon/bin/nodemon' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'nodemon/lib/cli/index' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'nodemon/lib/cli/parse' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'nodemon/lib/config/command' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'nodemon/lib/config/defaults' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'nodemon/lib/config/exec' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'nodemon/lib/config/index' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'nodemon/lib/config/load' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'nodemon/lib/help/index' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'nodemon/lib/index' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'nodemon/lib/monitor/index' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'nodemon/lib/monitor/match' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'nodemon/lib/monitor/run' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'nodemon/lib/monitor/watch' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'nodemon/lib/nodemon' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'nodemon/lib/rules/add' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'nodemon/lib/rules/index' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'nodemon/lib/rules/parse' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module 'nodemon/lib/spawn' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module 'nodemon/lib/utils/bus' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module 'nodemon/lib/utils/clone' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module 'nodemon/lib/utils/colour' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module 'nodemon/lib/utils/index' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module 'nodemon/lib/utils/log' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module 'nodemon/lib/utils/merge' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module 'nodemon/lib/version' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module 'nodemon/web/index' { 130 | declare module.exports: any; 131 | } 132 | 133 | // Filename aliases 134 | declare module 'nodemon/bin/nodemon.js' { 135 | declare module.exports: $Exports<'nodemon/bin/nodemon'>; 136 | } 137 | declare module 'nodemon/lib/cli/index.js' { 138 | declare module.exports: $Exports<'nodemon/lib/cli/index'>; 139 | } 140 | declare module 'nodemon/lib/cli/parse.js' { 141 | declare module.exports: $Exports<'nodemon/lib/cli/parse'>; 142 | } 143 | declare module 'nodemon/lib/config/command.js' { 144 | declare module.exports: $Exports<'nodemon/lib/config/command'>; 145 | } 146 | declare module 'nodemon/lib/config/defaults.js' { 147 | declare module.exports: $Exports<'nodemon/lib/config/defaults'>; 148 | } 149 | declare module 'nodemon/lib/config/exec.js' { 150 | declare module.exports: $Exports<'nodemon/lib/config/exec'>; 151 | } 152 | declare module 'nodemon/lib/config/index.js' { 153 | declare module.exports: $Exports<'nodemon/lib/config/index'>; 154 | } 155 | declare module 'nodemon/lib/config/load.js' { 156 | declare module.exports: $Exports<'nodemon/lib/config/load'>; 157 | } 158 | declare module 'nodemon/lib/help/index.js' { 159 | declare module.exports: $Exports<'nodemon/lib/help/index'>; 160 | } 161 | declare module 'nodemon/lib/index.js' { 162 | declare module.exports: $Exports<'nodemon/lib/index'>; 163 | } 164 | declare module 'nodemon/lib/monitor/index.js' { 165 | declare module.exports: $Exports<'nodemon/lib/monitor/index'>; 166 | } 167 | declare module 'nodemon/lib/monitor/match.js' { 168 | declare module.exports: $Exports<'nodemon/lib/monitor/match'>; 169 | } 170 | declare module 'nodemon/lib/monitor/run.js' { 171 | declare module.exports: $Exports<'nodemon/lib/monitor/run'>; 172 | } 173 | declare module 'nodemon/lib/monitor/watch.js' { 174 | declare module.exports: $Exports<'nodemon/lib/monitor/watch'>; 175 | } 176 | declare module 'nodemon/lib/nodemon.js' { 177 | declare module.exports: $Exports<'nodemon/lib/nodemon'>; 178 | } 179 | declare module 'nodemon/lib/rules/add.js' { 180 | declare module.exports: $Exports<'nodemon/lib/rules/add'>; 181 | } 182 | declare module 'nodemon/lib/rules/index.js' { 183 | declare module.exports: $Exports<'nodemon/lib/rules/index'>; 184 | } 185 | declare module 'nodemon/lib/rules/parse.js' { 186 | declare module.exports: $Exports<'nodemon/lib/rules/parse'>; 187 | } 188 | declare module 'nodemon/lib/spawn.js' { 189 | declare module.exports: $Exports<'nodemon/lib/spawn'>; 190 | } 191 | declare module 'nodemon/lib/utils/bus.js' { 192 | declare module.exports: $Exports<'nodemon/lib/utils/bus'>; 193 | } 194 | declare module 'nodemon/lib/utils/clone.js' { 195 | declare module.exports: $Exports<'nodemon/lib/utils/clone'>; 196 | } 197 | declare module 'nodemon/lib/utils/colour.js' { 198 | declare module.exports: $Exports<'nodemon/lib/utils/colour'>; 199 | } 200 | declare module 'nodemon/lib/utils/index.js' { 201 | declare module.exports: $Exports<'nodemon/lib/utils/index'>; 202 | } 203 | declare module 'nodemon/lib/utils/log.js' { 204 | declare module.exports: $Exports<'nodemon/lib/utils/log'>; 205 | } 206 | declare module 'nodemon/lib/utils/merge.js' { 207 | declare module.exports: $Exports<'nodemon/lib/utils/merge'>; 208 | } 209 | declare module 'nodemon/lib/version.js' { 210 | declare module.exports: $Exports<'nodemon/lib/version'>; 211 | } 212 | declare module 'nodemon/web/index.js' { 213 | declare module.exports: $Exports<'nodemon/web/index'>; 214 | } 215 | -------------------------------------------------------------------------------- /data/schema.graphql: -------------------------------------------------------------------------------- 1 | input AttendToEventInput { 2 | eventId: ID! 3 | clientMutationId: String 4 | } 5 | 6 | type AttendToEventPayload { 7 | message: String 8 | error: String 9 | clientMutationId: String 10 | } 11 | 12 | input CantGoToEventInput { 13 | eventId: ID! 14 | clientMutationId: String 15 | } 16 | 17 | type CantGoToEventPayload { 18 | message: String 19 | error: String 20 | clientMutationId: String 21 | } 22 | 23 | input ChangePasswordInput { 24 | oldPassword: String! 25 | 26 | """user new password""" 27 | password: String! 28 | clientMutationId: String 29 | } 30 | 31 | type ChangePasswordPayload { 32 | error: String 33 | me: User 34 | clientMutationId: String 35 | } 36 | 37 | """Event data""" 38 | type Event implements Node { 39 | """The ID of an object""" 40 | id: ID! 41 | _id: String 42 | title: String 43 | description: String 44 | date: String 45 | location: Location 46 | publicLimit: String 47 | isOwner: String 48 | 49 | """event image""" 50 | image: String 51 | 52 | """schedule""" 53 | schedule: [Schedule] 54 | 55 | """Users that attended to the event""" 56 | publicList: [User] 57 | 58 | """Users that cant go to the event""" 59 | notGoingList: [User] 60 | 61 | """Users that are waiting for places on the event""" 62 | waitList: [User] 63 | 64 | """Check if user attended to the event""" 65 | isEventAttended: Boolean 66 | } 67 | 68 | input EventAddInput { 69 | """event title""" 70 | title: String! 71 | 72 | """event description""" 73 | description: String 74 | 75 | """event date""" 76 | date: String! 77 | 78 | """event date""" 79 | publicLimit: String 80 | 81 | """event image""" 82 | image: String 83 | location: location 84 | schedule: [schedule] 85 | clientMutationId: String 86 | } 87 | 88 | type EventAddPayload { 89 | message: String 90 | error: String 91 | event: Event 92 | clientMutationId: String 93 | } 94 | 95 | """A connection to a list of items.""" 96 | type EventConnection { 97 | """Information to aid in pagination.""" 98 | pageInfo: PageInfo! 99 | 100 | """A list of edges.""" 101 | edges: [EventEdge] 102 | count: Int 103 | } 104 | 105 | """An edge in a connection.""" 106 | type EventEdge { 107 | """The item at the end of the edge""" 108 | node: Event 109 | 110 | """A cursor for use in pagination""" 111 | cursor: String! 112 | } 113 | 114 | input EventEditInput { 115 | """event title""" 116 | id: ID! 117 | 118 | """event title""" 119 | title: String! 120 | 121 | """event description""" 122 | description: String 123 | 124 | """event date""" 125 | date: String! 126 | 127 | """event date""" 128 | publicLimit: String 129 | 130 | """event image""" 131 | image: String 132 | location: location 133 | schedule: [schedule] 134 | clientMutationId: String 135 | } 136 | 137 | type EventEditPayload { 138 | message: String 139 | error: String 140 | event: Event 141 | clientMutationId: String 142 | } 143 | 144 | """event location""" 145 | input location { 146 | coordinates: [Float] 147 | cep: String 148 | street: String 149 | number: String 150 | } 151 | 152 | """Location Type""" 153 | type Location { 154 | coordinates: [Float] 155 | cep: String 156 | street: String 157 | number: String 158 | } 159 | 160 | input LoginEmailInput { 161 | email: String! 162 | password: String! 163 | clientMutationId: String 164 | } 165 | 166 | type LoginEmailPayload { 167 | token: String 168 | error: String 169 | clientMutationId: String 170 | } 171 | 172 | input MoveToPresenceListInput { 173 | eventId: ID! 174 | clientMutationId: String 175 | } 176 | 177 | type MoveToPresenceListPayload { 178 | message: String 179 | error: String 180 | clientMutationId: String 181 | } 182 | 183 | type Mutation { 184 | LoginEmail(input: LoginEmailInput!): LoginEmailPayload 185 | RegisterEmail(input: RegisterEmailInput!): RegisterEmailPayload 186 | ChangePassword(input: ChangePasswordInput!): ChangePasswordPayload 187 | EventAdd(input: EventAddInput!): EventAddPayload 188 | EventEdit(input: EventEditInput!): EventEditPayload 189 | AttendToEvent(input: AttendToEventInput!): AttendToEventPayload 190 | CantGoToEvent(input: CantGoToEventInput!): CantGoToEventPayload 191 | MoveToPresenceList(input: MoveToPresenceListInput!): MoveToPresenceListPayload 192 | } 193 | 194 | """An object with an ID""" 195 | interface Node { 196 | """The id of the object.""" 197 | id: ID! 198 | } 199 | 200 | """Information about pagination in a connection.""" 201 | type PageInfo { 202 | """When paginating forwards, are there more items?""" 203 | hasNextPage: Boolean! 204 | 205 | """When paginating backwards, are there more items?""" 206 | hasPreviousPage: Boolean! 207 | 208 | """When paginating backwards, the cursor to continue.""" 209 | startCursor: String 210 | 211 | """When paginating forwards, the cursor to continue.""" 212 | endCursor: String 213 | } 214 | 215 | """The root of all... queries""" 216 | type Query { 217 | """Fetches an object given its ID""" 218 | node( 219 | """The ID of an object""" 220 | id: ID! 221 | ): Node 222 | me: User 223 | events(after: String, first: Int, before: String, last: Int, search: String, distance: Int, days: Int, coordinates: [Float]): EventConnection 224 | event(id: ID): Event 225 | user(id: ID!): User 226 | users(after: String, first: Int, before: String, last: Int, search: String): UserConnection 227 | } 228 | 229 | input RegisterEmailInput { 230 | name: String! 231 | email: String! 232 | password: String! 233 | clientMutationId: String 234 | } 235 | 236 | type RegisterEmailPayload { 237 | token: String 238 | error: String 239 | clientMutationId: String 240 | } 241 | 242 | """event schedule""" 243 | input schedule { 244 | talker: String 245 | title: String 246 | description: String 247 | time: String 248 | } 249 | 250 | """Represents Schedules""" 251 | type Schedule { 252 | _id: String 253 | talker: String 254 | title: String 255 | description: String 256 | time: String 257 | } 258 | 259 | type Subscription { 260 | UserAdded: UserAddedPayload 261 | } 262 | 263 | """User data""" 264 | type User implements Node { 265 | """The ID of an object""" 266 | id: ID! 267 | _id: String 268 | name: String 269 | email: String 270 | role: String 271 | active: Boolean 272 | } 273 | 274 | type UserAddedPayload { 275 | userEdge: UserEdge 276 | } 277 | 278 | """A connection to a list of items.""" 279 | type UserConnection { 280 | """Information to aid in pagination.""" 281 | pageInfo: PageInfo! 282 | 283 | """A list of edges.""" 284 | edges: [UserEdge] 285 | count: Int 286 | } 287 | 288 | """An edge in a connection.""" 289 | type UserEdge { 290 | """The item at the end of the edge""" 291 | node: User 292 | 293 | """A cursor for use in pagination""" 294 | cursor: String! 295 | } 296 | -------------------------------------------------------------------------------- /flow-typed/npm/jsonwebtoken_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 238f271634c3c75a3b50c492fcac449f 2 | // flow-typed version: <>/jsonwebtoken_v^7.4.1/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'jsonwebtoken' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'jsonwebtoken' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'jsonwebtoken/decode' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'jsonwebtoken/lib/JsonWebTokenError' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'jsonwebtoken/lib/NotBeforeError' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'jsonwebtoken/lib/timespan' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'jsonwebtoken/lib/TokenExpiredError' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'jsonwebtoken/sign' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'jsonwebtoken/test/async_sign.tests' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'jsonwebtoken/test/buffer.tests' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'jsonwebtoken/test/encoding.tests' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'jsonwebtoken/test/expires_format.tests' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'jsonwebtoken/test/iat.tests' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'jsonwebtoken/test/invalid_exp.tests' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'jsonwebtoken/test/issue_147.tests' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'jsonwebtoken/test/issue_196.tests' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'jsonwebtoken/test/issue_304.tests' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'jsonwebtoken/test/issue_70.tests' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'jsonwebtoken/test/jwt.hs.tests' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'jsonwebtoken/test/jwt.rs.tests' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module 'jsonwebtoken/test/keyid.tests' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module 'jsonwebtoken/test/non_object_values.tests' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module 'jsonwebtoken/test/noTimestamp.tests' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module 'jsonwebtoken/test/rsa-public-key.tests' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module 'jsonwebtoken/test/set_headers.tests' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module 'jsonwebtoken/test/undefined_secretOrPublickey.tests' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module 'jsonwebtoken/test/util/fakeDate' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module 'jsonwebtoken/test/verify.tests' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module 'jsonwebtoken/test/wrong_alg.tests' { 130 | declare module.exports: any; 131 | } 132 | 133 | declare module 'jsonwebtoken/verify' { 134 | declare module.exports: any; 135 | } 136 | 137 | // Filename aliases 138 | declare module 'jsonwebtoken/decode.js' { 139 | declare module.exports: $Exports<'jsonwebtoken/decode'>; 140 | } 141 | declare module 'jsonwebtoken/index' { 142 | declare module.exports: $Exports<'jsonwebtoken'>; 143 | } 144 | declare module 'jsonwebtoken/index.js' { 145 | declare module.exports: $Exports<'jsonwebtoken'>; 146 | } 147 | declare module 'jsonwebtoken/lib/JsonWebTokenError.js' { 148 | declare module.exports: $Exports<'jsonwebtoken/lib/JsonWebTokenError'>; 149 | } 150 | declare module 'jsonwebtoken/lib/NotBeforeError.js' { 151 | declare module.exports: $Exports<'jsonwebtoken/lib/NotBeforeError'>; 152 | } 153 | declare module 'jsonwebtoken/lib/timespan.js' { 154 | declare module.exports: $Exports<'jsonwebtoken/lib/timespan'>; 155 | } 156 | declare module 'jsonwebtoken/lib/TokenExpiredError.js' { 157 | declare module.exports: $Exports<'jsonwebtoken/lib/TokenExpiredError'>; 158 | } 159 | declare module 'jsonwebtoken/sign.js' { 160 | declare module.exports: $Exports<'jsonwebtoken/sign'>; 161 | } 162 | declare module 'jsonwebtoken/test/async_sign.tests.js' { 163 | declare module.exports: $Exports<'jsonwebtoken/test/async_sign.tests'>; 164 | } 165 | declare module 'jsonwebtoken/test/buffer.tests.js' { 166 | declare module.exports: $Exports<'jsonwebtoken/test/buffer.tests'>; 167 | } 168 | declare module 'jsonwebtoken/test/encoding.tests.js' { 169 | declare module.exports: $Exports<'jsonwebtoken/test/encoding.tests'>; 170 | } 171 | declare module 'jsonwebtoken/test/expires_format.tests.js' { 172 | declare module.exports: $Exports<'jsonwebtoken/test/expires_format.tests'>; 173 | } 174 | declare module 'jsonwebtoken/test/iat.tests.js' { 175 | declare module.exports: $Exports<'jsonwebtoken/test/iat.tests'>; 176 | } 177 | declare module 'jsonwebtoken/test/invalid_exp.tests.js' { 178 | declare module.exports: $Exports<'jsonwebtoken/test/invalid_exp.tests'>; 179 | } 180 | declare module 'jsonwebtoken/test/issue_147.tests.js' { 181 | declare module.exports: $Exports<'jsonwebtoken/test/issue_147.tests'>; 182 | } 183 | declare module 'jsonwebtoken/test/issue_196.tests.js' { 184 | declare module.exports: $Exports<'jsonwebtoken/test/issue_196.tests'>; 185 | } 186 | declare module 'jsonwebtoken/test/issue_304.tests.js' { 187 | declare module.exports: $Exports<'jsonwebtoken/test/issue_304.tests'>; 188 | } 189 | declare module 'jsonwebtoken/test/issue_70.tests.js' { 190 | declare module.exports: $Exports<'jsonwebtoken/test/issue_70.tests'>; 191 | } 192 | declare module 'jsonwebtoken/test/jwt.hs.tests.js' { 193 | declare module.exports: $Exports<'jsonwebtoken/test/jwt.hs.tests'>; 194 | } 195 | declare module 'jsonwebtoken/test/jwt.rs.tests.js' { 196 | declare module.exports: $Exports<'jsonwebtoken/test/jwt.rs.tests'>; 197 | } 198 | declare module 'jsonwebtoken/test/keyid.tests.js' { 199 | declare module.exports: $Exports<'jsonwebtoken/test/keyid.tests'>; 200 | } 201 | declare module 'jsonwebtoken/test/non_object_values.tests.js' { 202 | declare module.exports: $Exports<'jsonwebtoken/test/non_object_values.tests'>; 203 | } 204 | declare module 'jsonwebtoken/test/noTimestamp.tests.js' { 205 | declare module.exports: $Exports<'jsonwebtoken/test/noTimestamp.tests'>; 206 | } 207 | declare module 'jsonwebtoken/test/rsa-public-key.tests.js' { 208 | declare module.exports: $Exports<'jsonwebtoken/test/rsa-public-key.tests'>; 209 | } 210 | declare module 'jsonwebtoken/test/set_headers.tests.js' { 211 | declare module.exports: $Exports<'jsonwebtoken/test/set_headers.tests'>; 212 | } 213 | declare module 'jsonwebtoken/test/undefined_secretOrPublickey.tests.js' { 214 | declare module.exports: $Exports<'jsonwebtoken/test/undefined_secretOrPublickey.tests'>; 215 | } 216 | declare module 'jsonwebtoken/test/util/fakeDate.js' { 217 | declare module.exports: $Exports<'jsonwebtoken/test/util/fakeDate'>; 218 | } 219 | declare module 'jsonwebtoken/test/verify.tests.js' { 220 | declare module.exports: $Exports<'jsonwebtoken/test/verify.tests'>; 221 | } 222 | declare module 'jsonwebtoken/test/wrong_alg.tests.js' { 223 | declare module.exports: $Exports<'jsonwebtoken/test/wrong_alg.tests'>; 224 | } 225 | declare module 'jsonwebtoken/verify.js' { 226 | declare module.exports: $Exports<'jsonwebtoken/verify'>; 227 | } 228 | -------------------------------------------------------------------------------- /flow-typed/npm/reify_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: bdd24183f1fd5f0b908ec716a2d280c7 2 | // flow-typed version: <>/reify_v^0.11.23/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'reify' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'reify' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'reify/lib/assignment-visitor' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'reify/lib/compiler' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'reify/lib/empty' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'reify/lib/fast-object' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'reify/lib/fast-path' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'reify/lib/import-export-visitor' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'reify/lib/magic-string' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'reify/lib/options' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'reify/lib/parsers/acorn-extensions/export' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'reify/lib/parsers/acorn-extensions/import' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'reify/lib/parsers/acorn-extensions/index' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'reify/lib/parsers/acorn-extensions/tolerance' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'reify/lib/parsers/acorn' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'reify/lib/parsers/babylon' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'reify/lib/parsers/default' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'reify/lib/parsers/top-level' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'reify/lib/runtime/entry' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'reify/lib/runtime/index' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module 'reify/lib/runtime/utils' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module 'reify/lib/transform' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module 'reify/lib/utils' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module 'reify/lib/visitor' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module 'reify/node/caching-compiler' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module 'reify/node/compile-hook' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module 'reify/node/data' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module 'reify/node/fs' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module 'reify/node/index' { 130 | declare module.exports: any; 131 | } 132 | 133 | declare module 'reify/node/pkg-info' { 134 | declare module.exports: any; 135 | } 136 | 137 | declare module 'reify/node/repl-hook' { 138 | declare module.exports: any; 139 | } 140 | 141 | declare module 'reify/node/utils' { 142 | declare module.exports: any; 143 | } 144 | 145 | declare module 'reify/node/version' { 146 | declare module.exports: any; 147 | } 148 | 149 | declare module 'reify/node/wrapper' { 150 | declare module.exports: any; 151 | } 152 | 153 | declare module 'reify/repl/index' { 154 | declare module.exports: any; 155 | } 156 | 157 | // Filename aliases 158 | declare module 'reify/lib/assignment-visitor.js' { 159 | declare module.exports: $Exports<'reify/lib/assignment-visitor'>; 160 | } 161 | declare module 'reify/lib/compiler.js' { 162 | declare module.exports: $Exports<'reify/lib/compiler'>; 163 | } 164 | declare module 'reify/lib/empty.js' { 165 | declare module.exports: $Exports<'reify/lib/empty'>; 166 | } 167 | declare module 'reify/lib/fast-object.js' { 168 | declare module.exports: $Exports<'reify/lib/fast-object'>; 169 | } 170 | declare module 'reify/lib/fast-path.js' { 171 | declare module.exports: $Exports<'reify/lib/fast-path'>; 172 | } 173 | declare module 'reify/lib/import-export-visitor.js' { 174 | declare module.exports: $Exports<'reify/lib/import-export-visitor'>; 175 | } 176 | declare module 'reify/lib/magic-string.js' { 177 | declare module.exports: $Exports<'reify/lib/magic-string'>; 178 | } 179 | declare module 'reify/lib/options.js' { 180 | declare module.exports: $Exports<'reify/lib/options'>; 181 | } 182 | declare module 'reify/lib/parsers/acorn-extensions/export.js' { 183 | declare module.exports: $Exports<'reify/lib/parsers/acorn-extensions/export'>; 184 | } 185 | declare module 'reify/lib/parsers/acorn-extensions/import.js' { 186 | declare module.exports: $Exports<'reify/lib/parsers/acorn-extensions/import'>; 187 | } 188 | declare module 'reify/lib/parsers/acorn-extensions/index.js' { 189 | declare module.exports: $Exports<'reify/lib/parsers/acorn-extensions/index'>; 190 | } 191 | declare module 'reify/lib/parsers/acorn-extensions/tolerance.js' { 192 | declare module.exports: $Exports<'reify/lib/parsers/acorn-extensions/tolerance'>; 193 | } 194 | declare module 'reify/lib/parsers/acorn.js' { 195 | declare module.exports: $Exports<'reify/lib/parsers/acorn'>; 196 | } 197 | declare module 'reify/lib/parsers/babylon.js' { 198 | declare module.exports: $Exports<'reify/lib/parsers/babylon'>; 199 | } 200 | declare module 'reify/lib/parsers/default.js' { 201 | declare module.exports: $Exports<'reify/lib/parsers/default'>; 202 | } 203 | declare module 'reify/lib/parsers/top-level.js' { 204 | declare module.exports: $Exports<'reify/lib/parsers/top-level'>; 205 | } 206 | declare module 'reify/lib/runtime/entry.js' { 207 | declare module.exports: $Exports<'reify/lib/runtime/entry'>; 208 | } 209 | declare module 'reify/lib/runtime/index.js' { 210 | declare module.exports: $Exports<'reify/lib/runtime/index'>; 211 | } 212 | declare module 'reify/lib/runtime/utils.js' { 213 | declare module.exports: $Exports<'reify/lib/runtime/utils'>; 214 | } 215 | declare module 'reify/lib/transform.js' { 216 | declare module.exports: $Exports<'reify/lib/transform'>; 217 | } 218 | declare module 'reify/lib/utils.js' { 219 | declare module.exports: $Exports<'reify/lib/utils'>; 220 | } 221 | declare module 'reify/lib/visitor.js' { 222 | declare module.exports: $Exports<'reify/lib/visitor'>; 223 | } 224 | declare module 'reify/node/caching-compiler.js' { 225 | declare module.exports: $Exports<'reify/node/caching-compiler'>; 226 | } 227 | declare module 'reify/node/compile-hook.js' { 228 | declare module.exports: $Exports<'reify/node/compile-hook'>; 229 | } 230 | declare module 'reify/node/data.js' { 231 | declare module.exports: $Exports<'reify/node/data'>; 232 | } 233 | declare module 'reify/node/fs.js' { 234 | declare module.exports: $Exports<'reify/node/fs'>; 235 | } 236 | declare module 'reify/node/index.js' { 237 | declare module.exports: $Exports<'reify/node/index'>; 238 | } 239 | declare module 'reify/node/pkg-info.js' { 240 | declare module.exports: $Exports<'reify/node/pkg-info'>; 241 | } 242 | declare module 'reify/node/repl-hook.js' { 243 | declare module.exports: $Exports<'reify/node/repl-hook'>; 244 | } 245 | declare module 'reify/node/utils.js' { 246 | declare module.exports: $Exports<'reify/node/utils'>; 247 | } 248 | declare module 'reify/node/version.js' { 249 | declare module.exports: $Exports<'reify/node/version'>; 250 | } 251 | declare module 'reify/node/wrapper.js' { 252 | declare module.exports: $Exports<'reify/node/wrapper'>; 253 | } 254 | declare module 'reify/repl/index.js' { 255 | declare module.exports: $Exports<'reify/repl/index'>; 256 | } 257 | -------------------------------------------------------------------------------- /flow-typed/npm/express_v4.16.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 106bbf49ff0c0b351c95d483d617ffba 2 | // flow-typed version: 7fe23c8e85/express_v4.16.x/flow_>=v0.32.x 3 | 4 | import type { Server } from 'http'; 5 | import type { Socket } from 'net'; 6 | 7 | declare type express$RouterOptions = { 8 | caseSensitive?: boolean, 9 | mergeParams?: boolean, 10 | strict?: boolean, 11 | }; 12 | 13 | declare class express$RequestResponseBase { 14 | app: express$Application; 15 | get(field: string): string | void; 16 | } 17 | 18 | declare type express$RequestParams = { 19 | [param: string]: string, 20 | }; 21 | 22 | declare class express$Request extends http$IncomingMessage mixins express$RequestResponseBase { 23 | baseUrl: string; 24 | body: mixed; 25 | cookies: { [cookie: string]: string }; 26 | connection: Socket; 27 | fresh: boolean; 28 | hostname: string; 29 | ip: string; 30 | ips: Array; 31 | method: string; 32 | originalUrl: string; 33 | params: express$RequestParams; 34 | path: string; 35 | protocol: 'https' | 'http'; 36 | query: { [name: string]: string | Array }; 37 | route: string; 38 | secure: boolean; 39 | signedCookies: { [signedCookie: string]: string }; 40 | stale: boolean; 41 | subdomains: Array; 42 | xhr: boolean; 43 | accepts(types: string): string | false; 44 | accepts(types: Array): string | false; 45 | acceptsCharsets(...charsets: Array): string | false; 46 | acceptsEncodings(...encoding: Array): string | false; 47 | acceptsLanguages(...lang: Array): string | false; 48 | header(field: string): string | void; 49 | is(type: string): boolean; 50 | param(name: string, defaultValue?: string): string | void; 51 | } 52 | 53 | declare type express$CookieOptions = { 54 | domain?: string, 55 | encode?: (value: string) => string, 56 | expires?: Date, 57 | httpOnly?: boolean, 58 | maxAge?: number, 59 | path?: string, 60 | secure?: boolean, 61 | signed?: boolean, 62 | }; 63 | 64 | declare type express$Path = string | RegExp; 65 | 66 | declare type express$RenderCallback = (err: Error | null, html?: string) => mixed; 67 | 68 | declare type express$SendFileOptions = { 69 | maxAge?: number, 70 | root?: string, 71 | lastModified?: boolean, 72 | headers?: { [name: string]: string }, 73 | dotfiles?: 'allow' | 'deny' | 'ignore', 74 | }; 75 | 76 | declare class express$Response extends http$ServerResponse mixins express$RequestResponseBase { 77 | headersSent: boolean; 78 | locals: { [name: string]: mixed }; 79 | append(field: string, value?: string): this; 80 | attachment(filename?: string): this; 81 | cookie(name: string, value: string, options?: express$CookieOptions): this; 82 | clearCookie(name: string, options?: express$CookieOptions): this; 83 | download(path: string, filename?: string, callback?: (err?: ?Error) => void): this; 84 | format(typesObject: { [type: string]: Function }): this; 85 | json(body?: mixed): this; 86 | jsonp(body?: mixed): this; 87 | links(links: { [name: string]: string }): this; 88 | location(path: string): this; 89 | redirect(url: string, ...args: Array): this; 90 | redirect(status: number, url: string, ...args: Array): this; 91 | render(view: string, locals?: { [name: string]: mixed }, callback?: express$RenderCallback): this; 92 | send(body?: mixed): this; 93 | sendFile(path: string, options?: express$SendFileOptions, callback?: (err?: ?Error) => mixed): this; 94 | sendStatus(statusCode: number): this; 95 | header(field: string, value?: string): this; 96 | header(headers: { [name: string]: string }): this; 97 | set(field: string, value?: string | string[]): this; 98 | set(headers: { [name: string]: string }): this; 99 | status(statusCode: number): this; 100 | type(type: string): this; 101 | vary(field: string): this; 102 | req: express$Request; 103 | } 104 | 105 | declare type express$NextFunction = (err?: ?Error | 'route') => mixed; 106 | declare type express$Middleware = 107 | | ((req: $Subtype, res: express$Response, next: express$NextFunction) => mixed) 108 | | ((error: Error, req: $Subtype, res: express$Response, next: express$NextFunction) => mixed); 109 | declare interface express$RouteMethodType { 110 | (middleware: express$Middleware): T; 111 | (...middleware: Array): T; 112 | (path: express$Path | express$Path[], ...middleware: Array): T; 113 | } 114 | declare class express$Route { 115 | all: express$RouteMethodType; 116 | get: express$RouteMethodType; 117 | post: express$RouteMethodType; 118 | put: express$RouteMethodType; 119 | head: express$RouteMethodType; 120 | delete: express$RouteMethodType; 121 | options: express$RouteMethodType; 122 | trace: express$RouteMethodType; 123 | copy: express$RouteMethodType; 124 | lock: express$RouteMethodType; 125 | mkcol: express$RouteMethodType; 126 | move: express$RouteMethodType; 127 | purge: express$RouteMethodType; 128 | propfind: express$RouteMethodType; 129 | proppatch: express$RouteMethodType; 130 | unlock: express$RouteMethodType; 131 | report: express$RouteMethodType; 132 | mkactivity: express$RouteMethodType; 133 | checkout: express$RouteMethodType; 134 | merge: express$RouteMethodType; 135 | 136 | // @TODO Missing 'm-search' but get flow illegal name error. 137 | 138 | notify: express$RouteMethodType; 139 | subscribe: express$RouteMethodType; 140 | unsubscribe: express$RouteMethodType; 141 | patch: express$RouteMethodType; 142 | search: express$RouteMethodType; 143 | connect: express$RouteMethodType; 144 | } 145 | 146 | declare class express$Router extends express$Route { 147 | constructor(options?: express$RouterOptions): void; 148 | route(path: string): express$Route; 149 | static (options?: express$RouterOptions): express$Router; 150 | use(middleware: express$Middleware): this; 151 | use(...middleware: Array): this; 152 | use(path: express$Path | express$Path[], ...middleware: Array): this; 153 | use(path: string, router: express$Router): this; 154 | handle(req: http$IncomingMessage, res: http$ServerResponse, next: express$NextFunction): void; 155 | param( 156 | param: string, 157 | callback: (req: $Subtype, res: express$Response, next: express$NextFunction, id: string) => mixed, 158 | ): void; 159 | 160 | // Can't use regular callable signature syntax due to https://github.com/facebook/flow/issues/3084 161 | $call: (req: http$IncomingMessage, res: http$ServerResponse, next?: ?express$NextFunction) => void; 162 | } 163 | 164 | /* 165 | With flow-bin ^0.59, express app.listen() is deemed to return any and fails flow type coverage. 166 | Which is ironic because https://github.com/facebook/flow/blob/master/Changelog.md#misc-2 (release notes for 0.59) 167 | says "Improves typings for Node.js HTTP server listen() function." See that? IMPROVES! 168 | To work around this issue, we changed Server to ?Server here, so that our invocations of express.listen() will 169 | not be deemed to lack type coverage. 170 | */ 171 | 172 | declare class express$Application extends express$Router mixins events$EventEmitter { 173 | constructor(): void; 174 | locals: { [name: string]: mixed }; 175 | mountpath: string; 176 | listen(port: number, hostname?: string, backlog?: number, callback?: (err?: ?Error) => mixed): ?Server; 177 | listen(port: number, hostname?: string, callback?: (err?: ?Error) => mixed): ?Server; 178 | listen(port: number, callback?: (err?: ?Error) => mixed): ?Server; 179 | listen(path: string, callback?: (err?: ?Error) => mixed): ?Server; 180 | listen(handle: Object, callback?: (err?: ?Error) => mixed): ?Server; 181 | disable(name: string): void; 182 | disabled(name: string): boolean; 183 | enable(name: string): express$Application; 184 | enabled(name: string): boolean; 185 | engine(name: string, callback: Function): void; 186 | /** 187 | * Mixed will not be taken as a value option. Issue around using the GET http method name and the get for settings. 188 | */ 189 | // get(name: string): mixed; 190 | set(name: string, value: mixed): mixed; 191 | render(name: string, optionsOrFunction: { [name: string]: mixed }, callback: express$RenderCallback): void; 192 | handle(req: http$IncomingMessage, res: http$ServerResponse, next?: ?express$NextFunction): void; 193 | } 194 | 195 | declare type JsonOptions = { 196 | inflate?: boolean, 197 | limit?: string | number, 198 | reviver?: (key: string, value: mixed) => mixed, 199 | strict?: boolean, 200 | type?: string | Array | ((req: express$Request) => boolean), 201 | verify?: (req: express$Request, res: express$Response, buf: Buffer, encoding: string) => mixed, 202 | }; 203 | 204 | declare type express$UrlEncodedOptions = { 205 | extended?: boolean, 206 | inflate?: boolean, 207 | limit?: string | number, 208 | parameterLimit?: number, 209 | type?: string | Array | ((req: express$Request) => boolean), 210 | verify?: (req: express$Request, res: express$Response, buf: Buffer, encoding: string) => mixed, 211 | }; 212 | 213 | declare module 'express' { 214 | declare export type RouterOptions = express$RouterOptions; 215 | declare export type CookieOptions = express$CookieOptions; 216 | declare export type Middleware = express$Middleware; 217 | declare export type NextFunction = express$NextFunction; 218 | declare export type RequestParams = express$RequestParams; 219 | declare export type $Response = express$Response; 220 | declare export type $Request = express$Request; 221 | declare export type $Application = express$Application; 222 | 223 | declare module.exports: { 224 | (): express$Application, // If you try to call like a function, it will use this signature 225 | json: (opts: ?JsonOptions) => express$Middleware, 226 | static: (root: string, options?: Object) => express$Middleware, // `static` property on the function 227 | Router: typeof express$Router, // `Router` property on the function 228 | urlencoded: (opts: ?express$UrlEncodedOptions) => express$Middleware, 229 | }; 230 | } 231 | -------------------------------------------------------------------------------- /flow-typed/npm/jest-cli_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 0f150bf2deeadc503005bb40b9fc8beb 2 | // flow-typed version: <>/jest-cli_v20.0.4/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'jest-cli' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'jest-cli' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'jest-cli/bin/jest' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'jest-cli/build/cli/args' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'jest-cli/build/cli/getJest' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'jest-cli/build/cli/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'jest-cli/build/cli/runCLI' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'jest-cli/build/constants' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'jest-cli/build/generateEmptyCoverage' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'jest-cli/build/jest' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'jest-cli/build/lib/BufferedConsole' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'jest-cli/build/lib/colorize' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'jest-cli/build/lib/createContext' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'jest-cli/build/lib/formatTestNameByPattern' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'jest-cli/build/lib/getMaxWorkers' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'jest-cli/build/lib/getTestPathPattern' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'jest-cli/build/lib/handleDeprecationWarnings' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'jest-cli/build/lib/highlight' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'jest-cli/build/lib/isValidPath' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'jest-cli/build/lib/logDebugMessages' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module 'jest-cli/build/lib/patternModeHelpers' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module 'jest-cli/build/lib/Prompt' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module 'jest-cli/build/lib/scrollList' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module 'jest-cli/build/lib/terminalUtils' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module 'jest-cli/build/lib/updateArgv' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module 'jest-cli/build/lib/validatePattern' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module 'jest-cli/build/PatternPrompt' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module 'jest-cli/build/preRunMessage' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module 'jest-cli/build/ReporterDispatcher' { 130 | declare module.exports: any; 131 | } 132 | 133 | declare module 'jest-cli/build/reporters/BaseReporter' { 134 | declare module.exports: any; 135 | } 136 | 137 | declare module 'jest-cli/build/reporters/CoverageReporter' { 138 | declare module.exports: any; 139 | } 140 | 141 | declare module 'jest-cli/build/reporters/CoverageWorker' { 142 | declare module.exports: any; 143 | } 144 | 145 | declare module 'jest-cli/build/reporters/DefaultReporter' { 146 | declare module.exports: any; 147 | } 148 | 149 | declare module 'jest-cli/build/reporters/getConsoleOutput' { 150 | declare module.exports: any; 151 | } 152 | 153 | declare module 'jest-cli/build/reporters/getResultHeader' { 154 | declare module.exports: any; 155 | } 156 | 157 | declare module 'jest-cli/build/reporters/NotifyReporter' { 158 | declare module.exports: any; 159 | } 160 | 161 | declare module 'jest-cli/build/reporters/Status' { 162 | declare module.exports: any; 163 | } 164 | 165 | declare module 'jest-cli/build/reporters/SummaryReporter' { 166 | declare module.exports: any; 167 | } 168 | 169 | declare module 'jest-cli/build/reporters/utils' { 170 | declare module.exports: any; 171 | } 172 | 173 | declare module 'jest-cli/build/reporters/VerboseReporter' { 174 | declare module.exports: any; 175 | } 176 | 177 | declare module 'jest-cli/build/runJest' { 178 | declare module.exports: any; 179 | } 180 | 181 | declare module 'jest-cli/build/runTest' { 182 | declare module.exports: any; 183 | } 184 | 185 | declare module 'jest-cli/build/SearchSource' { 186 | declare module.exports: any; 187 | } 188 | 189 | declare module 'jest-cli/build/TestNamePatternPrompt' { 190 | declare module.exports: any; 191 | } 192 | 193 | declare module 'jest-cli/build/TestPathPatternPrompt' { 194 | declare module.exports: any; 195 | } 196 | 197 | declare module 'jest-cli/build/TestRunner' { 198 | declare module.exports: any; 199 | } 200 | 201 | declare module 'jest-cli/build/TestSequencer' { 202 | declare module.exports: any; 203 | } 204 | 205 | declare module 'jest-cli/build/TestWatcher' { 206 | declare module.exports: any; 207 | } 208 | 209 | declare module 'jest-cli/build/TestWorker' { 210 | declare module.exports: any; 211 | } 212 | 213 | declare module 'jest-cli/build/watch' { 214 | declare module.exports: any; 215 | } 216 | 217 | // Filename aliases 218 | declare module 'jest-cli/bin/jest.js' { 219 | declare module.exports: $Exports<'jest-cli/bin/jest'>; 220 | } 221 | declare module 'jest-cli/build/cli/args.js' { 222 | declare module.exports: $Exports<'jest-cli/build/cli/args'>; 223 | } 224 | declare module 'jest-cli/build/cli/getJest.js' { 225 | declare module.exports: $Exports<'jest-cli/build/cli/getJest'>; 226 | } 227 | declare module 'jest-cli/build/cli/index.js' { 228 | declare module.exports: $Exports<'jest-cli/build/cli/index'>; 229 | } 230 | declare module 'jest-cli/build/cli/runCLI.js' { 231 | declare module.exports: $Exports<'jest-cli/build/cli/runCLI'>; 232 | } 233 | declare module 'jest-cli/build/constants.js' { 234 | declare module.exports: $Exports<'jest-cli/build/constants'>; 235 | } 236 | declare module 'jest-cli/build/generateEmptyCoverage.js' { 237 | declare module.exports: $Exports<'jest-cli/build/generateEmptyCoverage'>; 238 | } 239 | declare module 'jest-cli/build/jest.js' { 240 | declare module.exports: $Exports<'jest-cli/build/jest'>; 241 | } 242 | declare module 'jest-cli/build/lib/BufferedConsole.js' { 243 | declare module.exports: $Exports<'jest-cli/build/lib/BufferedConsole'>; 244 | } 245 | declare module 'jest-cli/build/lib/colorize.js' { 246 | declare module.exports: $Exports<'jest-cli/build/lib/colorize'>; 247 | } 248 | declare module 'jest-cli/build/lib/createContext.js' { 249 | declare module.exports: $Exports<'jest-cli/build/lib/createContext'>; 250 | } 251 | declare module 'jest-cli/build/lib/formatTestNameByPattern.js' { 252 | declare module.exports: $Exports<'jest-cli/build/lib/formatTestNameByPattern'>; 253 | } 254 | declare module 'jest-cli/build/lib/getMaxWorkers.js' { 255 | declare module.exports: $Exports<'jest-cli/build/lib/getMaxWorkers'>; 256 | } 257 | declare module 'jest-cli/build/lib/getTestPathPattern.js' { 258 | declare module.exports: $Exports<'jest-cli/build/lib/getTestPathPattern'>; 259 | } 260 | declare module 'jest-cli/build/lib/handleDeprecationWarnings.js' { 261 | declare module.exports: $Exports<'jest-cli/build/lib/handleDeprecationWarnings'>; 262 | } 263 | declare module 'jest-cli/build/lib/highlight.js' { 264 | declare module.exports: $Exports<'jest-cli/build/lib/highlight'>; 265 | } 266 | declare module 'jest-cli/build/lib/isValidPath.js' { 267 | declare module.exports: $Exports<'jest-cli/build/lib/isValidPath'>; 268 | } 269 | declare module 'jest-cli/build/lib/logDebugMessages.js' { 270 | declare module.exports: $Exports<'jest-cli/build/lib/logDebugMessages'>; 271 | } 272 | declare module 'jest-cli/build/lib/patternModeHelpers.js' { 273 | declare module.exports: $Exports<'jest-cli/build/lib/patternModeHelpers'>; 274 | } 275 | declare module 'jest-cli/build/lib/Prompt.js' { 276 | declare module.exports: $Exports<'jest-cli/build/lib/Prompt'>; 277 | } 278 | declare module 'jest-cli/build/lib/scrollList.js' { 279 | declare module.exports: $Exports<'jest-cli/build/lib/scrollList'>; 280 | } 281 | declare module 'jest-cli/build/lib/terminalUtils.js' { 282 | declare module.exports: $Exports<'jest-cli/build/lib/terminalUtils'>; 283 | } 284 | declare module 'jest-cli/build/lib/updateArgv.js' { 285 | declare module.exports: $Exports<'jest-cli/build/lib/updateArgv'>; 286 | } 287 | declare module 'jest-cli/build/lib/validatePattern.js' { 288 | declare module.exports: $Exports<'jest-cli/build/lib/validatePattern'>; 289 | } 290 | declare module 'jest-cli/build/PatternPrompt.js' { 291 | declare module.exports: $Exports<'jest-cli/build/PatternPrompt'>; 292 | } 293 | declare module 'jest-cli/build/preRunMessage.js' { 294 | declare module.exports: $Exports<'jest-cli/build/preRunMessage'>; 295 | } 296 | declare module 'jest-cli/build/ReporterDispatcher.js' { 297 | declare module.exports: $Exports<'jest-cli/build/ReporterDispatcher'>; 298 | } 299 | declare module 'jest-cli/build/reporters/BaseReporter.js' { 300 | declare module.exports: $Exports<'jest-cli/build/reporters/BaseReporter'>; 301 | } 302 | declare module 'jest-cli/build/reporters/CoverageReporter.js' { 303 | declare module.exports: $Exports<'jest-cli/build/reporters/CoverageReporter'>; 304 | } 305 | declare module 'jest-cli/build/reporters/CoverageWorker.js' { 306 | declare module.exports: $Exports<'jest-cli/build/reporters/CoverageWorker'>; 307 | } 308 | declare module 'jest-cli/build/reporters/DefaultReporter.js' { 309 | declare module.exports: $Exports<'jest-cli/build/reporters/DefaultReporter'>; 310 | } 311 | declare module 'jest-cli/build/reporters/getConsoleOutput.js' { 312 | declare module.exports: $Exports<'jest-cli/build/reporters/getConsoleOutput'>; 313 | } 314 | declare module 'jest-cli/build/reporters/getResultHeader.js' { 315 | declare module.exports: $Exports<'jest-cli/build/reporters/getResultHeader'>; 316 | } 317 | declare module 'jest-cli/build/reporters/NotifyReporter.js' { 318 | declare module.exports: $Exports<'jest-cli/build/reporters/NotifyReporter'>; 319 | } 320 | declare module 'jest-cli/build/reporters/Status.js' { 321 | declare module.exports: $Exports<'jest-cli/build/reporters/Status'>; 322 | } 323 | declare module 'jest-cli/build/reporters/SummaryReporter.js' { 324 | declare module.exports: $Exports<'jest-cli/build/reporters/SummaryReporter'>; 325 | } 326 | declare module 'jest-cli/build/reporters/utils.js' { 327 | declare module.exports: $Exports<'jest-cli/build/reporters/utils'>; 328 | } 329 | declare module 'jest-cli/build/reporters/VerboseReporter.js' { 330 | declare module.exports: $Exports<'jest-cli/build/reporters/VerboseReporter'>; 331 | } 332 | declare module 'jest-cli/build/runJest.js' { 333 | declare module.exports: $Exports<'jest-cli/build/runJest'>; 334 | } 335 | declare module 'jest-cli/build/runTest.js' { 336 | declare module.exports: $Exports<'jest-cli/build/runTest'>; 337 | } 338 | declare module 'jest-cli/build/SearchSource.js' { 339 | declare module.exports: $Exports<'jest-cli/build/SearchSource'>; 340 | } 341 | declare module 'jest-cli/build/TestNamePatternPrompt.js' { 342 | declare module.exports: $Exports<'jest-cli/build/TestNamePatternPrompt'>; 343 | } 344 | declare module 'jest-cli/build/TestPathPatternPrompt.js' { 345 | declare module.exports: $Exports<'jest-cli/build/TestPathPatternPrompt'>; 346 | } 347 | declare module 'jest-cli/build/TestRunner.js' { 348 | declare module.exports: $Exports<'jest-cli/build/TestRunner'>; 349 | } 350 | declare module 'jest-cli/build/TestSequencer.js' { 351 | declare module.exports: $Exports<'jest-cli/build/TestSequencer'>; 352 | } 353 | declare module 'jest-cli/build/TestWatcher.js' { 354 | declare module.exports: $Exports<'jest-cli/build/TestWatcher'>; 355 | } 356 | declare module 'jest-cli/build/TestWorker.js' { 357 | declare module.exports: $Exports<'jest-cli/build/TestWorker'>; 358 | } 359 | declare module 'jest-cli/build/watch.js' { 360 | declare module.exports: $Exports<'jest-cli/build/watch'>; 361 | } 362 | -------------------------------------------------------------------------------- /flow-typed/npm/eslint-plugin-import_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: b6631939a281b271c6955707fc3d10b1 2 | // flow-typed version: <>/eslint-plugin-import_v^2.3.0/flow_v0.48.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'eslint-plugin-import' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'eslint-plugin-import' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'eslint-plugin-import/config/electron' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'eslint-plugin-import/config/errors' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'eslint-plugin-import/config/react-native' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'eslint-plugin-import/config/react' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'eslint-plugin-import/config/recommended' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'eslint-plugin-import/config/stage-0' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'eslint-plugin-import/config/warnings' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'eslint-plugin-import/lib/core/importType' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'eslint-plugin-import/lib/core/staticRequire' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'eslint-plugin-import/lib/ExportMap' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'eslint-plugin-import/lib/importDeclaration' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'eslint-plugin-import/lib/index' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'eslint-plugin-import/lib/rules/default' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'eslint-plugin-import/lib/rules/export' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'eslint-plugin-import/lib/rules/extensions' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'eslint-plugin-import/lib/rules/first' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'eslint-plugin-import/lib/rules/imports-first' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'eslint-plugin-import/lib/rules/max-dependencies' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module 'eslint-plugin-import/lib/rules/named' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module 'eslint-plugin-import/lib/rules/namespace' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module 'eslint-plugin-import/lib/rules/newline-after-import' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module 'eslint-plugin-import/lib/rules/no-absolute-path' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module 'eslint-plugin-import/lib/rules/no-amd' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module 'eslint-plugin-import/lib/rules/no-anonymous-default-export' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module 'eslint-plugin-import/lib/rules/no-commonjs' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module 'eslint-plugin-import/lib/rules/no-deprecated' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module 'eslint-plugin-import/lib/rules/no-duplicates' { 130 | declare module.exports: any; 131 | } 132 | 133 | declare module 'eslint-plugin-import/lib/rules/no-dynamic-require' { 134 | declare module.exports: any; 135 | } 136 | 137 | declare module 'eslint-plugin-import/lib/rules/no-extraneous-dependencies' { 138 | declare module.exports: any; 139 | } 140 | 141 | declare module 'eslint-plugin-import/lib/rules/no-internal-modules' { 142 | declare module.exports: any; 143 | } 144 | 145 | declare module 'eslint-plugin-import/lib/rules/no-mutable-exports' { 146 | declare module.exports: any; 147 | } 148 | 149 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default-member' { 150 | declare module.exports: any; 151 | } 152 | 153 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default' { 154 | declare module.exports: any; 155 | } 156 | 157 | declare module 'eslint-plugin-import/lib/rules/no-named-default' { 158 | declare module.exports: any; 159 | } 160 | 161 | declare module 'eslint-plugin-import/lib/rules/no-namespace' { 162 | declare module.exports: any; 163 | } 164 | 165 | declare module 'eslint-plugin-import/lib/rules/no-nodejs-modules' { 166 | declare module.exports: any; 167 | } 168 | 169 | declare module 'eslint-plugin-import/lib/rules/no-restricted-paths' { 170 | declare module.exports: any; 171 | } 172 | 173 | declare module 'eslint-plugin-import/lib/rules/no-unassigned-import' { 174 | declare module.exports: any; 175 | } 176 | 177 | declare module 'eslint-plugin-import/lib/rules/no-unresolved' { 178 | declare module.exports: any; 179 | } 180 | 181 | declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax' { 182 | declare module.exports: any; 183 | } 184 | 185 | declare module 'eslint-plugin-import/lib/rules/order' { 186 | declare module.exports: any; 187 | } 188 | 189 | declare module 'eslint-plugin-import/lib/rules/prefer-default-export' { 190 | declare module.exports: any; 191 | } 192 | 193 | declare module 'eslint-plugin-import/lib/rules/unambiguous' { 194 | declare module.exports: any; 195 | } 196 | 197 | declare module 'eslint-plugin-import/memo-parser/index' { 198 | declare module.exports: any; 199 | } 200 | 201 | // Filename aliases 202 | declare module 'eslint-plugin-import/config/electron.js' { 203 | declare module.exports: $Exports<'eslint-plugin-import/config/electron'>; 204 | } 205 | declare module 'eslint-plugin-import/config/errors.js' { 206 | declare module.exports: $Exports<'eslint-plugin-import/config/errors'>; 207 | } 208 | declare module 'eslint-plugin-import/config/react-native.js' { 209 | declare module.exports: $Exports<'eslint-plugin-import/config/react-native'>; 210 | } 211 | declare module 'eslint-plugin-import/config/react.js' { 212 | declare module.exports: $Exports<'eslint-plugin-import/config/react'>; 213 | } 214 | declare module 'eslint-plugin-import/config/recommended.js' { 215 | declare module.exports: $Exports<'eslint-plugin-import/config/recommended'>; 216 | } 217 | declare module 'eslint-plugin-import/config/stage-0.js' { 218 | declare module.exports: $Exports<'eslint-plugin-import/config/stage-0'>; 219 | } 220 | declare module 'eslint-plugin-import/config/warnings.js' { 221 | declare module.exports: $Exports<'eslint-plugin-import/config/warnings'>; 222 | } 223 | declare module 'eslint-plugin-import/lib/core/importType.js' { 224 | declare module.exports: $Exports<'eslint-plugin-import/lib/core/importType'>; 225 | } 226 | declare module 'eslint-plugin-import/lib/core/staticRequire.js' { 227 | declare module.exports: $Exports<'eslint-plugin-import/lib/core/staticRequire'>; 228 | } 229 | declare module 'eslint-plugin-import/lib/ExportMap.js' { 230 | declare module.exports: $Exports<'eslint-plugin-import/lib/ExportMap'>; 231 | } 232 | declare module 'eslint-plugin-import/lib/importDeclaration.js' { 233 | declare module.exports: $Exports<'eslint-plugin-import/lib/importDeclaration'>; 234 | } 235 | declare module 'eslint-plugin-import/lib/index.js' { 236 | declare module.exports: $Exports<'eslint-plugin-import/lib/index'>; 237 | } 238 | declare module 'eslint-plugin-import/lib/rules/default.js' { 239 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/default'>; 240 | } 241 | declare module 'eslint-plugin-import/lib/rules/export.js' { 242 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/export'>; 243 | } 244 | declare module 'eslint-plugin-import/lib/rules/extensions.js' { 245 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/extensions'>; 246 | } 247 | declare module 'eslint-plugin-import/lib/rules/first.js' { 248 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/first'>; 249 | } 250 | declare module 'eslint-plugin-import/lib/rules/imports-first.js' { 251 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/imports-first'>; 252 | } 253 | declare module 'eslint-plugin-import/lib/rules/max-dependencies.js' { 254 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/max-dependencies'>; 255 | } 256 | declare module 'eslint-plugin-import/lib/rules/named.js' { 257 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/named'>; 258 | } 259 | declare module 'eslint-plugin-import/lib/rules/namespace.js' { 260 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/namespace'>; 261 | } 262 | declare module 'eslint-plugin-import/lib/rules/newline-after-import.js' { 263 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/newline-after-import'>; 264 | } 265 | declare module 'eslint-plugin-import/lib/rules/no-absolute-path.js' { 266 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-absolute-path'>; 267 | } 268 | declare module 'eslint-plugin-import/lib/rules/no-amd.js' { 269 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-amd'>; 270 | } 271 | declare module 'eslint-plugin-import/lib/rules/no-anonymous-default-export.js' { 272 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-anonymous-default-export'>; 273 | } 274 | declare module 'eslint-plugin-import/lib/rules/no-commonjs.js' { 275 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-commonjs'>; 276 | } 277 | declare module 'eslint-plugin-import/lib/rules/no-deprecated.js' { 278 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-deprecated'>; 279 | } 280 | declare module 'eslint-plugin-import/lib/rules/no-duplicates.js' { 281 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-duplicates'>; 282 | } 283 | declare module 'eslint-plugin-import/lib/rules/no-dynamic-require.js' { 284 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-dynamic-require'>; 285 | } 286 | declare module 'eslint-plugin-import/lib/rules/no-extraneous-dependencies.js' { 287 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-extraneous-dependencies'>; 288 | } 289 | declare module 'eslint-plugin-import/lib/rules/no-internal-modules.js' { 290 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-internal-modules'>; 291 | } 292 | declare module 'eslint-plugin-import/lib/rules/no-mutable-exports.js' { 293 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-mutable-exports'>; 294 | } 295 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default-member.js' { 296 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-as-default-member'>; 297 | } 298 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default.js' { 299 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-as-default'>; 300 | } 301 | declare module 'eslint-plugin-import/lib/rules/no-named-default.js' { 302 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-default'>; 303 | } 304 | declare module 'eslint-plugin-import/lib/rules/no-namespace.js' { 305 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-namespace'>; 306 | } 307 | declare module 'eslint-plugin-import/lib/rules/no-nodejs-modules.js' { 308 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-nodejs-modules'>; 309 | } 310 | declare module 'eslint-plugin-import/lib/rules/no-restricted-paths.js' { 311 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-restricted-paths'>; 312 | } 313 | declare module 'eslint-plugin-import/lib/rules/no-unassigned-import.js' { 314 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unassigned-import'>; 315 | } 316 | declare module 'eslint-plugin-import/lib/rules/no-unresolved.js' { 317 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unresolved'>; 318 | } 319 | declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js' { 320 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-webpack-loader-syntax'>; 321 | } 322 | declare module 'eslint-plugin-import/lib/rules/order.js' { 323 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/order'>; 324 | } 325 | declare module 'eslint-plugin-import/lib/rules/prefer-default-export.js' { 326 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/prefer-default-export'>; 327 | } 328 | declare module 'eslint-plugin-import/lib/rules/unambiguous.js' { 329 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/unambiguous'>; 330 | } 331 | declare module 'eslint-plugin-import/memo-parser/index.js' { 332 | declare module.exports: $Exports<'eslint-plugin-import/memo-parser/index'>; 333 | } 334 | -------------------------------------------------------------------------------- /flow-typed/npm/koa_v2.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 846c003f881e5aba2c7c39e3edf8ce31 2 | // flow-typed version: 47f1640404/koa_v2.x.x/flow_>=v0.47.x 3 | 4 | /* 5 | * Type def from from source code of koa. 6 | * this: https://github.com/koajs/koa/commit/08eb1a20c3975230aa1fe1c693b0cd1ac7a0752b 7 | * previous: https://github.com/koajs/koa/commit/fabf5864c6a5dca0782b867a263b1b0825a05bf9 8 | * 9 | * Changelog 10 | * breaking: remove unused app.name 11 | * breaking: ctx.throw([status], [msg], [properties]) (caused by http-errors (#957) ) 12 | **/ 13 | declare module 'koa' { 14 | // Currently, import type doesnt work well ? 15 | // so copy `Server` from flow/lib/node.js#L820 16 | declare class Server extends net$Server { 17 | listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server, 18 | listen(path: string, callback?: Function): Server, 19 | listen(handle: Object, callback?: Function): Server, 20 | close(callback?: Function): Server, 21 | maxHeadersCount: number, 22 | setTimeout(msecs: number, callback: Function): Server, 23 | timeout: number, 24 | } 25 | declare type ServerType = Server; 26 | 27 | declare type JSON = | string | number | boolean | null | JSONObject | JSONArray; 28 | declare type JSONObject = { [key: string]: JSON }; 29 | declare type JSONArray = Array; 30 | 31 | declare type SimpleHeader = { 32 | 'set-cookie'?: Array, 33 | [key: string]: string, 34 | }; 35 | 36 | declare type RequestJSON = { 37 | 'method': string, 38 | 'url': string, 39 | 'header': SimpleHeader, 40 | }; 41 | declare type RequestInspect = void|RequestJSON; 42 | declare type Request = { 43 | app: Application, 44 | req: http$IncomingMessage, 45 | res: http$ServerResponse, 46 | ctx: Context, 47 | response: Response, 48 | 49 | fresh: boolean, 50 | header: SimpleHeader, 51 | headers: SimpleHeader, // alias as header 52 | host: string, 53 | hostname: string, 54 | href: string, 55 | idempotent: boolean, 56 | ip: string, 57 | ips: string[], 58 | method: string, 59 | origin: string, 60 | originalUrl: string, 61 | path: string, 62 | protocol: string, 63 | query: {[key: string]: string}, // always string 64 | querystring: string, 65 | search: string, 66 | secure: boolean, // Shorthand for ctx.protocol == "https" to check if a request was issued via TLS. 67 | socket: net$Socket, 68 | stale: boolean, 69 | subdomains: string[], 70 | type: string, 71 | url: string, 72 | 73 | charset: string|void, 74 | length: number|void, 75 | 76 | // Those functions comes from https://github.com/jshttp/accepts/blob/master/index.js 77 | // request.js$L445 78 | // https://github.com/jshttp/accepts/blob/master/test/type.js 79 | accepts: ((args: string[]) => string|false)& 80 | // ToDo: There is an issue https://github.com/facebook/flow/issues/3009 81 | // if you meet some error here, temporarily add an additional annotation 82 | // like: `request.accepts((['json', 'text']:Array))` to fix it. 83 | ((arg: string, ...args: string[]) => string|false) & 84 | ( () => string[] ) , // return the old value. 85 | 86 | // https://github.com/jshttp/accepts/blob/master/index.js#L153 87 | // https://github.com/jshttp/accepts/blob/master/test/charset.js 88 | acceptsCharsets: ( (args: string[]) => buffer$Encoding|false)& 89 | // ToDo: https://github.com/facebook/flow/issues/3009 90 | // if you meet some error here, see L70. 91 | ( (arg: string, ...args: string[]) => buffer$Encoding|false ) & 92 | ( () => string[] ), 93 | 94 | // https://github.com/jshttp/accepts/blob/master/index.js#L119 95 | // https://github.com/jshttp/accepts/blob/master/test/encoding.js 96 | acceptsEncodings: ( (args: string[]) => string|false)& 97 | // ToDo: https://github.com/facebook/flow/issues/3009 98 | // if you meet some error here, see L70. 99 | ( (arg: string, ...args: string[]) => string|false ) & 100 | ( () => string[] ), 101 | 102 | // https://github.com/jshttp/accepts/blob/master/index.js#L185 103 | // https://github.com/jshttp/accepts/blob/master/test/language.js 104 | acceptsLanguages: ( (args: string[]) => string|false) & 105 | // ToDo: https://github.com/facebook/flow/issues/3009 106 | // if you meet some error here, see L70. 107 | ( (arg: string, ...args: string[]) => string|false ) & 108 | ( () => string[] ), 109 | 110 | get: (field: string) => string, 111 | 112 | /* https://github.com/jshttp/type-is/blob/master/test/test.js 113 | * Check if the incoming request contains the "Content-Type" 114 | * header field, and it contains any of the give mime `type`s. 115 | * If there is no request body, `null` is returned. 116 | * If there is no content type, `false` is returned. 117 | * Otherwise, it returns the first `type` that matches. 118 | */ 119 | is: ( (args: string[]) => null|false|string)& 120 | ( (arg: string, ...args: string[]) => null|false|string ) & 121 | ( () => string ), // should return the mime type 122 | 123 | toJSON: () => RequestJSON, 124 | inspect: () => RequestInspect, 125 | 126 | [key: string]: mixed, // props added by middlewares. 127 | }; 128 | 129 | declare type ResponseJSON = { 130 | 'status': mixed, 131 | 'message': mixed, 132 | 'header': mixed, 133 | }; 134 | declare type ResponseInspect = { 135 | 'status': mixed, 136 | 'message': mixed, 137 | 'header': mixed, 138 | 'body': mixed, 139 | }; 140 | declare type Response = { 141 | app: Application, 142 | req: http$IncomingMessage, 143 | res: http$ServerResponse, 144 | ctx: Context, 145 | request: Request, 146 | 147 | // docs/api/response.md#L113. 148 | body: string|Buffer|stream$Stream|Object|Array|null, // JSON contains null 149 | etag: string, 150 | header: SimpleHeader, 151 | headers: SimpleHeader, // alias as header 152 | headerSent: boolean, 153 | // can be set with string|Date, but get with Date. 154 | // set lastModified(v: string|Date), // 0.36 doesn't support this. 155 | lastModified: Date, 156 | message: string, 157 | socket: net$Socket, 158 | status: number, 159 | type: string, 160 | writable: boolean, 161 | 162 | // charset: string, // doesn't find in response.js 163 | length: number|void, 164 | 165 | append: (field: string, val: string | string[]) => void, 166 | attachment: (filename?: string) => void, 167 | get: (field: string) => string, 168 | // https://github.com/jshttp/type-is/blob/master/test/test.js 169 | // https://github.com/koajs/koa/blob/v2.x/lib/response.js#L382 170 | is: ( (arg: string[]) => false|string) & 171 | ( (arg: string, ...args: string[]) => false|string ) & 172 | ( () => string ), // should return the mime type 173 | redirect: (url: string, alt?: string) => void, 174 | remove: (field: string) => void, 175 | // https://github.com/koajs/koa/blob/v2.x/lib/response.js#L418 176 | set: ((field: string, val: string | string[]) => void)& 177 | ((field: {[key: string]: string | string[]}) => void), 178 | 179 | vary: (field: string) => void, 180 | 181 | // https://github.com/koajs/koa/blob/v2.x/lib/response.js#L519 182 | toJSON(): ResponseJSON, 183 | inspect(): ResponseInspect, 184 | 185 | [key: string]: mixed, // props added by middlewares. 186 | } 187 | 188 | declare type ContextJSON = { 189 | request: RequestJSON, 190 | response: ResponseJSON, 191 | app: ApplicationJSON, 192 | originalUrl: string, 193 | req: '', 194 | res: '', 195 | socket: '', 196 | }; 197 | // https://github.com/pillarjs/cookies 198 | declare type CookiesSetOptions = { 199 | maxAge: number, // milliseconds from Date.now() for expiry 200 | expires: Date, //cookie's expiration date (expires at the end of session by default). 201 | path: string, // the path of the cookie (/ by default). 202 | domain: string, // domain of the cookie (no default). 203 | secure: boolean, // false by default for HTTP, true by default for HTTPS 204 | httpOnly: boolean, // a boolean indicating whether the cookie is only to be sent over HTTP(S), 205 | // and not made available to client JavaScript (true by default). 206 | signed: boolean, // whether the cookie is to be signed (false by default) 207 | overwrite: boolean, // whether to overwrite previously set cookies of the same name (false by default). 208 | }; 209 | declare type Cookies = { 210 | get: (name: string, options?: {signed: boolean}) => string|void, 211 | set: ((name: string, value: string, options?: CookiesSetOptions) => Context)& 212 | // delete cookie (an outbound header with an expired date is used.) 213 | ( (name: string) => Context), 214 | }; 215 | // The default props of context come from two files 216 | // `application.createContext` & `context.js` 217 | declare type Context = { 218 | accept: $PropertyType, 219 | app: Application, 220 | cookies: Cookies, 221 | name?: string, // ? 222 | originalUrl: string, 223 | req: http$IncomingMessage, 224 | request: Request, 225 | res: http$ServerResponse, 226 | respond?: boolean, // should not be used, allow bypassing koa application.js#L193 227 | response: Response, 228 | state: Object, 229 | 230 | // context.js#L55 231 | assert: (test: mixed, status: number, message?: string, opts?: mixed) => void, 232 | // context.js#L107 233 | // if (!(err instanceof Error)) err = new Error(`non-error thrown: ${err}`); 234 | onerror: (err?: mixed) => void, 235 | // context.md#L88 236 | throw: ( status: number, msg?: string, opts?: Object) => void, 237 | toJSON(): ContextJSON, 238 | inspect(): ContextJSON, 239 | 240 | // ToDo: add const for some props, 241 | // while the `const props` feature of Flow is landing in future 242 | // cherry pick from response 243 | attachment: $PropertyType, 244 | redirect: $PropertyType, 245 | remove: $PropertyType, 246 | vary: $PropertyType, 247 | set: $PropertyType, 248 | append: $PropertyType, 249 | flushHeaders: $PropertyType, 250 | status: $PropertyType, 251 | message: $PropertyType, 252 | body: $PropertyType, 253 | length: $PropertyType, 254 | type: $PropertyType, 255 | lastModified: $PropertyType, 256 | etag: $PropertyType, 257 | headerSent: $PropertyType, 258 | writable: $PropertyType, 259 | 260 | // cherry pick from request 261 | acceptsLanguages: $PropertyType, 262 | acceptsEncodings: $PropertyType, 263 | acceptsCharsets: $PropertyType, 264 | accepts: $PropertyType, 265 | get: $PropertyType, 266 | is: $PropertyType, 267 | querystring: $PropertyType, 268 | idempotent: $PropertyType, 269 | socket: $PropertyType, 270 | search: $PropertyType, 271 | method: $PropertyType, 272 | query: $PropertyType, 273 | path: $PropertyType, 274 | url: $PropertyType, 275 | origin: $PropertyType, 276 | href: $PropertyType, 277 | subdomains: $PropertyType, 278 | protocol: $PropertyType, 279 | host: $PropertyType, 280 | hostname: $PropertyType, 281 | header: $PropertyType, 282 | headers: $PropertyType, 283 | secure: $PropertyType, 284 | stale: $PropertyType, 285 | fresh: $PropertyType, 286 | ips: $PropertyType, 287 | ip: $PropertyType, 288 | 289 | [key: string]: mixed, // props added by middlewares. 290 | } 291 | 292 | declare type Middleware = 293 | (ctx: Context, next: () => Promise) => Promise|void; 294 | declare type ApplicationJSON = { 295 | 'subdomainOffset': mixed, 296 | 'proxy': mixed, 297 | 'env': string, 298 | }; 299 | declare class Application extends events$EventEmitter { 300 | context: Context, 301 | // request handler for node's native http server. 302 | callback: () => (req: http$IncomingMessage, res: http$ServerResponse) => void, 303 | env: string, 304 | keys?: Array|Object, // https://github.com/crypto-utils/keygrip 305 | middleware: Array, 306 | proxy: boolean, // when true proxy header fields will be trusted 307 | request: Request, 308 | response: Response, 309 | server: Server, 310 | subdomainOffset: number, 311 | 312 | listen: $PropertyType, 313 | toJSON(): ApplicationJSON, 314 | inspect(): ApplicationJSON, 315 | use(fn: Middleware): this, 316 | } 317 | 318 | declare module.exports: Class; 319 | } 320 | -------------------------------------------------------------------------------- /flow-typed/npm/jest_v20.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 5fea44cc4b74e03b45bd39839c91ee2f 2 | // flow-typed version: c0702c8e54/jest_v20.x.x/flow_>=v0.33.x 3 | 4 | type JestMockFn = { 5 | (...args: Array): any, 6 | /** 7 | * An object for introspecting mock calls 8 | */ 9 | mock: { 10 | /** 11 | * An array that represents all calls that have been made into this mock 12 | * function. Each call is represented by an array of arguments that were 13 | * passed during the call. 14 | */ 15 | calls: Array>, 16 | /** 17 | * An array that contains all the object instances that have been 18 | * instantiated from this mock function. 19 | */ 20 | instances: mixed 21 | }, 22 | /** 23 | * Resets all information stored in the mockFn.mock.calls and 24 | * mockFn.mock.instances arrays. Often this is useful when you want to clean 25 | * up a mock's usage data between two assertions. 26 | */ 27 | mockClear(): Function, 28 | /** 29 | * Resets all information stored in the mock. This is useful when you want to 30 | * completely restore a mock back to its initial state. 31 | */ 32 | mockReset(): Function, 33 | /** 34 | * Removes the mock and restores the initial implementation. This is useful 35 | * when you want to mock functions in certain test cases and restore the 36 | * original implementation in others. Beware that mockFn.mockRestore only 37 | * works when mock was created with jest.spyOn. Thus you have to take care of 38 | * restoration yourself when manually assigning jest.fn(). 39 | */ 40 | mockRestore(): Function, 41 | /** 42 | * Accepts a function that should be used as the implementation of the mock. 43 | * The mock itself will still record all calls that go into and instances 44 | * that come from itself -- the only difference is that the implementation 45 | * will also be executed when the mock is called. 46 | */ 47 | mockImplementation(fn: Function): JestMockFn, 48 | /** 49 | * Accepts a function that will be used as an implementation of the mock for 50 | * one call to the mocked function. Can be chained so that multiple function 51 | * calls produce different results. 52 | */ 53 | mockImplementationOnce(fn: Function): JestMockFn, 54 | /** 55 | * Just a simple sugar function for returning `this` 56 | */ 57 | mockReturnThis(): void, 58 | /** 59 | * Deprecated: use jest.fn(() => value) instead 60 | */ 61 | mockReturnValue(value: any): JestMockFn, 62 | /** 63 | * Sugar for only returning a value once inside your mock 64 | */ 65 | mockReturnValueOnce(value: any): JestMockFn 66 | }; 67 | 68 | type JestAsymmetricEqualityType = { 69 | /** 70 | * A custom Jasmine equality tester 71 | */ 72 | asymmetricMatch(value: mixed): boolean 73 | }; 74 | 75 | type JestCallsType = { 76 | allArgs(): mixed, 77 | all(): mixed, 78 | any(): boolean, 79 | count(): number, 80 | first(): mixed, 81 | mostRecent(): mixed, 82 | reset(): void 83 | }; 84 | 85 | type JestClockType = { 86 | install(): void, 87 | mockDate(date: Date): void, 88 | tick(milliseconds?: number): void, 89 | uninstall(): void 90 | }; 91 | 92 | type JestMatcherResult = { 93 | message?: string | (() => string), 94 | pass: boolean 95 | }; 96 | 97 | type JestMatcher = (actual: any, expected: any) => JestMatcherResult; 98 | 99 | type JestPromiseType = { 100 | /** 101 | * Use rejects to unwrap the reason of a rejected promise so any other 102 | * matcher can be chained. If the promise is fulfilled the assertion fails. 103 | */ 104 | rejects: JestExpectType, 105 | /** 106 | * Use resolves to unwrap the value of a fulfilled promise so any other 107 | * matcher can be chained. If the promise is rejected the assertion fails. 108 | */ 109 | resolves: JestExpectType 110 | }; 111 | 112 | /** 113 | * Plugin: jest-enzyme 114 | */ 115 | type EnzymeMatchersType = { 116 | toBeChecked(): void, 117 | toBeDisabled(): void, 118 | toBeEmpty(): void, 119 | toBePresent(): void, 120 | toContainReact(component: React$Element): void, 121 | toHaveClassName(className: string): void, 122 | toHaveHTML(html: string): void, 123 | toHaveProp(propKey: string, propValue?: any): void, 124 | toHaveRef(refName: string): void, 125 | toHaveState(stateKey: string, stateValue?: any): void, 126 | toHaveStyle(styleKey: string, styleValue?: any): void, 127 | toHaveTagName(tagName: string): void, 128 | toHaveText(text: string): void, 129 | toIncludeText(text: string): void, 130 | toHaveValue(value: any): void, 131 | toMatchSelector(selector: string): void, 132 | }; 133 | 134 | type JestExpectType = { 135 | not: JestExpectType & EnzymeMatchersType, 136 | /** 137 | * If you have a mock function, you can use .lastCalledWith to test what 138 | * arguments it was last called with. 139 | */ 140 | lastCalledWith(...args: Array): void, 141 | /** 142 | * toBe just checks that a value is what you expect. It uses === to check 143 | * strict equality. 144 | */ 145 | toBe(value: any): void, 146 | /** 147 | * Use .toHaveBeenCalled to ensure that a mock function got called. 148 | */ 149 | toBeCalled(): void, 150 | /** 151 | * Use .toBeCalledWith to ensure that a mock function was called with 152 | * specific arguments. 153 | */ 154 | toBeCalledWith(...args: Array): void, 155 | /** 156 | * Using exact equality with floating point numbers is a bad idea. Rounding 157 | * means that intuitive things fail. 158 | */ 159 | toBeCloseTo(num: number, delta: any): void, 160 | /** 161 | * Use .toBeDefined to check that a variable is not undefined. 162 | */ 163 | toBeDefined(): void, 164 | /** 165 | * Use .toBeFalsy when you don't care what a value is, you just want to 166 | * ensure a value is false in a boolean context. 167 | */ 168 | toBeFalsy(): void, 169 | /** 170 | * To compare floating point numbers, you can use toBeGreaterThan. 171 | */ 172 | toBeGreaterThan(number: number): void, 173 | /** 174 | * To compare floating point numbers, you can use toBeGreaterThanOrEqual. 175 | */ 176 | toBeGreaterThanOrEqual(number: number): void, 177 | /** 178 | * To compare floating point numbers, you can use toBeLessThan. 179 | */ 180 | toBeLessThan(number: number): void, 181 | /** 182 | * To compare floating point numbers, you can use toBeLessThanOrEqual. 183 | */ 184 | toBeLessThanOrEqual(number: number): void, 185 | /** 186 | * Use .toBeInstanceOf(Class) to check that an object is an instance of a 187 | * class. 188 | */ 189 | toBeInstanceOf(cls: Class<*>): void, 190 | /** 191 | * .toBeNull() is the same as .toBe(null) but the error messages are a bit 192 | * nicer. 193 | */ 194 | toBeNull(): void, 195 | /** 196 | * Use .toBeTruthy when you don't care what a value is, you just want to 197 | * ensure a value is true in a boolean context. 198 | */ 199 | toBeTruthy(): void, 200 | /** 201 | * Use .toBeUndefined to check that a variable is undefined. 202 | */ 203 | toBeUndefined(): void, 204 | /** 205 | * Use .toContain when you want to check that an item is in a list. For 206 | * testing the items in the list, this uses ===, a strict equality check. 207 | */ 208 | toContain(item: any): void, 209 | /** 210 | * Use .toContainEqual when you want to check that an item is in a list. For 211 | * testing the items in the list, this matcher recursively checks the 212 | * equality of all fields, rather than checking for object identity. 213 | */ 214 | toContainEqual(item: any): void, 215 | /** 216 | * Use .toEqual when you want to check that two objects have the same value. 217 | * This matcher recursively checks the equality of all fields, rather than 218 | * checking for object identity. 219 | */ 220 | toEqual(value: any): void, 221 | /** 222 | * Use .toHaveBeenCalled to ensure that a mock function got called. 223 | */ 224 | toHaveBeenCalled(): void, 225 | /** 226 | * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact 227 | * number of times. 228 | */ 229 | toHaveBeenCalledTimes(number: number): void, 230 | /** 231 | * Use .toHaveBeenCalledWith to ensure that a mock function was called with 232 | * specific arguments. 233 | */ 234 | toHaveBeenCalledWith(...args: Array): void, 235 | /** 236 | * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called 237 | * with specific arguments. 238 | */ 239 | toHaveBeenLastCalledWith(...args: Array): void, 240 | /** 241 | * Check that an object has a .length property and it is set to a certain 242 | * numeric value. 243 | */ 244 | toHaveLength(number: number): void, 245 | /** 246 | * 247 | */ 248 | toHaveProperty(propPath: string, value?: any): void, 249 | /** 250 | * Use .toMatch to check that a string matches a regular expression. 251 | */ 252 | toMatch(regexp: RegExp): void, 253 | /** 254 | * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. 255 | */ 256 | toMatchObject(object: Object): void, 257 | /** 258 | * This ensures that a React component matches the most recent snapshot. 259 | */ 260 | toMatchSnapshot(name?: string): void, 261 | /** 262 | * Use .toThrow to test that a function throws when it is called. 263 | * If you want to test that a specific error gets thrown, you can provide an 264 | * argument to toThrow. The argument can be a string for the error message, 265 | * a class for the error, or a regex that should match the error. 266 | * 267 | * Alias: .toThrowError 268 | */ 269 | toThrow(message?: string | Error | RegExp): void, 270 | toThrowError(message?: string | Error | RegExp): void, 271 | /** 272 | * Use .toThrowErrorMatchingSnapshot to test that a function throws a error 273 | * matching the most recent snapshot when it is called. 274 | */ 275 | toThrowErrorMatchingSnapshot(): void 276 | }; 277 | 278 | type JestObjectType = { 279 | /** 280 | * Disables automatic mocking in the module loader. 281 | * 282 | * After this method is called, all `require()`s will return the real 283 | * versions of each module (rather than a mocked version). 284 | */ 285 | disableAutomock(): JestObjectType, 286 | /** 287 | * An un-hoisted version of disableAutomock 288 | */ 289 | autoMockOff(): JestObjectType, 290 | /** 291 | * Enables automatic mocking in the module loader. 292 | */ 293 | enableAutomock(): JestObjectType, 294 | /** 295 | * An un-hoisted version of enableAutomock 296 | */ 297 | autoMockOn(): JestObjectType, 298 | /** 299 | * Clears the mock.calls and mock.instances properties of all mocks. 300 | * Equivalent to calling .mockClear() on every mocked function. 301 | */ 302 | clearAllMocks(): JestObjectType, 303 | /** 304 | * Resets the state of all mocks. Equivalent to calling .mockReset() on every 305 | * mocked function. 306 | */ 307 | resetAllMocks(): JestObjectType, 308 | /** 309 | * Removes any pending timers from the timer system. 310 | */ 311 | clearAllTimers(): void, 312 | /** 313 | * The same as `mock` but not moved to the top of the expectation by 314 | * babel-jest. 315 | */ 316 | doMock(moduleName: string, moduleFactory?: any): JestObjectType, 317 | /** 318 | * The same as `unmock` but not moved to the top of the expectation by 319 | * babel-jest. 320 | */ 321 | dontMock(moduleName: string): JestObjectType, 322 | /** 323 | * Returns a new, unused mock function. Optionally takes a mock 324 | * implementation. 325 | */ 326 | fn(implementation?: Function): JestMockFn, 327 | /** 328 | * Determines if the given function is a mocked function. 329 | */ 330 | isMockFunction(fn: Function): boolean, 331 | /** 332 | * Given the name of a module, use the automatic mocking system to generate a 333 | * mocked version of the module for you. 334 | */ 335 | genMockFromModule(moduleName: string): any, 336 | /** 337 | * Mocks a module with an auto-mocked version when it is being required. 338 | * 339 | * The second argument can be used to specify an explicit module factory that 340 | * is being run instead of using Jest's automocking feature. 341 | * 342 | * The third argument can be used to create virtual mocks -- mocks of modules 343 | * that don't exist anywhere in the system. 344 | */ 345 | mock( 346 | moduleName: string, 347 | moduleFactory?: any, 348 | options?: Object 349 | ): JestObjectType, 350 | /** 351 | * Resets the module registry - the cache of all required modules. This is 352 | * useful to isolate modules where local state might conflict between tests. 353 | */ 354 | resetModules(): JestObjectType, 355 | /** 356 | * Exhausts the micro-task queue (usually interfaced in node via 357 | * process.nextTick). 358 | */ 359 | runAllTicks(): void, 360 | /** 361 | * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), 362 | * setInterval(), and setImmediate()). 363 | */ 364 | runAllTimers(): void, 365 | /** 366 | * Exhausts all tasks queued by setImmediate(). 367 | */ 368 | runAllImmediates(): void, 369 | /** 370 | * Executes only the macro task queue (i.e. all tasks queued by setTimeout() 371 | * or setInterval() and setImmediate()). 372 | */ 373 | runTimersToTime(msToRun: number): void, 374 | /** 375 | * Executes only the macro-tasks that are currently pending (i.e., only the 376 | * tasks that have been queued by setTimeout() or setInterval() up to this 377 | * point) 378 | */ 379 | runOnlyPendingTimers(): void, 380 | /** 381 | * Explicitly supplies the mock object that the module system should return 382 | * for the specified module. Note: It is recommended to use jest.mock() 383 | * instead. 384 | */ 385 | setMock(moduleName: string, moduleExports: any): JestObjectType, 386 | /** 387 | * Indicates that the module system should never return a mocked version of 388 | * the specified module from require() (e.g. that it should always return the 389 | * real module). 390 | */ 391 | unmock(moduleName: string): JestObjectType, 392 | /** 393 | * Instructs Jest to use fake versions of the standard timer functions 394 | * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, 395 | * setImmediate and clearImmediate). 396 | */ 397 | useFakeTimers(): JestObjectType, 398 | /** 399 | * Instructs Jest to use the real versions of the standard timer functions. 400 | */ 401 | useRealTimers(): JestObjectType, 402 | /** 403 | * Creates a mock function similar to jest.fn but also tracks calls to 404 | * object[methodName]. 405 | */ 406 | spyOn(object: Object, methodName: string): JestMockFn 407 | }; 408 | 409 | type JestSpyType = { 410 | calls: JestCallsType 411 | }; 412 | 413 | /** Runs this function after every test inside this context */ 414 | declare function afterEach(fn: Function): void; 415 | /** Runs this function before every test inside this context */ 416 | declare function beforeEach(fn: Function): void; 417 | /** Runs this function after all tests have finished inside this context */ 418 | declare function afterAll(fn: Function): void; 419 | /** Runs this function before any tests have started inside this context */ 420 | declare function beforeAll(fn: Function): void; 421 | /** A context for grouping tests together */ 422 | declare function describe(name: string, fn: Function): void; 423 | 424 | /** An individual test unit */ 425 | declare var it: { 426 | /** 427 | * An individual test unit 428 | * 429 | * @param {string} Name of Test 430 | * @param {Function} Test 431 | */ 432 | (name: string, fn?: Function): ?Promise, 433 | /** 434 | * Only run this test 435 | * 436 | * @param {string} Name of Test 437 | * @param {Function} Test 438 | */ 439 | only(name: string, fn?: Function): ?Promise, 440 | /** 441 | * Skip running this test 442 | * 443 | * @param {string} Name of Test 444 | * @param {Function} Test 445 | */ 446 | skip(name: string, fn?: Function): ?Promise, 447 | /** 448 | * Run the test concurrently 449 | * 450 | * @param {string} Name of Test 451 | * @param {Function} Test 452 | */ 453 | concurrent(name: string, fn?: Function): ?Promise 454 | }; 455 | declare function fit(name: string, fn: Function): ?Promise; 456 | /** An individual test unit */ 457 | declare var test: typeof it; 458 | /** A disabled group of tests */ 459 | declare var xdescribe: typeof describe; 460 | /** A focused group of tests */ 461 | declare var fdescribe: typeof describe; 462 | /** A disabled individual test */ 463 | declare var xit: typeof it; 464 | /** A disabled individual test */ 465 | declare var xtest: typeof it; 466 | 467 | /** The expect function is used every time you want to test a value */ 468 | declare var expect: { 469 | /** The object that you want to make assertions against */ 470 | (value: any): JestExpectType & JestPromiseType & EnzymeMatchersType, 471 | /** Add additional Jasmine matchers to Jest's roster */ 472 | extend(matchers: { [name: string]: JestMatcher }): void, 473 | /** Add a module that formats application-specific data structures. */ 474 | addSnapshotSerializer(serializer: (input: Object) => string): void, 475 | assertions(expectedAssertions: number): void, 476 | hasAssertions(): void, 477 | any(value: mixed): JestAsymmetricEqualityType, 478 | anything(): void, 479 | arrayContaining(value: Array): void, 480 | objectContaining(value: Object): void, 481 | /** Matches any received string that contains the exact expected string. */ 482 | stringContaining(value: string): void, 483 | stringMatching(value: string | RegExp): void 484 | }; 485 | 486 | // TODO handle return type 487 | // http://jasmine.github.io/2.4/introduction.html#section-Spies 488 | declare function spyOn(value: mixed, method: string): Object; 489 | 490 | /** Holds all functions related to manipulating test runner */ 491 | declare var jest: JestObjectType; 492 | 493 | /** 494 | * The global Jamine object, this is generally not exposed as the public API, 495 | * using features inside here could break in later versions of Jest. 496 | */ 497 | declare var jasmine: { 498 | DEFAULT_TIMEOUT_INTERVAL: number, 499 | any(value: mixed): JestAsymmetricEqualityType, 500 | anything(): void, 501 | arrayContaining(value: Array): void, 502 | clock(): JestClockType, 503 | createSpy(name: string): JestSpyType, 504 | createSpyObj( 505 | baseName: string, 506 | methodNames: Array 507 | ): { [methodName: string]: JestSpyType }, 508 | objectContaining(value: Object): void, 509 | stringMatching(value: string): void 510 | }; 511 | --------------------------------------------------------------------------------