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
Maintainers
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.
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 servicestop()
: Stop the ping service
Common Use Cases 🎯
Free Hosting Services
- Prevent Render, Railway.app etc from sleeping
Development & Testing
- Keep development servers active
- Monitor server health
Best Practices 💡
- Set interval slightly lower than your hosting platform's timeout
- Implement error handling for network issues
- 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License 📄
ISC © Muhsin Abdul Nissar
Support ⭐
If you found this package helpful, please consider giving it a star on GitHub!