src/server.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 33
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 24
mnd 0
bc 0
fnc 1
dl 0
loc 33
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
/* eslint-disable-next-line */
2
import 'babel-polyfill';
3
import express from 'express';
4
import { ApolloServer } from 'apollo-server-express';
5
import expressPlayground from 'graphql-playground-middleware-express';
6
import bodyParser from 'body-parser';
7
import typeDefs from './graphql/schema';
8
import resolvers from './graphql/resolvers';
9
import { GITHUB_TOKEN } from './constants';
10
11
const graphQLServer = express();
12
13
const apolloServer = new ApolloServer({
14
  typeDefs,
15
  resolvers,
16
  context: {},
17
  tracing: true,
18
  playground: true,
19
  introspection: true,
20
});
21
22
process.env.NODE_TLS_REJECT_UNAUTHORIZED = `0`;
23
24
graphQLServer.use(bodyParser.json());
25
apolloServer.applyMiddleware({ app: graphQLServer });
26
27
graphQLServer.get(`/`, (_, res) => {
28
  res.setHeader(`Access-Control-Allow-Origin`, `*`);
29
  res.send({ token: GITHUB_TOKEN });
30
});
31
32
graphQLServer.get(`/playground`, expressPlayground({ endpoint: `/graphql` }));
33
34
export default graphQLServer;
35