aboutsummaryrefslogblamecommitdiff
path: root/server/main.js
blob: bdcf9a4d221bf31dcaf4a5fe06fc320ab8c90546 (plain) (tree)
1
2
3
4


                                     
                                     














                                                                                          


                               


                                                                       
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const passport = require('passport');

const {port, mongoUrl} = require("./config/env");
const apiRoutes = require('./routes/api');

mongoose.connect(mongoUrl, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  useFindAndModify: false
});

mongoose.connection.on('error', console.error.bind(console, 'connection error:'));
mongoose.connection.once('open', () => console.log("Successfully connected to MongoDB!"));

app.use(express.json());

require('./config/passport');
app.use(passport.initialize());

app.use('/api', apiRoutes);

app.listen(port, () => console.log(`Server started on port ${port}.`));