-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (27 loc) · 1.06 KB
/
server.js
File metadata and controls
36 lines (27 loc) · 1.06 KB
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
/* eslint-env node */
//------------------------------------------------------------------------------
// node.js starter application for Bluemix
//------------------------------------------------------------------------------
// This application uses express as its web server
// for more info, see: http://expressjs.com
// var express = require('express');
import express from 'express';
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
import cfenv from 'cfenv';
// configuration of graphql endpoint
import ncSchema from './data/schema';
import graphqlHTTP from 'express-graphql';
// create a new express server
const app = express();
app.use('/graphql', graphqlHTTP({
schema: ncSchema,
graphiql: true,
}));
// get the app environment from Cloud Foundry
const appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function () {
// print a message when the server starts listening
console.log('server starting on ' + appEnv.url);
});