text: require("dotenv").config({ path: ".env_" + process.env.ENVIRONMENT.toLowerCase() })
  require("dotenv").config({ path: ".env" })
  
  const routes = require("./routes")
  const express = require("express")
  const cors = require("cors")
  
  class App {
      constructor() {
          this.app = express()
          this.middlewares()
          this.routes()
      }
  
      middlewares() {
          this.app.use(express.json())
          this.app.use((req, res, next) => {
              res.header("Access-Control-Allow-Origin", "*")
              res.header("Access-Control-Allow-Methods", "GET, POST, PUT")
              res.header(
                  "Access-Control-Allow-Headers",
                  "Access, Content-type, Authorization, Accept, Origin, X-Requested-With"
              )
  
              this.app.use(cors())
              process.env.IP = (req.headers['x-forwarded-for'] || req.socket.remoteAddress).replace('::ffff:', '')
              process.env.ROTA = req.path
              next()
          })
      }
  
      routes() {
          this.app.use(routes)
      }
  }
  
  module.exports = new App().app