fix(portal-api): better handle dev enviroments

This commit is contained in:
Sérgio Ramos 2017-07-20 14:44:55 +01:00 committed by Judit Greskovits
parent 2f4e9d4a57
commit 4df7549799
3 changed files with 18 additions and 2 deletions

View File

@ -9,6 +9,13 @@ const Resolvers = require('./resolvers');
const ContainerPilotWatcher = require('./watch/container-pilot'); const ContainerPilotWatcher = require('./watch/container-pilot');
const MachinesWatcher = require('./watch/machines'); const MachinesWatcher = require('./watch/machines');
const {
NAMESPACE
} = process.env;
const namespace = NAMESPACE
? `/${NAMESPACE}`
: '';
const internals = {}; const internals = {};
@ -59,6 +66,8 @@ module.exports = function (server, options, next) {
{ {
register: Graphi, register: Graphi,
options: { options: {
graphqlPath: `${namespace}/graphql`,
graphiqlPath: `${namespace}/graphiql`,
schema: Schema, schema: Schema,
resolvers: Resolvers(data) resolvers: Resolvers(data)
} }

View File

@ -11,7 +11,8 @@
"lint-ci": "belly-button", "lint-ci": "belly-button",
"test": "lab -c", "test": "lab -c",
"test-ci": "echo 0", "test-ci": "echo 0",
"start": "node server.js" "start": "node server.js",
"dev": "CORS=1 NAMESPACE=api node server.js"
}, },
"keywords": [], "keywords": [],
"author": "wyatt", "author": "wyatt",

View File

@ -14,7 +14,13 @@ const Fs = require('fs');
const Url = require('url'); const Url = require('url');
const server = new Hapi.Server(); const server = new Hapi.Server();
server.connection({ port: 3000 });
server.connection({
port: 3000,
routes: {
cors: Boolean(process.env.CORS)
}
});
const swaggerOptions = { const swaggerOptions = {
info: { info: {