-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (26 loc) · 924 Bytes
/
app.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
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const logger = require('morgan');
const mongoose = require('mongoose');
const route = require('./src/routes');
const app = express();
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'src/views'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use('/', express.static(path.join(__dirname, 'public')));
app.use('upload', express.static(path.join(__dirname, 'upload')));
app.use('/', route);
mongoose.connect(process.env.MONGODB_ATLAS_URI, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
user: process.env.MONGODB_ATLAS_USER,
pass: process.env.MONGODB_ATLAS_PASS,
dbName: process.env.MONGODB_ATLAS_DBNAME,
}, () => {
console.log('Connect to MongoDB successful');
});
module.exports = app;