-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (26 loc) · 738 Bytes
/
app.js
File metadata and controls
28 lines (26 loc) · 738 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
import express from 'express';
import graphQLHTTP from 'express-graphql';
import Schema from './schema';
import expressLogging from 'express-logging';
import logger from 'logops';
var app = express()
app.use(expressLogging(logger));
app.set('views', __dirname);
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'ejs');
app.use(express.static(__dirname));
app.listen((process.env.PORT || 4000), (err) => {
if (err) {
console.error(err)
return
}
console.log(`Server is now running on localhost: ${process.env.PORT || 4000}`)
})
app.get('/', function (req, res) {
res.render('index.html');
});
app.use('/api', graphQLHTTP({
schema: Schema,
pretty: true,
graphiql: true
}));