-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (34 loc) · 950 Bytes
/
app.js
File metadata and controls
38 lines (34 loc) · 950 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
34
35
36
37
38
// ytits2m
const express = require("express");
var { graphqlHTTP } = require("express-graphql");
const schema = require("./server/schema/schema");
const testSchema = require("./server/schema/types_schema");
const mongoose = require("mongoose");
const app = express();
const port = process.env.PORT || 4000;
const cors = require("cors");
app.use(cors());
app.use(
"/graphql",
graphqlHTTP({
graphiql: true,
schema,
})
);
mongoose
.connect(
`mongodb+srv://caleb:luna1212@graphqlcluster.ytits2m.mongodb.net/GraphQlCluster?retryWrites=true&w=majority
`,
{ useNewUrlParser: true, useUnifiedTopology: true }
)
.then(() => {
app.listen({ port: port }, () => {
console.log(process.env.mongoUserName);
//localhost:4000
console.log("Listening for requests on my awesome port " + port);
});
})
.catch((e) => {
console.log(process.env.mongoUserName);
return console.log("Error:::" + e);
});