openBackhaul / RequestSequenceRepresentation

Graphical representation of Request Flows
Apache License 2.0
0 stars 3 forks source link

To integrate both server and client #25

Closed PrathibaJee closed 1 year ago

PrathibaJee commented 1 year ago

To make both the server and the client run in the same port following procedure needs to be followed, create a folder "build" in the client folder run the command npm run build in the /client folder and direct the executables into the /client/build directory This executables in the /client/build shall be injected as a middleware to the express framework router stack.

app.use(express.static(path.join(__dirname, '../client/build')));
app.get('/v1/represent-flow-visualization-page', (req, res) => {
    res.sendFile(path.resolve(__dirname, '../client/build', 'index.html'));
  });

We are using OAS3tools for the express framework. The custom routes shall be included at any position before router and after express json middlewares.

const stack = app._router.stack;
const lastEntries = stack.splice(app._router.stack.length - 2);  // The number of middleware we added is 2 in this case. 
const firstEntries = stack.splice(0, 9); // Adding the middleware after the cookieParser
app._router.stack = [...firstEntries, ...lastEntries, ...stack];
console.log(app._router.stack);
PrathibaJee commented 1 year ago

Fixed in the PR https://github.com/openBackhaul/RequestSequenceRepresentation/pull/38 , hence closing this issue.