-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (38 loc) · 1.04 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require("dotenv").config();
const express = require("express");
const graphqlHTTP = require("express-graphql");
const schema = require("./schema/schema");
const mongoose = require("mongoose");
const cors = require("cors");
const PORT = process.env.PORT || 5000;
const app = express();
// allow cross-origin requests
app.use(cors());
// console.log(process.env.CONNECTION_STRING);
// connect to mlab database
// make sure to replace my db string & creds with your own
// mongoose.connect(
// `mongodb://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${
// process.env.DB_HOST
// }`
// );
// mongoose.connection.once("open", () => {
// console.log("conneted to database");
// });
// // bind express with graphql
// app.use(
// "/graphql",
// graphqlHTTP({
// schema,
// graphiql: true
// })
// );
var router = express.Router();
// Home page route.
router.get("/", function(req, res) {
res.send("Wiki home page");
});
app.use("/", router);
app.listen(PORT, () => {
console.log(`now listening for requests on port ${PORT}`);
});