listener(func) {
    if (!express) {
      console.log(
        "loreListener runs in Node, not the browser. Use this in an Adobe extension to listen for messages."
      );
    }

    // This should never happen since we have fallbacks:
    if (!this.port) {
      console.log("Define a port number to listen on");
      return;
    }

    var jsonParser = bodyParser.json();
    var textParser = bodyParser.text();
    this.app.post("/", [jsonParser, textParser], (req, res) => {
      res.write(JSON.stringify(req.headers, null, 2));
      res.write("\n\n");

      var contentType = req.get("content-type");

      if (contentType.includes("application/json")) {
        if (!func) {
          console.log("Lore: Define a func to do something with this data ↓");
          console.log(req.body);
        } else {
          func(req.body);
        }
        res.write(JSON.stringify(req.body, null, 2));
      }
      res.end();
    });

    var server = this.app.listen(this.port, () => {
      var port = server.address().port;
      // Changing all strings to a template literal for ease of use:
      // https://css-tricks.com/template-literals/
      console.log(`Lore listening at http://${this.address}:${this.port}`);
      //   console.log("Lore listening at http://127.0.0.1:", port);
    });

    return server;
  }
// function that does something with received data
function that does something with received data
function that does something with received data
listener(func) {
    if (!express) {
      console.log(
        "loreListener runs in Node, not the browser. Use this in an Adobe extension to listen for messages."
      );
    }
    if (!this.port) {
      console.log("Define a port number to listen on");
      return;
    }
    var jsonParser = bodyParser.json();
    var textParser = bodyParser.text();
    this.app.post("/", [jsonParser, textParser], (req, res) => {
      res.write(JSON.stringify(req.headers, null, 2));
      res.write("\n\n");
      var contentType = req.get("content-type");
      if (contentType.includes("application/json")) {
        if (!func) {
          console.log("Lore: Define a func to do something with this data ↓");
          console.log(req.body);
        } else {
          func(req.body);
        }
        res.write(JSON.stringify(req.body, null, 2));
      }
      res.end();
    });
    var server = this.app.listen(this.port, () => {
      var port = server.address().port;
      console.log(`Lore listening at http://${this.address}:${this.port}`);
    });
    return server;
  }
listener ( func ) { if ( ! express ) { console . log ( "loreListener runs in Node, not the browser. Use this in an Adobe extension to listen for messages." ) ; } if ( ! this . port ) { console . log ( "Define a port number to listen on" ) ; return ; } var jsonParser = bodyParser . json ( ) ; var textParser = bodyParser . text ( ) ; this . app . post ( "/" , [ jsonParser , textParser ] , ( req , res ) => { res . write ( JSON . stringify ( req . headers , null , 2 ) ) ; res . write ( "\n\n" ) ; var contentType = req . get ( "content-type" ) ; if ( contentType . includes ( "application/json" ) ) { if ( ! func ) { console . log ( "Lore: Define a func to do something with this data ↓"); console . log ( req . body ) ; } else { func ( req . body ) ; } res . write ( JSON . stringify ( req . body , null , 2 ) ) ; } res . end ( ) ; } ) ; var server = this . app . listen ( this . port , ( ) => { var port = server . address ( ) . port ; console . log ( ` ${ this . address } ${ this . port } ` ) ; } ) ; return server ; }
function that does something with received data
function that does something with received data
// This should never happen since we have fallbacks: // Changing all strings to a template literal for ease of use: // https://css-tricks.com/template-literals/ //   console.log("Lore listening at http://127.0.0.1:", port);