0

I have my node application architecture like this-

app.js

import express from 'express';
var app = express();
app.use('/route', Router);

Router.js

import express from 'express';
var router = express.Router();
router.get('/route', Router.routerController);

controller.js

exports.routerController = async function (req, res) {
  const { id } = req.params;
  try {
    // Actual API call
  } catch (error) {

  }
};

What will be the best way to integrate Winston for logging into such architecture. Is there a way in which I can integrate Winston in the entire application without placing log calls in every controller?

Frosted Cupcake
  • 1,909
  • 2
  • 20
  • 42

1 Answers1

1

You can use middleware for that. see sth like this https://www.npmjs.com/package/express-winston

Tuan Anh Tran
  • 6,807
  • 6
  • 37
  • 54