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 📦
npm install spin-up-ping
yarn add spin-up-ping
pnpm add spin-up-ping
Usage 💻
import {SpinUp} from "spin-up-ping";
const pinger = new SpinUp({
url: "https://your-server.com",
intervalMinutes: 5,
onSuccess: (response) => {
console.log("Ping successful:", response);
},
onError: (error) => {
console.error("Ping failed:", error);
},
});
pinger.start();
pinger.stop();
API Reference 📚
Constructor Options
interface SpinUpOptions {
url: string;
intervalMinutes: number;
onSuccess?: (response: any) => void;
onError?: (error: Error) => void;
}
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!