All files / server server.ts

0% Statements 0/21
0% Branches 0/4
0% Functions 0/2
0% Lines 0/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                       
import { APP_DEFAULT_PORT } from '../shared/config';
const express = require('express');
const mongoose = require('mongoose');
const enforce = require('express-sslify');
const frameguard = require('frameguard');
import * as graphqlHTTP from 'express-graphql';
import expressPlayground from 'graphql-playground-middleware-express';
import { graphqlUploadExpress } from 'graphql-upload';
import Schema from './gql/Schema';
import Router from './router';
 
const app = express();
 
if (app.get('env') === 'production') {
  app.use(enforce.HTTPS({ trustProtoHeader: true }));
}
app.use(frameguard({ action: 'deny' }));
 
app.use(express.static('dist'));
 
app.use(
  '/graphql',
  graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
  graphqlHTTP({ schema: Schema }),
);
app.get('/playground', expressPlayground({ endpoint: '/graphql' }), () => {}); // tslint:disable-line
 
app.use('/', Router);
 
const port = Number(process.env.PORT || APP_DEFAULT_PORT);
 
app.listen(port, () => {
  console.log(`Express server listening on port ${port}`);
  mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/kukr');
});