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

spin-up-ping

v1.0.5

Published

Keep your server awake and prevent it from spinning down due to inactivity! Perfect for free-tier hosting platforms like Render, Heroku, etc.

Downloads

389

Readme

spin-up-ping 🚀

Keep your server awake and prevent it from spinning down due to inactivity! Perfect for free-tier hosting platforms like Render, Heroku, etc.

NPM Version GitHub Issues License

Why spin-up-ping? 🤔

Free-tier hosting services often spin down your server after a period of inactivity (usually 15-30 minutes). This can lead to slow response times when the server needs to spin up again. spin-up-ping solves this by sending periodic pings to keep your server alive.

Features ✨

  • 🔄 Configurable ping intervals (minimum 5 minutes)
  • 📊 Success and error callbacks for monitoring
  • 🛡️ Built-in abuse prevention
  • 💪 Written in TypeScript with full type support
  • 🎯 Zero dependencies (except axios for HTTP requests)

Installation 📦

# Using npm
npm install spin-up-ping

# Using yarn
yarn add spin-up-ping

# Using pnpm
pnpm add spin-up-ping

Usage 💻

import {SpinUp} from "spin-up-ping";

const pinger = new SpinUp({
  url: "https://your-server.com", // Your server URL
  intervalMinutes: 5, // Minimum 5 minutes
  onSuccess: (response) => {
    // Optional success callback
    console.log("Ping successful:", response);
  },
  onError: (error) => {
    // Optional error callback
    console.error("Ping failed:", error);
  },
});

// Start pinging
pinger.start();

// Stop pinging (if needed)
pinger.stop();

API Reference 📚

Constructor Options

interface SpinUpOptions {
  url: string; // URL to ping
  intervalMinutes: number; // Interval between pings (min: 5)
  onSuccess?: (response: any) => void; // Success callback
  onError?: (error: Error) => void; // Error callback
}

Methods

  • start(): Start the ping service
  • stop(): Stop the ping service

Common Use Cases 🎯

  1. Free Hosting Services

    • Prevent Render, Railway.app etc from sleeping
  2. Development & Testing

    • Keep development servers active
    • Monitor server health

Best Practices 💡

  1. Set interval slightly lower than your hosting platform's timeout
  2. Implement error handling for network issues
  3. Use environment variables for server URLs

Contributing 🤝

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License 📄

ISC © Muhsin Abdul Nissar

Support ⭐

If you found this package helpful, please consider giving it a star on GitHub!