Advertisement
Guest User

Untitled

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