-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (23 loc) · 848 Bytes
/
app.js
File metadata and controls
30 lines (23 loc) · 848 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
const express = require('express');
const mongoose = require('mongoose');
const graphqlHTTP = require('express-graphql');
const schema = require('./schema/schema');
const cors = require('cors');
const PORT = process.env.PORT || 5000;
const app = express();
app.use(cors());
mongoose.connect('mongodb://gqluser:gqluser123@gql-shard-00-00.bvfhu.mongodb.net:27017,gql-shard-00-01.bvfhu.mongodb.net:27017,gql-shard-00-02.bvfhu.mongodb.net:27017/test?replicaSet=atlas-t5g64z-shard-0&ssl=true&authSource=admin')
mongoose.connection.once('open', () => {
console.log('conneted to database');
});
app.get("/", (req, res) => {
console.log("received")
res.send({data: "OK"})
})
app.use('/graphql', graphqlHTTP({
schema,
graphiql: true
}));
app.listen(PORT, () => {
console.log(`now listening for requests on port ${PORT}`);
});