text: const Koa = require("koa");
  const Router = require("koa-router");
  const Logger = require("koa-logger");
  const Cors = require("@koa/cors");
  const BodyParser = require("koa-bodyparser");
  const Helmet = require("koa-helmet");
  const respond = require("koa-respond");
  const compress = require("koa-compress");
  const mongoose = require("mongoose");
  
  // MONGOOSE CONNECT
  // ===========================================================================
  if (process.env.NODE_ENV === "production") {
    mongoose.connect("mongodb://admin:admin@ds141889.mlab.com:41889/url");
  } else {
    mongoose.connect("mongodb://localhost:27017/url");
  }
  
  const app = new Koa();
  const router = new Router();
  
  app.use(Helmet());
  
  if (process.env.NODE_ENV === "development") {
    app.use(Logger());
  }
  
  app.use(Cors());
  app.use(compress());
  app.use(
    BodyParser({
      enableTypes: ["json"],
      jsonLimit: "5mb",
      strict: true,
      onerror: function(err, ctx) {
        ctx.throw("body parse error", 422);
      }
    })
  );
  
  app.use(respond());
  
  // API routes
  require("./routes")(router);
  app.use(router.routes());
  app.use(router.allowedMethods());
  
  module.exports = app;
  