forked from ramsaylanier/WordExpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (33 loc) · 1.05 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
/* eslint no-console: 0 */
import path from 'path';
import express from 'express';
import { apolloServer } from 'apollo-server';
import { Definitions, Resolvers } from './schema/schema';
import { privateSettings } from './settings/settings';
const APP_PORT = process.env.PORT || 3000;
const GRAPHQL_PORT = 8080;
const graphQLServer = express();
let app = express();
graphQLServer.use('/', apolloServer({
graphiql: true,
pretty: true,
schema: Definitions,
resolvers: Resolvers
}));
graphQLServer.listen(GRAPHQL_PORT, () => console.log(
`GraphQL Server is now running on http://localhost:${GRAPHQL_PORT}`
));
app.use(require('prerender-node').set('prerenderToken', privateSettings.prerenderToken ));
app.use(express.static('./dist'));
app.use('/graphql', apolloServer({
graphiql: true,
pretty: true,
schema: Schema,
resolvers: Resolvers
}));
app.get('*', function response(req, res, next) {
res.sendFile(path.join(__dirname, '/index.html'));
});
app.listen(APP_PORT, () => {
console.log(`App is now running on http://localhost:${APP_PORT}`);
});