-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·35 lines (26 loc) · 928 Bytes
/
index.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
35
import express from 'express';
import mongoose from 'mongoose';
import bodyParser from 'body-parser';
import movieRouter from './Routes/movieRoutes';
import config from './config';
const App = express();
const port = process.env.PORT || 3000;
App.use(bodyParser.urlencoded({extended:true}));
App.use(bodyParser.json());
//const movieRouter = require('./Routes/movieRoutes');
Promise = require('bluebird');
// plugin bluebird promise in mongoose
mongoose.Promise = Promise;
const mongoUri = config.mongo.host;
mongoose.connect(mongoUri, { server: { socketOptions: { keepAlive: 1 } } });
mongoose.connection.on('error', () => {
throw new Error(`unable to connect to database: ${mongoUri}`);
});
App.use('/api/movies', movieRouter);
App.get('/', (req, res)=>{
res.send('welcome to my the movie API!');
});
App.listen(port, ()=>{
console.log('Gulp is running my app on PORT: ' + port);
});
export default App;