How to use the express-winston.responseWhitelist function in express-winston

To help you get started, we’ve selected a few express-winston examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github garage-it / SmartHouse-backend / src / config / express.js View on Github external
app.use(compress());
app.use(methodOverride());

app.use(passport.initialize());
app.use(passport.session());

// disable 'X-Powered-By' header in response
app.disable('x-powered-by');

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// enable detailed API logging in dev env
if (config.env === 'development') {
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    app.use(expressWinston.logger({
        winstonInstance,
        meta: true,     // optional: log meta data about request (defaults to true)
        msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
        colorStatus: true     // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
    }));
}


if (config.staticPath) {
    /* eslint-disable no-console */
    console.log('Serve static files from: \x1b[36m' + config.staticPath + '\x1b[0m');
    /* eslint-enable no-console */
    app.use(express.static(config.staticPath));
}
github linnovate / mean / server / config / express.js View on Github external
app.use(bodyParser.urlencoded({ extended: true }));

app.use(cookieParser());
app.use(compress());
app.use(methodOverride());

// secure apps by setting various HTTP headers
app.use(helmet());

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// enable detailed API logging in dev env
if (config.env === 'development') {
  expressWinston.requestWhitelist.push('body');
  expressWinston.responseWhitelist.push('body');
  // app.use(expressWinston.logger({
  //   winstonInstance,
  //   meta: true, // optional: log meta data about request (defaults to true)
  //   msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
  //   colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
  // }));
}
app.use(express.static(path.join(appRoot.path, 'dist')));

app.use('/api', routes);

innograph.init('/api/graphql', app, {post: postCtrl});

app.get('*', (req, res) => {
  res.sendFile(path.join(appRoot.path, 'dist/index.html'));
});
github skarif2 / node-rest-starter / src / config / server.old.js View on Github external
app.use(morgan('dev'))
}

app.use(bodyParser.urlencoded({ extended: true, }))
app.use(bodyParser.json())

app.use(compression())
app.use(cookieParser())
app.use(cors())
app.use(helmet())
app.use(methodOverride())

// enable detailed API logging in all env except test
if (env.NODE_ENV !== 'test') {
  expressWinston.requestWhitelist.push('body')
  expressWinston.responseWhitelist.push('body')
  app.use(expressWinston.logger({
    winstonInstance,
    meta: true, // optional: log meta data about request (defaults to true)
    msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
    colorStatus: true, // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
  }))
}

/**
 * @apiDescription Mounts api routes at /api
 * @apiGroup API
 */
app.use('/api', routes)

