-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (27 loc) · 831 Bytes
/
index.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
//IMPORTS
const express = require('express');
const cookieSession = require('cookie-session');
const { GraphQLServer, PubSub } = require('graphql-yoga');
const typeDefs = require('./graphql/typeDefs');
const resolvers = require('./graphql/resolvers');
const room = require('./db/db');
//SERVER
const pubsub = new PubSub();
const options = {
port: process.env.PORT || 1337,
endpoint: '/api',
subscriptions: '/api',
playground: '/playground'
};
const server = new GraphQLServer({
typeDefs,
resolvers,
context: (req) => ({ pubsub, room})
});
server.express.use(cookieSession({
name: 'session',
maxAge: 24 * 60 * 60 * 1000,
keys: ['assignment3']
}));
server.express.use('/', express.static('site'));
server.start(options, ({port}) => console.log(`Server is running on localhost:${port}`));