Module export for ACE 'addon' in app.js won't work

Hi all,

I am playing around with the atlassian-connect-express framework and successfully created a Jira plugin with the starter code.

Right now, I am refactoring the code in order to implement a route handling I am used to from other projects. In general, I want to change the way how the Express ‘app’ and the ACE ‘addon’ are forwarded to the route handler in index.js. Instead of calling routes(app, addon) I want to use the JS ‘export and require’ syntax.

Here is a code snippet from what I did:

# app.js

const express = require('express');
const ace = require('atlassian-connect-express');
const router = require('./routes/index'); //import routes from '.routes';
...

# Instantiate the express app
const app = express();
const addon = ace(app);
...

# Wire up routes
app.use("/", router); //routes(app, addon);
...

module.exports={ app, addon }
# routes/index.js

const router = require('express').Router();
const { app , addon } = require("../app");

# export default function routes(app, addon)
app.get("/helloWorld", addon.authenticate(), (req, res) => {
  ...
});

module.exports = router;

When running npm start, Node cannot resolve ‘addon’ in index.js and, thus, displays following error message:

TypeError: Cannot read property 'authenticate' of undefined

Can someone tell me what I am doing wrong or provide a workaround which will solve my problem?

Best,
Valentin