Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. if (true) {
  2. // app.get('/', (req, res) => {
  3. // res.sendFile(path.resolve('build/index.html'));
  4. // });
  5. // app.use(express.static(__dirname + '/dist'));
  6. const staticPath = path.join(__dirname, '../../build');
  7.  
  8. console.log('Production, serving static files from ' + staticPath);
  9. console.log(path.resolve('/build'))
  10. console.log(path.resolve('build'))
  11. console.log(path.resolve('build/'))
  12.  
  13. app.use(express.static(path.resolve('build')));
  14. } else {
  15. console.log('Env is not production, not serving any static files.');
  16. }
  17.  
  18. app.use('/graphql', bodyParser.json(),
  19. graphqlExpress({
  20. context: { mongo },
  21. schema,
  22. })
  23. );
  24.  
  25. app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
  26.  
  27. app.listen(3000, () => {
  28. console.log(`Go to http://localhost:${process.env.PORT || DEFAULT_PORT}/graphiql to run queries!`);
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement