const actionGraphiQL = async function(ctx, next) { const {dev, debug, test} = ctx.app.config.env // Dirty hack -_- // Need to be improved const subscriptionsEndpoint = ( `ws://${ctx.app.addr.replace(/^.*:\/\//, "")}${endpointURL}` ) const middleware = (dev || debug || test) ? graphiqlKoa({endpointURL, subscriptionsEndpoint}) : noop() await middleware(ctx, next) }
router.post('/auth/refresh', tokenRefresh) router.post('/auth/github', githubAuthRedirect) router.post('/auth/github/:redirect', githubAuthRedirect) router.post('/auth/cb/github', githubAuthCB) router.post( '/graphql', graphqlKoa(ctx => ({ schema: executableSchema, context: { ctx } })) ) if (process.env !== 'production') { router.get('/graphiql', graphiqlKoa({ endpointURL: '/graphql' })) } app.use(router.routes()) app.use(router.allowedMethods()) // Launching the server const server = app.listen(parseInt(env('SERVER_PORT'), 10), env('SERVER_HOST')) // Setup the subscription server SubscriptionServer.create( { schema: executableSchema, execute,