text: const express = require('express');
  const path = require('path');
  const db = require('./config/connection');
  const routes = require('./routes');
  const { ApolloServer } = require('apollo-server-express');
  const { authMiddleware } = require('./utils/auth');
  
  const { typeDefs, resolvers } = require('./schemas');
  
  
  const app = express();
  const PORT = process.env.PORT || 3001;
  
  const server = new ApolloServer({
    typeDefs,
    resolvers,
    context: authMiddleware,
  });
  
  server.start().then(() => {
    server.applyMiddleware({ app });
  
    app.use(express.urlencoded({ extended: true }));
    app.use(express.json());
  
  // if we're in production, serve client/build as static assets
  // if (process.env.NODE_ENV === 'production') {
  //   app.use(express.static(path.join(__dirname, '../client/build')));
  // }
   app.get('/*', function(req, res) {
     res.sendFile(path.join(__dirname, '../client/src/App.js'), function(err) {
       if (err) {
         res.status(500).send(err)
       }
     })
   })
  
  app.use(routes);
  
  db.once('open', () => {
    app.listen(PORT, () => console.log(`🌍 Now listening on localhost:${PORT}`));
  });
  })
  