npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodehawk

v0.0.7

Published

A slim and hyper configurable watcher for Node.

Downloads

5

Readme

Nodehawk

🗣 This project is actively looking for contributors like you!

Nodehawk is a watcher for your Node server, without a lot of overheads. It observes your directories and files for changes, and triggers rebuilds to make Node application developments hassle-free. Supports every NodeJS framework.

To check the progress, do check out our weekly digest!

This project is inspired by the fantastic Nodemon and uses Chokidar under the hood. Thanks to Freepik for the icon.

npm Build Coverage Status All Contributors

Table of contents

Why Nodehawk?

During the development of a Node server, there is a need for a very versatile watcher than can keep track of your changes and rebuild your application to reflect the same. Of course, there is Nodemon which is the inspiration of this tool, but there are some shortcomings to it.

One of the major differentiator of Nodehawk, is that it is built specifically to make development of Node servers less cumbersome. It primarily focuses on providing a watcher that addresses issues around watching and restarting.

Installation

There are two ways to use this. Either install it globally or add it as a development dependency.

  • Installing globally:
# with npm
npm i -g nodehawk

# with yarn
yarn global add global nodehawk
  • Adding the package as a dev dependency to your project:
# with npm
npm i -D nodehawk

# with yarn
yarn add -D nodehawk

Usage

For using the watcher, simple add a script to your package.json:

{
    "scripts": {
        "start": "nodehawk"
    }
}

IMPORTANT: Nodehawk will by default pass a process.env.PORT to your process. Use it to run your app on that port. All you need to do is:

- app.listen(<your-existing-port>);
+ app.listen(process.env.PORT);

This will help Nodehawk kill the process running on the port to prevent any EADDRINUSE errors. You can customize the port in the configurations below.

You need to provide an exec command in a .nodehawkrc file. The simplest one for your server can be:

{
    "exec": "node src/server"
}

The watcher will run with the default configurations, and automatically start watching your src directory. If you want to customize it further, you can read the whole list of configurations, which can be specified in a .nodehawkrc file in the root of your project alongside package.json.

Configurations

Nodehawk allows a rich variety of configuration options, to suit your needs. All of these configurations are provided through a .nodehawkrc file.

Basic

| Key | Type | Default | Description | | -------- | ---------------- | --------- | ------------------------------------------------------------------------------------------ | | paths | string|string[] | "./src" | The path or array of paths or globs to watch for changes. | | root | string | "." | The root folder from where all paths are resolved. | | exec | string | "" | The command to execute when a restart is triggered. | | port | number | 4000 | The port number where your process will run. | | logLevel | number | 3 | The verbosity of logs to be displayed. 1:fatal, 2:error, 3:warn, 4:info, 5:debug |

Performance

| Key | Type | Default | Description | | ---------- | -------------- | ------- | --------------------------------------------------------------------------- | | buffer | number | 1500 | Buffer to wait for events after which the exec command should be trigger. | | bufferPoll | number | 100 | Poll to check the stability of the buffer. | | ignored | string|regexp | "" | A path or glob of files or folders to be ignored. |

Display

| Key | Type | Default | Description | | ----------------------- | ------- | ----------------- | ----------------------------------------------------------- | | display.onBeforeStart | string | "Starting..." | Message to display while starting the process. | | display.onStart | string | "Started" | Message to display after the process has started. | | display.onBeforeRestart | string | "Restarting..." | Message to display while restarting the process. | | display.onRestart | string | "Restarting..". | Message to display after the process has restarted. | | display.onBeforeStop | string | "Stopping..." | Message to display while stopping the process. | | clearScreen | boolean | true | Whether to clear the console on start/restart event or not. |

Process

| Key | Type | Default | Description | | --- | ------ | ------- | ------------------------------------------------ | | env | object | {} | Key value pairs to be assigned to process.env. |

The complete API documentation is available on the website.

Examples

There are quite a few real-world examples of Nodehawk. You can the in the examples directory.

Roadmap

  • Integrate ability to add watcher listeners while using the package as an API.
  • Integrate actions for automatic publishing.

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!