// catch 404 and forward to error handler
app.use((req, res, next) => {
github amida-tech / api-boilerplate / config / express.js View on Github external
app.use(compress());
app.use(methodOverride());

// secure apps by setting various HTTP headers
app.use(helmet());

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// This is really just a test output and should be the first thing you see
winstonInstance.info('The application is starting...');

// enable detailed API logging in dev env
if (config.env === 'development') {
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    app.use(expressWinston.logger({
        winstonInstance,
        meta: true, // optional: log meta data about request (defaults to true)
        msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
        colorStatus: true, // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
    }));
}

// Get API Version from .env (or else assume 1.0)
const baseUrl = `/api/v${config.apiVersion}`;

// mount all routes on /api path
app.use(`${baseUrl}`, routes);

// if error is not an instanceOf APIError, convert it.
app.use((err, req, res, next) => {
github Christilut / node-modern-boilerplate / config / express.ts View on Github external
//   origin: [], // TODO add origins for production
    //   optionsSuccessStatus: 200
    // }))

    // Enable Forest Admin (must be done before express error handlers)
  } else {
    app.use(cors())
  }

  // Load Forest Admin (must be after CORS)
  require('config/forestadmin')(app)

  // Enable detailed API logging
  if (env.NODE_ENV !== env.Environments.Test) {
    expressWinston.requestWhitelist.push('body')
    expressWinston.responseWhitelist.push('body')
    app.use(expressWinston.logger({
      winstonInstance: logger,
      meta: true, // optional: log meta data about request (defaults to true)
      msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
      colorStatus: true, // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
      skip: (req, res) => {
        // Filter logging errors here that are not really errors. This also prevents them from showing up in Sentry.

        // Filter 404: bots cause these
        if (env.NODE_ENV === env.Environments.Production) {
          return (
            res.statusCode === httpStatus.NOT_FOUND
            ||
            (res.statusCode === httpStatus.OK && req.url.includes('/misc/health-check'))
          )
        }
github sentinel-official / sentinel / master-node-nodejs / src / config / middlewares.js View on Github external
export default app => {
  app.use(function onError(err, req, res, next) {
    res.statusCode = 500;
    res.end(res.sentry + '\n');
  });
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(cors());
  if (isDev && !isTest) {
    app.use(morgan('dev'));
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    // app.use(
    //   expressWinston.logger({
    //     winstonInstance,
    //     meta: true,
    //     msg:
    //       'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
    //     colorStatus: true,
    //   }),
    // );
  }
};
github eclipse / repairnator / website / repairnator-mongo-rest-api / config / express.js View on Github external
app.use(bodyParser.urlencoded({ extended: true }));

app.use(cookieParser());
app.use(compress());
app.use(methodOverride());

// secure apps by setting various HTTP headers
app.use(helmet());

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// enable detailed API logging in dev env
if (config.env === 'development') {
  expressWinston.requestWhitelist.push('body');
  expressWinston.responseWhitelist.push('body');
  app.use(expressWinston.logger({
    winstonInstance,
    meta: true, // optional: log meta data about request (defaults to true)
    msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
    colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
  }));
}

// mount all routes on /api path
app.use('/repairnator-mongo-api', routes);

// if error is not an instanceOf APIError, convert it.
app.use((err, req, res, next) => {
  if (err instanceof expressValidation.ValidationError) {
    // validation error contains errors which is an array of error each containing message[]
    const unifiedErrorMessage = err.errors.map(error => error.messages.join('. ')).join(' and ');
github strues / boldr / packages / boldr-api / src / middleware / express.js View on Github external
}
    }),
  );
  // must be right after bodyParser
  app.use(expressValidator());
  app.use(
    busboy({
      limits: {
        fileSize: 5242880,
      },
    }),
  );
  app.use(hpp());
  if (process.env.NODE_ENV !== 'production') {
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    app.use(
      expressWinston.logger({
        winstonInstance,
        meta: true,
        msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
        colorStatus: true,
      }),
    );
  }
  app.use(flash());
};
github binbytes / chat-app-server / src / config / middlewares.js View on Github external
export default app => {
  app.use(compression())
  app.use(bodyParser.urlencoded({ extended: true }))
  app.use(bodyParser.json())
  app.use(passport.initialize())
  app.use(cors({
    credentials: true,
    origin: process.env.FRONT_ORIGIN // Change allowed origin url for production
  }))
  app.use(methodOverride())
  if (isDev && !isTest) {
    app.use(morgan('dev'))
    expressWinston.requestWhitelist.push('body')
    expressWinston.responseWhitelist.push('body')
    app.use(
      expressWinston.logger({
        winstonInstance,
        meta: true,
        msg:
          'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
        colorStatus: true
      }),
    )
  }
}
github vukhanhtruong / nodejs-api-boilerplate / src / config / middlewares.js View on Github external
export default app => {
  app.use(compression());
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(passport.initialize());
  app.use(helmet());
  app.use(cors(corsWhiteList));
  app.use(methodOverride());
  if (isDev && !isTest) {
    app.use(morgan('dev'));
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    app.use(
      expressWinston.logger({
        winstonInstance,
        meta: true,
        msg:
          'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
        colorStatus: true,
      }),
    );
  }
};

express-winston

express.js middleware for winstonjs/winston

MIT
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis