Q:

How do I store user action data? i.e userID date/time and action code

The action code being whichever page the user interacts with
please refer to javascript/nodejs code below.
for example at each router.get() if a user is accesing this i need to store his/her userID the dateTime and an action code matching to each router.

router.get('/', function(request, response) {
 response.sendFile(path.join(__dirname + '/eventlist.html'));
});
router.get('/watchlist', function(request, response) {
 response.sendFile(path.join(__dirname + '/watchlist.html'));
 
});
router.get('/search', function(request, response) {
 response.sendFile(path.join(__dirname + '/search.html'));
});

app.post('/search', function(req,res){
 let inputContent = req.body.srchterm;
 var sequelize = require('./db');
 sequelize.query('SELECT * FROM main_table WHERE jobname = :jobname OR jobstream = :jobstream OR workstation = :workstation ',
 { replacements: { jobname: inputContent, jobstream: inputContent, workstation: inputContent }, type: sequelize.QueryTypes.SELECT }
                           )
                             .then(function(searchib) {
                                console.log(searchib);
                                if (searchib == "") {
                 res.send(srcharray);
                                } else {
                                var srcharray = [];
    searchib.forEach(function(items){
                                console.log('displaying srchadata');
    srcharray.push ({workstation: items.workstation,
      jobstream: items.jobstream,
      jobdate: (items.jobdate.toLocaleString('en-GB', { timeZone: 'GMT'})),
      jobname: items.jobname
            });
                                console.log(srcharray);
    });
    // return response.json(srcharray);
    res.send(srcharray);
    }
    });
});

app.use('/', router);

A:

Create your own middleware (storeUserActionDataMiddleware) to store the data like below:
function storeUserActionDataMiddleware(req, res, next) {
    let data = {
        userId: 42 /* get userId somehow */,
        dateTime: new Date(),
        actionCode: `${req.method} ${req.originalUrl}`,
    };

    console.log({ data });

    // Store user action data here
    // store(data);

    // then execute routes
    next();
}

If you want to store the data only for specific router, then use the middleware at the top of the router like:
// only specific router will store user action data
router.use(storeUserActionDataMiddleware);

router.get(/* ... */)
router.post(/* ... */)

Or, if you want to store the data application wide, then use the middleware at the top of the app like:
// all routes will store user action data
app.use(storeUserActionDataMiddleware);

app.use(/* ... */)
app.get(/* ... */)
app.post(/* ... */)

