forked from noahgribbin/Cornucopia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (27 loc) · 975 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const express = require('express');
const cors = require('cors');
const morgan = require('morgan');
const debug = require('debug')('cornucopia:server');
const Promise = require('bluebird');
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const errors = require('./lib/error-middleware.js');
const authRouter = require('./route/auth-router.js');
const profileRouter = require('./route/profile-router.js');
const recipeRouter = require('./route/recipe-router.js');
const commentRouter = require('./route/comment-router.js');
const upvoteRouter = require('./route/upvote-router.js');
dotenv.load();
const app = express();
mongoose.Promise = Promise;
mongoose.connect(process.env.MONGODB_URI);
app.use(cors());
app.use(morgan('dev'));
app.use(authRouter);
app.use(profileRouter);
app.use(recipeRouter);
app.use(commentRouter);
app.use(upvoteRouter);
app.use(errors);
app.listen((process.env.PORT || 8000), () => debug('server up!'));