Last active
May 15, 2019 20:10
-
-
Save baconcheese113/edbc738379a53792dd3cce0f4c8ad5ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "client", | |
"version": "0.1.0", | |
"private": true, | |
"dependencies": { | |
"apollo-boost": "^0.3.1", | |
"axios": "^0.18.0", | |
"graphql": "^14.1.1", | |
"react": "^16.8.4", | |
"react-apollo": "^2.5.3", | |
"react-apollo-hooks": "^0.4.4", | |
"react-dom": "^16.8.4", | |
"react-scripts": "2.1.8", | |
"socket.io": "^2.2.0", | |
"socket.io-client": "^2.2.0", | |
"styled-components": "^4.2.0" | |
}, | |
"scripts": { | |
"start": "react-scripts start", | |
"build": "react-scripts build", | |
"test": "react-scripts test", | |
"eject": "react-scripts eject", | |
"lint-staged": { | |
"*.{js,jsx}": [ | |
"pretty-quick --staged", | |
"eslint src/ --fix", | |
"git add" | |
] | |
} | |
}, | |
"eslintConfig": { | |
"extends": "react-app" | |
}, | |
"browserslist": [ | |
">0.2%", | |
"not dead", | |
"not ie <= 11", | |
"not op_mini all" | |
], | |
"proxy": { | |
"/api": { | |
"target": "http://localhost:5000", | |
"pathRewrite": { | |
"^/api": "/" | |
} | |
} | |
}, | |
"homepage": "./", | |
"devDependencies": { | |
"eslint": "^5.16.0", | |
"eslint-config-airbnb": "^17.1.0", | |
"eslint-config-prettier": "^4.2.0", | |
"eslint-plugin-import": "^2.17.2", | |
"eslint-plugin-jsx-a11y": "^6.2.1", | |
"eslint-plugin-prettier": "^3.1.0", | |
"eslint-plugin-react": "^7.13.0", | |
"husky": "^2.2.0", | |
"lint-staged": "^8.1.6", | |
"prettier": "^1.17.0", | |
"pretty-quick": "^1.10.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "graphql-webrtc", | |
"version": "1.0.0", | |
"description": "", | |
"engines": { | |
"node": "10.x" | |
}, | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start:server": "cd server && npm start", | |
"start:client": "cd client && npm start", | |
"build:server": "cd server && npm run build", | |
"build:client": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build", | |
"start": "npm run start:server && npm run start:client", | |
"build": "npm run build:server", | |
"heroku-postbuild": "npm run build:client && npm run build:server" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '@babel/polyfill/noConflict'; | |
import server from './server'; | |
import express from 'express'; | |
import jwt from 'jsonwebtoken'; | |
import cookieParser from 'cookie-parser'; | |
import path from 'path'; | |
const http = require('http').Server(server.express); | |
const io = require('socket.io')(http); | |
require('./socket')(io); | |
if (process.env.NODE_ENV === 'production') { | |
server.express.use( | |
express.static(path.join(__dirname, '../../client/build')) | |
); | |
server.express.get('/*', function(req, res) { | |
res.sendFile(path.join(__dirname, '../../client/build', 'index.html')); | |
}); | |
} else { | |
server.express.get('/*', (req, res) => { | |
res.sendFile(path.join(__dirname, '../../client/public', 'index.html')); | |
}); | |
} | |
server.express.use(cookieParser()); | |
server.express.use((req, res, next) => { | |
if (!req.cookies || !req.cookies.token) { | |
return next(); | |
} | |
const { token } = req.cookies; | |
if (token) { | |
console.log(process.env.SOCKET_PORT); | |
const { userId } = jwt.verify(token, process.env.JWT_SECRET); | |
// Put the userId onto the req for future requests to access | |
req.userId = userId; | |
} | |
next(); | |
}); | |
// Socket-io listener | |
http.listen( | |
{ port: process.env.PORT || 5000 }, //, host: process.env.DOMAIN }, | |
() => console.log('listening on port ' + process.env.PORT || 5000) | |
); | |
// GraphQL and app listener | |
server.start( | |
{ | |
cors: { | |
credentials: true, | |
origin: '/' //process.env.DOMAIN_FULL + ':' + process.env.CLIENT_PORT | |
} | |
// port: process.env.PORT || 4000 | |
}, | |
() => { | |
console.log('The server is up!'); | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "server", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node dist/index.js", | |
"build": "npm install && npm install --only=dev --no-shrinkwrap", | |
"postbuild": "babel src --out-dir dist --copy-files", | |
"test": "env-cmd ./config/test.env jest --watch --runInBand", | |
"dev": "env-cmd ./config/dev.env nodemon --inspect src/index.js --exec babel-node --ext .js,.json,.graphql", | |
"get-schema": "graphql get-schema -p prisma --dotenv config/dev.env" | |
}, | |
"jest": { | |
"globalSetup": "./tests/jest/globalSetup.js", | |
"globalTeardown": "./tests/jest/globalTeardown.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@babel/polyfill": "^7.4.0", | |
"apollo-boost": "^0.3.1", | |
"babel-register": "^6.26.0", | |
"bcryptjs": "^2.4.3", | |
"cookie-parser": "^1.4.4", | |
"cors": "^2.8.5", | |
"cross-fetch": "^3.0.1", | |
"env-cmd": "^8.0.2", | |
"graphql": "^14.1.1", | |
"graphql-yoga": "^1.17.4", | |
"jsonwebtoken": "^8.5.1", | |
"prisma-binding": "^2.3.9", | |
"socket.io": "^2.2.0" | |
}, | |
"devDependencies": { | |
"@babel/cli": "^7.0.0", | |
"@babel/core": "^7.0.0", | |
"@babel/node": "^7.0.0", | |
"@babel/preset-env": "^7.0.0", | |
"graphql-cli": "^3.0.11", | |
"jest": "^24.5.0", | |
"nodemon": "^1.18.10" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GraphQLServer, PubSub } from 'graphql-yoga'; | |
import {resolvers, fragmentReplacements} from './resolvers/index' | |
import prisma from './prisma' | |
const pubsub = new PubSub() | |
export default new GraphQLServer({ | |
typeDefs: './src/schema.graphql', | |
resolvers, | |
context(request) { | |
return { | |
pubsub, | |
prisma, | |
request, //fragmentReplacements[], request, response | |
} | |
}, | |
fragmentReplacements, | |
debug: true, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment