text: const express = require('express');
  const mongoose = require('mongoose');
  const path = require('path');
  const PORT = process.env.PORT || 8080;
  const app = express();
  const routes = require('./routes');
  
  // Define middleware here
  app.use(express.urlencoded({ extended: true }));
  app.use(express.json());
  // Serve up static assets (usually on heroku)
  // if (process.env.NODE_ENV === 'production') {
  app.use(express.static('client/build'));
  // }
  
  // app.use(function (req, res, next) {
  //   // Website you wish to allow to connect
  //   res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
  
  //   // Request methods you wish to allow
  //   res.setHeader(
  //     'Access-Control-Allow-Methods',
  //     'GET, POST, OPTIONS, PUT, PATCH, DELETE'
  //   );
  
  //   // Request headers you wish to allow
  //   res.setHeader(
  //     'Access-Control-Allow-Headers',
  //     'X-Requested-With,content-type'
  //   );
  
  //   // Set to true if you need the website to include cookies in the requests sent
  //   // to the API (e.g. in case you use sessions)
  //   res.setHeader('Access-Control-Allow-Credentials', true);
  
  //   // Pass to next layer of middleware
  //   next();
  // });
  
  // Add routes, both API and view
  app.use(routes);
  
  // Send every other request to the React app
  // Define any API routes before this runs
  app.get('*', (req, res) => {
    res.sendFile(path.join(__dirname, './client/build/index.html'));
  });
  
  // Connect to the Mongo DB
  mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/googlebooks');
  
  app.listen(PORT, () => {
    console.log(`🌎 ==> API server now on port ${PORT}!`);
  });
  