-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserver.js
66 lines (54 loc) · 1.54 KB
/
server.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const { ApolloServer } = require("apollo-server-express");
const express = require("express");
const compression = require("compression");
const cors = require("cors");
const LogRocket = require("logrocket");
const AuthService = require("./services/auth.service");
const PORT = process.env.PORT || 4000;
const server = new ApolloServer({
modules: [
require("./graphql-modules/user"),
require("./graphql-modules/token"),
require("./graphql-modules/places_visited"),
require("./graphql-modules/place_living"),
require("./graphql-modules/interests"),
require("./graphql-modules/social"),
require("./graphql-modules/place_visiting"),
require("./graphql-modules/friend_requests"),
require("./graphql-modules/city_reviews"),
require("./graphql-modules/blog_posts"),
],
context: ({ req }) => {
let token = req.headers.authorization;
if (token) {
return AuthService.verifyToken(token);
}
},
introspection: true,
playground: true,
});
const app = express();
app.use(cors());
app.use(compression());
server.applyMiddleware({
app,
path: "/graphql",
bodyParserConfig: {
limit: "100mb",
},
});
async function start() {
// Initialize LogRocket
LogRocket.init('81ftil/travelmaps');
// Start express
app.start()
}
start();
app.listen(PORT, () => {
var env = process.env.NODE_ENV || "dev";
if (env == "dev") {
console.log("Running development environment!");
// opn(`http://localhost:${PORT}/graphql`);
console.log(`Playground is up at localhost:${PORT}/graphql`);
}
});