-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpress.js
28 lines (22 loc) · 977 Bytes
/
express.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
const express = require('express');
var cors = require('cors')
const app = express();
const bodyParser = require('body-parser');
const sourceDir = 'dist';
const mongoose = require('mongoose');
const port = process.env.PORT || 8082;
app.use(express.static(sourceDir));
app.use(cors());
// Body Parser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/api', require('./src/server/routes/comments'));
const uri = 'mongodb://koby:[email protected]:27017,bigpandaownz-shard-00-01-sdkkk.mongodb.net:27017,bigpandaownz-shard-00-02-sdkkk.mongodb.net:27017/test?ssl=true&replicaSet=BigPandaOwnz-shard-0&authSource=admin&retryWrites=true';
mongoose.connect(uri).then(
() => console.log('connected'),
err => console.log('not connected', err)
);
app.listen(port, () => {
console.log(`Express web server started: http://localhost:${port}`);
console.log(`Serving content from /${sourceDir}/`);
});