SHARE
TWEET

Untitled

a guest Nov 19th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Deps.
  2. const express = require('express');
  3. const mongoose = require('mongoose');
  4. const bodyParser = require('body-parser');
  5. const path = require('path');
  6.  
  7.  
  8. //Setup and connect to db.
  9. mongoose.connect('mongodb+srv://TU_USERR:TU_CLAVE@EL_HOST?retryWrites=true&w=majority', { useNewUrlParser: true, useUnifiedTopology: true});
  10. //mongoose.connect('mongodb://localhost:27017/reserve', { useNewUrlParser: true, useUnifiedTopology: true});
  11. const db = mongoose.connection;
  12. if(!db)
  13.     console.log("Error connecting db");
  14. else
  15.     console.log("Db connected successfully");
  16.  
  17.  
  18.  
  19. //Setting up the app and its routes.
  20. var homeRoutes = require('./routes/indexRoutes');
  21. var usersRoutes = require('./routes/userRoutes');
  22. var resRoutes = require('./routes/restaurantRoutes');
  23. var catRoutes = require('./routes/categoryRoutes');
  24. var reservationRoutes = require('./routes/reservationRoutes');
  25.  
  26. var app = express();
  27.  
  28. app.use(bodyParser.urlencoded({
  29.     extended: true
  30.  }));
  31. app.use(bodyParser.json());
  32. app.use(express.static(path.join(__dirname, 'public')));
  33.  
  34. app.use('/api', homeRoutes);
  35. app.use('/api/users', usersRoutes);
  36. app.use('/api/restaurant', resRoutes);
  37. app.use('/api/category', catRoutes);
  38. app.use('/api/reservation', reservationRoutes);
  39.  
  40. //Catch 404 and forward to error handler
  41. app.use(function(req, res) {
  42.     res.send("Error");
  43.   });
  44.  
  45.  
  46.  
  47. module.exports = app;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top