
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.
koa-chokidar
Advanced tools
koa middleware to watch and reload files on change. Makes nodemon unnecessary.
koa middleware to watch and reload files on change. Makes nodemon unnecessary.
Inspired by Don't use nodemon, there are better ways! and connect-chokidar, this module alleviates the pain of waiting for webpack (or your favorite bundler) to compile, anytime a hot-reloaded file changes on disk, for Koa apps.
> npm i koa-chokidar
// or if using yarn
> yarn add koa-chokidar
const createWatcher = require('koa-chokidar')
const koaChokidar = createWatcher(`${__dirname}`, {
// Unless specified explictly, `process.env.NODE_ENV !== 'production'` will be used as the default
// so in production mode, this middleware will do nothing (to override, set it to `true`)
watch: process.env.NODE_ENV !== 'production',
// Only the filenames that are in the regexp below will be deleted
// from `require.cache` when files change
requireCacheToRemoveRe: /[/\\]src[/\\]/,
// `chokidar` opts can be provided here
chokidar: {
ignored: ['node_modules']
}
})
// ...
const router = require('koa-router')()
// You'll have to `require()` all of the files that your
// local middleware or router depend on. This is because if we required it on top,
// the router / middleware would always refer to that instance and there would be
// no way of clearing it.
router.get('/', koaChokidar(() => require('./src/homepage')))
router.get('/users', koaChokidar(() => require('./src/user-api')))
Checkout the example folder for a sample koa
app. You can run the example app by:
$ git clone https://github.com/mrchief/koa-chokidar
$ cd koa-chokidar/example
$ npm install
$ npm start
Visit http://localhost:8000
in any browser. Then try changing the response in any of the watched files and hit refresh on the browser. Watch the response change without restarting the node process!
The sample app uses koa-router
but you can use any other router/middleware. The idea remains the same - load your watched files via koa-chokidar
. Anything required/imported outside of koa-chokidar
will not be watched/reloaded.
Run your process with the NODE_DEBUG=koa-chokidar
environment variable set.
Released 2018 by Hrusikesh Panda
FAQs
koa middleware to watch and reload files on change. Makes nodemon unnecessary.
The npm package koa-chokidar receives a total of 2 weekly downloads. As such, koa-chokidar popularity was classified as not popular.
We found that koa-chokidar 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.