This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.fontSize": 16, | |
"terminal.integrated.fontSize": 16, | |
"window.zoomLevel": 0 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: this adds a filename and line number to winston's output | |
// Example output: 'info (routes/index.js:34) GET 200 /index' | |
var winston = require('winston') | |
var path = require('path') | |
var PROJECT_ROOT = path.join(__dirname, '..') | |
var logger = new winston.logger({ ... }) | |
// this allows winston to handle output from express' morgan middleware |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
const { format } = winston; | |
const { combine, colorize, timestamp, printf } = format; | |
/** | |
* /** | |
* Use CallSite to extract filename and number, for more info read: https://v8.dev/docs/stack-trace-api#customizing-stack-traces | |
* @param numberOfLinesToFetch - optional, when we want more than one line back from the stacktrace | |
* @returns {string|null} filename and line number separated by a colon, if numberOfLinesToFetch > 1 we'll return a string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
require('winston-daily-rotate-file'); | |
const path = require('path'); | |
const PROJECT_ROOT = path.join(__dirname, '..'); | |
const highlight = require('cli-highlight').highlight; | |
// const options = { | |
// file: { | |
// level: 'info', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const favicon = require('serve-favicon'); | |
const path = require('path'); | |
const rfs = require('rotating-file-stream'); | |
require('dotenv').config(); // Put before logger.js | |
// const logger = require('./util/loggerEasy'); | |
const logger = require('./util/logger'); | |
const { stream } = logger; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const favicon = require('serve-favicon'); | |
const path = require('path'); | |
const rfs = require('rotating-file-stream'); | |
// const logger = require('./util/loggerEasy'); | |
const logger = require('./util/loggerWithLineNew'); | |
const { stream } = logger; | |
const morgan = require('morgan'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
require('winston-daily-rotate-file'); | |
require('winston-mongodb'); | |
const path = require('path'); | |
const PROJECT_ROOT = path.join(__dirname, '..'); | |
const highlight = require('cli-highlight').highlight; | |
const arrow = '\u276F\u276F\u25B6'; | |
const logConfig = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MONGO_URI='mongodb+srv://<user>:<password>@<cluster_name>.xxxxx.mongodb.net/<database_name>?retryWrites=true&w=majority' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ErrorResponse extends Error { | |
constructor(message, statusCode, reason) { | |
super(message); | |
this.statusCode = statusCode; | |
this.reason = reason; | |
this.name = 'ErrorResponse'; | |
} | |
} | |
module.exports = ErrorResponse; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ErrorResponse = require('./errorResponse'); | |
const logger = require('./logger'); | |
const colors = require('colors'); | |
colors.enable(); | |
const errorHandler = (err, req, res, next) => { | |
let error = { ...err }; | |
error.message = err.message; | |
// logger.error(err.stack.red); | |
console.log(err.stack.red); |