-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (29 loc) · 985 Bytes
/
server.js
File metadata and controls
34 lines (29 loc) · 985 Bytes
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
require('dotenv/config');
const mongoose = require('mongoose');
const {graphqlUploadExpress} = require('graphql-upload');
const {join} = require('path')
const app = require('./app');
const apolloServer = require('./apollo');
require('./Helpers/Jobs');
async function startServer() {
app.use(graphqlUploadExpress());
await apolloServer.start();
apolloServer.applyMiddleware({app});
app.use('/', (req, res) => {
res.send("Welcome to Super OTT Platform!")
})
}
startServer();
mongoose.connect(process.env.MONGODB_LOCAL_URL, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
useFindAndModify: false
})
.then(() => console.log("MongoDB Connected Successfully!"))
.catch((err) => console.log("MongoDB Connection Failed"));
const port = process.env.PORT || 3001
app.listen(port, () => {
console.log(`App is running on port ${port}`);
console.log(`GraphQl EndPoint path: ${apolloServer.graphqlPath}`);
})