-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (26 loc) · 768 Bytes
/
app.js
File metadata and controls
35 lines (26 loc) · 768 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
import express from 'express';
import graphqlHTTP from 'express-graphql';
import mongoose from 'mongoose';
import path from 'path';
import Schema from './graphql';
var app = express();
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(express.static(__dirname + '/public'));
app.post('/graphql', graphqlHTTP({
schema: Schema.schema(),
graphiql: false
}));
app.get('/graphql', graphqlHTTP({
schema: Schema.schema(),
graphiql: true
}));
app.use('/', (req, res) => {
return res.render('index');
});
// Connect mongo database
mongoose.connect('mongodb://root:root@ds017165.mlab.com:17165/bornevia');
// start server
var server = app.listen(3000, () => {
console.log('Listening at port', server.address().port);
});