forked from SchoolofComputerScience/scs-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (29 loc) · 873 Bytes
/
server.js
File metadata and controls
36 lines (29 loc) · 873 Bytes
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
const app = require('express')()
const graph = require('express-graphql')
const compression = require('compression')
const cors = require('cors')
const schema = require('./scheme.js')
const helmet = require('helmet')
app.use(helmet.xssFilter());
app.use(helmet.frameguard({action: 'deny'}));
app.use(helmet.ieNoOpen());
app.use(compression({threshold: 0}))
app.use(cors());
app.set('trust proxy', true);
app.use(function (req, res, next) {
if (req.get('x-appengine-https') === 'on' && !req.get('x-forwarded-proto')){
req.headers['x-forwarded-proto'] = 'https';
}
next();
});
app.use('/graph', graph({
schema: schema,
allowUndefinedInResolve: false,
pretty: true,
graphiql: true,
shouldBatch: true
}))
app.use('*', (req, res) => res.send('scs:cmu / api'))
app.listen(process.env.PORT || 5000, () => {
console.log(`> scs:cmu / api / :5000\n`)
})