const cors = require('cors')

const init = app => {
  // Custom config
  const graphiql = process.env.GRAPHIQL_ENABLED === '1' || process.env.NODE_ENV !== 'production'

  // Cross Origin
  app.use(cors())

  // Mongoose
  const mongo_uri = process.env.MONGODB_URI
  require('./mongoose')(mongo_uri)

  // GraphQL
  const graphqlHTTP = require('express-graphql')

  const fs = require('fs')
  const path = require('path')

  const graphql_uri = `./graphql`
  const abs_graphql_uri = path.resolve('../', graphql_uri)
  const graphql_paths = (() => {
    try { 
      return fs.readdirSync(abs_graphql_uri).filter(file => fs.statSync(path.join(abs_graphql_uri, file)).isDirectory())
    } catch(err) {
      return []
    }
  })()

  graphql_paths.forEach(tc => {
    const graphql_path = path.resolve('/', graphql_uri, tc)
    const abs_graphql_path = `${abs_graphql_uri}/${tc}`
    const schema = require(abs_graphql_path)

    app.use(graphql_path, graphqlHTTP(() => ({
      schema,
      graphiql,
      formatError: (error) => ({
        message: error.message,
        stack: !error.message.match(/for security reason/i) ? error.stack.split('\n') : null,
      })
    })))

    debug.log(`GraphQL : http://localhost:${process.env.HTTP_PORT}${graphql_path} -> ${abs_graphql_path}`)
  })
}

module.exports = init

@@ -453,67 +453,8 @@
 ql%60%0A
-  const abs_graphql_uri = path.resolve('../', graphql_uri)%0A
   co
@@ -491,17 +491,16 @@
    try %7B
- 
 %0A      r
@@ -520,20 +520,16 @@
 dirSync(
-abs_
 graphql_
@@ -570,20 +570,16 @@
 th.join(
-abs_
 graphql_
@@ -616,16 +616,17 @@
  %7D catch
+ 
 (err) %7B%0A
@@ -693,31 +693,29 @@
 %7B%0A    const 
-graphql
+route
 _path = path
@@ -759,34 +759,42 @@
 nst 
-abs_graphql_path = %60$%7Babs_
+require_path = path.resolve('./', 
 grap
@@ -804,16 +804,13 @@
 _uri
-%7D/$%7Btc%7D%60
+, tc)
 %0A   
@@ -833,27 +833,23 @@
 require(
-abs_graphql
+require
 _path)%0A%0A
@@ -860,23 +860,21 @@
 app.use(
-graphql
+route
 _path, g
@@ -1169,23 +1169,21 @@
 _PORT%7D$%7B
-graphql
+route
 _path%7D -
@@ -1190,19 +1190,13 @@
 %3E $%7B
-abs_graphql
+route
 _pat

Correct route_path