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

sails-hook-dev

v1.3.0

Published

Hook for Sails.js full of development utilities.

Downloads

267

Readme

sails-hook-dev

A Sails hook that provides diagnostic / debugging information during development.

Check the memory usage or environent variables of the currently-running Sails/Node.js process. Or check how it's configured, or the installed versions of its dependencies. You can also fetch session data for the currently logged in user, or force Node's garbage collector to run.

Note

The diagnostic routes exposed by this hook will work when your app is in development mode (i.e. NODE_ENV !== "production")

If you want to enable this hook in a production-like environment where NODE_ENV is set to production (such as your staging environment), then use the dev.enableInProduction setting.

For security reasons, this hook should never be used in a true production environment that touches real users.

Install

In your Sails project:

npm install sails-hook-dev --save-dev

^^ That will install this hook as a dev dependency, for local development only. If you also want to use sails-hook-dev somewhere else (like in your staging environment), then instead use:

npm install sails-hook-dev

Usage

To see all available development routes, visit http://localhost:1337/dev:

screenshot of what the dev page looks like

See all available routes

http://localhost:1337/dev/routes

See session of currently logged-in user

http://localhost:1337/dev/session

See actual versions of dependencies in node_modules

http://localhost:1337/dev/dependencies

See current memory usage

http://localhost:1337/dev/memory

Debugging

Deliberately crash the process

http://localhost:1337/dev/throw-uncaught

Simulate endpoint that never sends a response

http://localhost:1337/dev/dont-respond

Simulate locking up the process by overwhelming its CPU

http://localhost:1337/dev/peg

Simulate runaway recursion that overflows the call stack

http://localhost:1337/dev/overflow-stack

Simulate exceeding the process's available memory

http://localhost:1337/dev/overflow-memory

Simulate an endpoint that consumes memory, but does not leak

http://localhost:1337/dev/consume-memory

Simulate an endpoint with an actual memory leak

http://localhost:1337/dev/leak-memory

Run the garbage collector

http://localhost:1337/dev/gc

Note that you must lift your app with node --expose-gc app.js in order for the garbage collector to be accessible from userland.

Setting this up on your staging server

Want to use this hook in your staging environment? Since the NODE_ENV environment variable will be set to production, the hook will be disabled by default. But never fear: there is a simple, recommended solution.

At the bottom of your staging configuration (config/env/staging.js), set:

  dev: Object.assign({}, PRODUCTION_CONFIG.dev||{}, {
    enableInProduction: true
  }),

Note that you could hypothetically specify this in your environment variables, by setting sails_dev__enableInProduction=true. But as of Sails 1.1.0 the behavior of rc when merging this particular config key gets a little bit wonky, so it's best to stick with the solution above.

Help

If you have further questions or are having trouble, click here.

Bugs   NPM version

To report a bug, click here.

Contributing

Please observe the guidelines and conventions laid out in the Sails project contribution guide when opening issues or submitting pull requests.

NPM info

License

MIT © 2015, 2016, 2018-present Mike McNeil

As for the Sails framework, it's free and open-source under the MIT License too.