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EAAO,UAAU,IACf,SAAS,EAAS,GAClB,MAAM,IAAI,MAAM,+HAAmI,EAGrJ,EAAO,UAAU,KACf,SAAS,EAAS,GAClB,MAAM,IAAI,MAAM,iIAAqI,EAcvJ,EAAO,UAAU,OAAS,EAAQ,OAElC,EAAO,UAAU,IAAM,SAAS,GAC1B,EAAO,kBACT,EAAO,SAAW,KAAK,UAEzB,KAAK,IAAI,IAAI,MAAM,KAAK,IAAK,UAC/B,EAEA,EAAO,UAAU,SAAW,WAC1B,IAAI,EAAW,EAAK,KAAK,MAAM,KAAM,WAErC,OAAO,EAAS,KAAK,KAAM,EAC7B,EAOO,CACT","file":"/npm/web-site@0.51.0/web-site.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/web-site@0.51.0/web-site.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var library = require(\"module-library\")(require)\n\nmodule.exports = library.export(\n  \"web-site\",\n  [\"with-nearby-modules\", \"http\", \"body-parser\", \"cookie-parser\", \"path\", \"compression\"],\n\n  function(withNearbyModules, http, bodyParser, cookieParser, path, compression) {\n\n    var express = require(\"express\")\n\n    function Server(app) {\n      this.app = app || express()\n      this.app.use(compression({level: 1}))\n      this.app.use(bodyParser.json())\n      this.app.use(bodyParser.urlencoded({ extended: true }))\n      this.app.use(cookieParser())\n      this.stop = stop.bind(this)\n      this.memories = {}\n      this.__isNrtvWebSite = true\n    }\n\n    Server.prototype.remember = function(key) {\n      return this.memories[key]\n    }\n\n    Server.prototype.see = function(key, object) {\n      this.memories[key] = object\n    }\n\n    Server.prototype.express =\n      function() {\n        return this.app\n      }\n\n    Server.prototype.isStarted =\n      function() {\n        return !!this.port\n      }\n\n    Server.prototype.start = function(port) { \n      this.ensureStopped()\n      this.sockets = sockets = []\n      this.port = port || 5678\n\n      if (this.startOverride) {\n        this.server = this.startOverride(port)\n\n        if (!this.server) {\n          throw new Error(\"The start function you gave us needs to return an http server so we can monitor the sockets and stuff! The function you gave us looks like this:\\n\"+this.startOverride.toString()+\"\\n\")\n        }\n\n        console.log(startStatus(this, port))\n\n      } else {\n        this.server = http.createServer(\n          this.app)\n\n        this.server.listen(\n          port)\n        .on(\n          \"error\",\n          errorWithPort.bind(\n            null,\n            port))\n\n        console.log(\n          \"web-site starting on\",\n          port)\n      }\n\n      this.server.on('connection', function(socket) {\n        sockets.push(socket)\n        socket.setTimeout(4000)\n        socket.on('close', function () {\n          sockets.splice(sockets.indexOf(socket), 1)\n        })\n      })\n    }\n\n    function startStatus(site, port) {\n      if (site.startOverride.name) {\n        var overrideName = \"the \"+site.startOverride.name+\" function\"\n      } else {\n        var overrideName = \"an unnamed override function\"\n      } \n\n      if (port) {\n        return \"web-site ostensibly started by \"+overrideName+\" on \"+port\n      } else {\n        return \"web-site ostensibly started by \"+overrideName+\" without a port\"\n      }\n    }\n\n\n    function errorWithPort(port, error) {\n      error.message += \" (port \"+port+\")\"\n      throw error\n    }\n\n    Server.prototype.getPort =\n      function() { return this.port }\n\n    Server.prototype.ensureStopped =\n      function(message)  {\n        if (this.port) {\n          throw new Error(\"You already started this server. \"+(message ? message : \"\"))\n        }\n      }\n\n    Server.prototype.relenquishControl =\n      function(start) {\n        this.ensureStopped(\"You have to override the start function before you start it.\")\n\n        this.startOverride = start\n      }\n\n    function stop(callback) {\n      var port = this.port\n\n      this.server.close(function () {\n        console.log('Server closed!', port, 'should be free.')\n        if (callback) { callback() }\n      })\n\n      this.sockets.forEach(function(socket) {\n        socket.destroy()\n      })\n    }\n\n    var ALLOWED_VERBS = \"get, post, put, head, delete, options, trace, copy, lock, mkcol, move, purge, propfind, proppatch, unlock, report, mkactivity, checkout, merge, m-search, notify, subscribe, unsubscribe, patch, search, connect\".split(\", \")\n\n    function verbOk(verb) {\n      var i = ALLOWED_VERBS.indexOf(verb.toLowerCase())\n      return i >= 0\n    }\n\n    Server.prototype.addRoute =\n      function(verb, pattern, handler) {\n        if (!verbOk(verb)) {\n          throw new Error(\"webSite.addRoute expects an HTTP verb as the first argument. You passed \\\"\"+verb+\"\\\". Valid verbs are \"+ALLOWED_VERBS)\n        }\n\n        this.app[verb](\n          pattern,\n          wrap.bind(null, handler)\n        )\n      }\n\n    function deprecated(verb) {\n\n    }\n\n    Server.prototype.get =\n      function(pattern, handler) {\n      throw new Error(\"site.get is no longer supported. Use site.addRoute(\\\"get\\\", \\\"/route-to\\\", function handler(request, response) { ... }) instead.\")}\n\n\n    Server.prototype.post =\n      function(pattern, handler) {\n      throw new Error(\"site.post is no longer supported. Use site.addRoute(\\\"post\\\", \\\"/resource\\\", function handler(request, response) { ... }) instead.\")}\n\n    function wrap(handler, request, response) {\n      try {\n        handler(request, response)\n      } catch (e) {\n        var lines = e.stack.split(\"\\n\")\n\n        console.log(\"\\n ⚡⚡⚡ REQUEST ERROR ⚡⚡⚡\\n\\n\"+lines[0])\n\n        console.log(lines.slice(1).join(\"\\n\"))\n      }\n    }\n\n    Server.prototype.static = express.static;\n\n    Server.prototype.use = function(server) {\n      if (server.__isNrtvWebSite) {\n        server.memories = this.memories\n      }\n      this.app.use.apply(this.app, arguments)\n    }\n\n    Server.prototype.sendFile = function() {\n      var fullPath = path.join.apply(null, arguments)\n\n      return sendFile.bind(null, fullPath)\n    }\n\n    function sendFile(pathToFile, request, response) {\n\n      response.sendFile(pathToFile)\n    }\n\n    return Server\n  }\n)\n"]}