-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (32 loc) · 946 Bytes
/
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
import express from 'express';
import bodyParser from 'body-parser';
import models from './models/index.js';
import GraphHTTP from 'express-graphql';
import Schema from './graphql';
var app = express();
var router = express.Router();
function startApp(port) {
app.listen(port, function() {
console.log('Server is listening on port ' + port);
});
}
/*models.sequelize.sync()
.then(function() {
startApp(8088);
})
.catch(function (e) {
throw new Error(e);
});*/
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
/*
* This is here because of authentication. Auth middleware decodes the JWT token
* and saves its content to request.user object.
*/
app.use('/graphql', GraphHTTP((request) => ({
schema: Schema,
context: { user: request.user },
pretty: true,
graphiql: true
})));
startApp(8088);