text: // Generated by BUCKLESCRIPT VERSION 1.9.1, PLEASE EDIT WITH CARE
  'use strict';
  
  var Curry      = require("bs-platform/lib/js/curry.js");
  var Js_exn     = require("bs-platform/lib/js/js_exn.js");
  var Express    = require("../src/express.js");
  var Js_json    = require("bs-platform/lib/js/js_json.js");
  var Express$1  = require("express");
  var Process    = require("process");
  var Caml_obj   = require("bs-platform/lib/js/caml_obj.js");
  var Pervasives = require("bs-platform/lib/js/pervasives.js");
  
  function checkProperty(req, next, property, k) {
    var match = req[property];
    if (match !== undefined) {
      var match$1 = Js_json.decodeBoolean(match);
      if (match$1 && Caml_obj.caml_equal(match$1[0], true)) {
        return Curry._1(k, /* () */0);
      } else {
        return Curry._1(next, Express.Next[/* route */1]);
      }
    } else {
      return Curry._1(next, Express.Next[/* route */1]);
    }
  }
  
  function checkProperties(req, next, properties, k) {
    var aux = function (properties) {
      if (properties) {
        var tl = properties[1];
        return checkProperty(req, next, properties[0], (function () {
                      return aux(tl);
                    }));
      } else {
        return Curry._1(k, /* () */0);
      }
    };
    return aux(properties);
  }
  
  function setProperty(req, property) {
    req[property] = true;
    return /* () */0;
  }
  
  function getDictString(dict, key) {
    var match = dict[key];
    if (match !== undefined) {
      return Js_json.decodeString(match);
    } else {
      return /* None */0;
    }
  }
  
  function makeSuccessJson() {
    var json = { };
    json["success"] = true;
    return json;
  }
  
  var app = Express.express(/* () */0);
  
  app.use("/", (function (req, _, next) {
          setProperty(req, "middleware0");
          return Curry._1(next, Express.Next[/* middleware */0]);
        }));
  
  app.use(/* array */[
        (function (req, _, next) {
            return checkProperty(req, next, "middleware0", (function () {
                          setProperty(req, "middleware1");
                          return Curry._1(next, Express.Next[/* middleware */0]);
                        }));
          }),
        (function (req, _, next) {
            return checkProperties(req, next, /* :: */[
                        "middleware0",
                        /* :: */[
                          "middleware1",
                          /* [] */0
                        ]
                      ], (function () {
                          setProperty(req, "middleware2");
                          return Curry._1(next, Express.Next[/* middleware */0]);
                        }));
          })
      ]);
  
  app.get("/", (function (req, res, next) {
          return checkProperties(req, next, /* :: */[
                      "middleware0",
                      /* :: */[
                        "middleware1",
                        /* :: */[
                          "middleware2",
                          /* [] */0
                        ]
                      ]
                    ], (function () {
                        return res.send(makeSuccessJson(/* () */0));
                      }));
        }));
  
  var options = Express.Static[/* defaultOptions */0](/* () */0);
  
  app.use("/static", Express$1.static("static", options));
  
  app.post("/:id/id", /* array */[(function (req, res, next) {
            return checkProperties(req, next, /* :: */[
                        "middleware0",
                        /* :: */[
                          "middleware1",
                          /* :: */[
                            "middleware2",
                            /* [] */0
                          ]
                        ]
                      ], (function () {
                          var match = getDictString(req.params, "id");
                          if (match && match[0] === "123") {
                            return res.send(makeSuccessJson(/* () */0));
                          } else {
                            return Curry._1(next, Express.Next[/* route */1]);
                          }
                        }));
          })]);
  
  app.get("/baseUrl", (function (req, res, next) {
          var match = req.baseUrl;
          if (match === "") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/hostname", (function (req, res, next) {
          var match = req.hostname;
          if (match === "localhost") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/ip", (function (req, res, next) {
          var s = req.ip;
          if (s === "127.0.0.1") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            console.log(s);
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/method", (function (req, res, next) {
          var s = Express.Request[/* method_ */0](req);
          if (s !== 0) {
            console.log(s);
            return Curry._1(next, Express.Next[/* route */1]);
          } else {
            return res.send(makeSuccessJson(/* () */0));
          }
        }));
  
  app.get("/originalUrl", (function (req, res, next) {
          var s = req.originalUrl;
          if (s === "/originalUrl") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            console.log(s);
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/path", (function (req, res, next) {
          var s = req.path;
          if (s === "/path") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            console.log(s);
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/protocol", (function (req, res, next) {
          var s = Express.Request[/* protocol */1](req);
          if (s !== 0) {
            console.log(s);
            return Curry._1(next, Express.Next[/* route */1]);
          } else {
            return res.send(makeSuccessJson(/* () */0));
          }
        }));
  
  app.get("/query", (function (req, res, next) {
          var match = getDictString(req.query, "key");
          if (match && match[0] === "value") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/accepts", /* array */[
        (function (req, _, next) {
            var match = Express.Request[/* accepts */2](req, /* array */[
                  "audio/whatever",
                  "audio/basic"
                ]);
            if (match && match[0] === "audio/basic") {
              return Curry._1(next, Express.Next[/* middleware */0]);
            } else {
              return Curry._1(next, Express.Next[/* route */1]);
            }
          }),
        (function (req, res, next) {
            var match = Express.Request[/* accepts */2](req, /* array */["text/css"]);
            if (match) {
              return Curry._1(next, Express.Next[/* route */1]);
            } else {
              return res.send(makeSuccessJson(/* () */0));
            }
          })
      ]);
  
  app.get("/accepts-charsets", /* array */[
        (function (req, _, next) {
            var match = Express.Request[/* acceptsCharsets */3](req, /* array */[
                  "UTF-8",
                  "UTF-16"
                ]);
            if (match && match[0] === "UTF-8") {
              return Curry._1(next, Express.Next[/* middleware */0]);
            } else {
              return Curry._1(next, Express.Next[/* route */1]);
            }
          }),
        (function (req, res, next) {
            var match = Express.Request[/* acceptsCharsets */3](req, /* array */["UTF-16"]);
            if (match) {
              return Curry._1(next, Express.Next[/* route */1]);
            } else {
              return res.send(makeSuccessJson(/* () */0));
            }
          })
      ]);
  
  app.get("/get", (function (req, res, next) {
          var match = req.get("key");
          if (!(match == null) && match === "value") {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/fresh", (function (req, res, next) {
          if (req.fresh) {
            return Curry._1(next, Express.Next[/* route */1]);
          } else {
            return res.send(makeSuccessJson(/* () */0));
          }
        }));
  
  app.get("/stale", (function (req, res, next) {
          if (req.stale) {
            return res.send(makeSuccessJson(/* () */0));
          } else {
            return Curry._1(next, Express.Next[/* route */1]);
          }
        }));
  
  app.get("/secure", (function (req, res, next) {
          if (req.secure) {
            return Curry._1(next, Express.Next[/* route */1]);
          } else {
            return res.send(makeSuccessJson(/* () */0));
          }
        }));
  
  app.get("/xhr", (function (req, res, next) {
          if (req.xhr) {
            return Curry._1(next, Express.Next[/* route */1]);
          } else {
            return res.send(makeSuccessJson(/* () */0));
          }
        }));
  
  app.get("/redir", (function (_, res, _$1) {
          return res.redirect("/redir/target");
        }));
  
  app.get("/redircode", (function (_, res, _$1) {
          return res.redirect(301, "/redir/target");
        }));
  
  function onListen(port, e) {
    var exit = 0;
    var val;
    try {
      val = e;
      exit = 1;
    }
    catch (raw_exn){
      var exn = Js_exn.internalToOCamlException(raw_exn);
      if (exn[0] === Js_exn.$$Error) {
        console.log(exn[1]);
        Process.exit(1);
        return /* () */0;
      } else {
        throw exn;
      }
    }
    if (exit === 1) {
      console.log("Listening at http://127.0.0.1:" + Pervasives.string_of_int(port));
      return /* () */0;
    }
    
  }
  
  Express.App[/* listen */0](app, /* None */0, /* Some */[(function (param) {
            return onListen(3000, param);
          })], /* () */0);
  
  exports.checkProperty   = checkProperty;
  exports.checkProperties = checkProperties;
  exports.setProperty     = setProperty;
  exports.getDictString   = getDictString;
  exports.makeSuccessJson = makeSuccessJson;
  exports.app             = app;
  exports.onListen        = onListen;
  /* app Not a pure module */
  