
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
A middleware to simply attach a logger to the request context of your http server of choice
crummy
Crummy
A logger's bus. Also an adjective meaning "no good" or "undesirable"
crummy
is middleware to simply attach a bunyan logger to the request
context of your http server of choice. Below is a list of supported http server
modules:
If you don't see yours above, feel free to request it in the issues section of this repository, or use the adapter module to adapt it to your own.
The reason bunyan
is required is because it is the one popular logging module
that I could find that made it really easy to make a copy of a logger with all
of the different logging transports that the original had. If winston or other
loggers support this, I would be willing to support multiple logging modules.
express
const express = require('express')
const crummy = require('crummy/express')
const uuid = require('uuid')
const log = require('./lib/log')
const app = express()
app.use(crummy({
path: 'log', // will attach to `req.log`
logger: log, // The bunyan logger to use. `.child()` will be called on it
meta: (req, res) => { // attaches returned object to metadata of each log in the request
return {
reqId: return uuid.v4()
}
}
}))
app.use((req, res, next) => {
req.log.info(req.method, req.path) // Will log the path requested, as well as any default meta data
})
// ... routes, other middleware, app.listen(), etc.
koa
const koa = require('koa')
const crummy = require('crummy/koa')
const uuid = require('uuid')
const log = require('./lib/log')
const app = koa()
app.use(crummy({
path: 'log', // will attach to `req.log`
logger: log, // The bunyan logger to use. `.child()` will be called on it
meta: (req, res) => { // attaches returned object to metadata of each log in the request
return {
reqId: return uuid.v4()
}
}
}))
app.use(function *(next) {
this.log.info(req.method, req.path);
let start = Date.now()
yield next
let responseTime = Date.now() - start
this.log.info(`${responseTime}ms`)
})
// ... other koa setup stuff
This really isn't a lot of code. It just has some sensible defaults. The core piece of this module might make more sense if there were different adapters to utilize. Below is an example of what this module is doing without actually using this module:
const express = require('express')
const uuid = require('uuid')
const log = require('./lib/log')
const app = express()
app.use((req, res, next) => {
req.log = log.child({ reqId: uuid.v4() })
next()
})
app.use((req, res, next) => {
req.log.info(req.method, res.path)
})
// ... routes, other middleware, app.listen(), etc.
After reading that, you will probably just opt to just roll your own, which is totally fine. I wrote this because I don't like to have any miscellaneous modules lying around. I like most of my middleware stack to be declarative. For what it's worth, there are tests around the functionality described above, which might be a bit overkill.
FAQs
A middleware to simply attach a logger to the request context of your http server of choice
The npm package crummy receives a total of 0 weekly downloads. As such, crummy popularity was classified as not popular.
We found that crummy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.