-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
32 lines (25 loc) · 771 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
const express = require('express');
const mongoose = require('mongoose');
const graphqlHttp = require('express-graphql');
const schema = require('./graphql/schema/index');
const resolvers = require('./graphql/resolvers/index');
const auth = require('./middleware/auth');
const app = express();
app.use(express.json());
app.use(auth);
app.use('/graphql', graphqlHttp({
schema: schema,
rootValue: resolvers,
graphiql: true,
}));
mongoose
.connect(
`mongodb+srv://${process.env.MONGO_USERNAME}:${process.env.MONGO_PASSWORD}@cluster0-ksfag.mongodb.net/${process.env.MONGO_DB}?retryWrites=true`, {
useNewUrlParser: true
},
)
.then(() => {
app.listen(3000);
})
// eslint-disable-next-line no-console
.catch(err => console.error(err));