text: // MongoDB PW: ivCemDMfIdzisEgj
  
  // MongoDB connection: mongodb+srv://Amisha4real:<password>@amisha-u2dvc.mongodb.net/test?retryWrites=true&w=majority
  
  const express = require('express');
  const bodyParser = require('body-parser');
  const mongoose = require('mongoose');
  const path = require('path');
  
  const stuffRoute = require('./routes/stuff');
  const userRoutes = require('./routes/user');
  
  const app = express();
  
  mongoose
    .connect(
      'mongodb+srv://Amisha4real:ivCemDMfIdzisEgj@amisha-u2dvc.mongodb.net/test?retryWrites=true&w=majority'
    )
    .then(() => {
      console.log('Successfully connected to MongoDB Atlas!');
    })
    .catch(error => {
      console.log('Unable to connect to MongoDB Atlas!');
      console.error(error);
    });
  
  app.use((req, res, next) => {
    res.setHeader('Access-Control-Allow-origin', '*');
    res.setHeader(
      'Access-Control-Allow-Headers',
      'Origin, X-Requested-With, Content, Accept, Content-Type, Authorization'
    );
    res.setHeader(
      'Access-Control-Allow-Methods',
      'GET, POST, PUT, DELETE, PATCH, OPTIONS'
    );
    next();
  });
  
  app.use(bodyParser.json());
  app.use('/images', express.static(path.join(__dirname, 'images')));
  
  app.use('/api/stuff', stuffRoute);
  app.use('/api/auth', userRoutes);
  
  module.exports = app;
  