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

View File

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

View File

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