-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphql_start.js
49 lines (36 loc) · 1.15 KB
/
graphql_start.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
39
40
41
42
43
44
45
46
47
48
49
// server.js
import express from 'express';
import path from 'path';
import http from 'http';
import vehicleData from './graphqlserver/vehicles/vehicles';
let app = express();
//let PORT = 3g000;
let PORT = process.env.PORT
app.use(express.static(path.resolve(__dirname, 'client')));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS");
next();
});
app.post('/vehicleGraphql', vehicleData);
app.get('/vehicleGraphql', vehicleData);
/*app.post('/graphql', (req, res) => {
console.log('Hello');
res.send('Hello!');
});*/
app.use('/vehicleGraphql',(req, res) => {
console.log('Helg');
res.send('pong');
});
app.get('/hej', (req, res) => {
console.log('Helg');
res.send('Helg!');
});
let server = app.listen(PORT, function () {
//let host = server.address().address;
//let port = server.address().port;
let host = process.env.IP;
let port = process.env.PORT;
console.log('GraphQL listening at http://%s:%s', host, port);
});