-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (31 loc) · 953 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
36
37
38
39
const express = require('express');
const bodyParser = require('body-parser');
const graphqlHTTP = require('express-graphql');
const mongoose = require('mongoose');
const keys = require('./config/keys');
require('./models/Event');
require('./models/User');
require('./models/Booking');
const graphqlSchema = require('./graphql/schema');
const graphqlResolvers = require('./graphql/resolvers');
const requireLogin = require('./middlewares/requireLogin');
const app = express();
app.use(bodyParser.json());
app.use(requireLogin);
app.use(
'/graphql',
graphqlHTTP({
schema: graphqlSchema,
rootValue: graphqlResolvers,
graphiql: true
})
);
const PORT = process.env.PORT || 5000;
mongoose
.connect(
`mongodb+srv://${keys.mongoUser}:${
keys.mongoPassword
}@cluster0-wxsmq.mongodb.net/${keys.mongoDb}?retryWrites=true&w=majority`
)
.then(app.listen(PORT, () => console.log(`Listening on ${PORT}`)))
.catch(err => console.log(err));