Skip to content

mreshank/ping-me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸš€ Ping-Me

GitHub stars Build Status NPM Version License Issues Discussions

Keep your free tier backends alive, responsive, and observable!

Ping-Me is a full-stack open-source infrastructure utility that prevents automatic sleep cycles on free hosting platforms like Render, Railway, Cyclic, Glitch, and Vercel Functions.

πŸ”₯ The Problem

Free-tier backend hosts are amazing β€” until they're not:

  • πŸ”Œ Your server goes to sleep after minutes of inactivity
  • 🐒 First requests are cold, taking seconds to start
  • 😬 It times out if you don't keep it warm
  • πŸ§ͺ When demoing or testing, your APIs break unpredictably

βœ… The Solution

Ping-Me makes sure your backend never sleeps, and if it tries, you know about it:

  • πŸ” Keep-alive Pinging: Automatically pings your endpoint on intervals
  • βš™οΈ Framework Adapters: Plug into Express, Fastify, Koa, Next.js, Hono
  • πŸ§ͺ Dashboard UI: View uptime %, ping latency, error codes, logs
  • πŸ”‘ API Key Access: Each user gets a unique key to isolate metrics
  • πŸ›‘οΈ Abuse Protection: Rate limiting, IP filtering, data-size capping
  • 🧩 CLI Tool: Bootstrap your server with pings instantly

πŸ“¦ Installation

# Install the core library
npm install @ping-me/core

# Or use the framework-specific adapter
npm install @ping-me/express
# npm install @ping-me/next
# npm install @ping-me/fastify
# npm install @ping-me/koa
# npm install @ping-me/hono

Or use the CLI to set up:

npx ping-me init
npx ping-me add express

🧰 Usage

Express

const express = require('express');
const { withPingMe } = require('@ping-me/express');

const app = express();

// Add ping-me to your app
withPingMe(app, {
  route: '/ping-me',          // Custom route (default: /ping-me)
  interval: 300000,           // 5 minutes
  baseUrl: 'https://my-api.com', // Optional: specify exact URL
  apiKey: 'your-api-key'      // Optional: for dashboard metrics
});

app.listen(3000);

Next.js

// pages/api/ping-me.js
import { createPingMeHandler } from '@ping-me/next';

export default createPingMeHandler();

// In your _app.js or a component
import { usePingMe } from '@ping-me/next';

function MyApp({ Component, pageProps }) {
  // This will auto-ping your endpoint
  const status = usePingMe({
    interval: 300000, // 5 minutes
    apiKey: process.env.PING_ME_API_KEY // Optional
  });
  
  return <Component {...pageProps} />;
}

Core Usage

import { pingMe } from '@ping-me/core';

// Start pinging
const stopPinging = pingMe({
  url: 'https://my-api.com/ping',
  interval: 300000, // 5 minutes
  apiKey: 'your-api-key', // Optional
  log: console.log     // Optional custom logger
});

// Stop pinging later if needed
stopPinging();

πŸ“Š Dashboard

A beautiful Next.js dashboard is available to monitor your backend services:

  • πŸ“ˆ Uptime Charts: See your uptime over time
  • ⏱️ Response Times: Track latency trends
  • πŸ’¬ Status Logs: View ping history and errors
  • πŸ”” Alert Settings: Configure notification preferences

Try the Dashboard β†’

πŸ§‘β€πŸ’» API

Track your metrics with the Ping-Me API:

# Ping Logging Endpoint
POST https://ping-me-api.vercel.app/api/log
Authorization: Bearer your-api-key
{
  "endpoint": "https://my-api.com",
  "status": 200,
  "responseTime": 123
}

# Get Metrics
GET https://ping-me-api.vercel.app/api/metrics
Authorization: Bearer your-api-key

πŸ› οΈ Project Structure

This is a monorepo built with Turborepo and PNPM:

ping-me/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ dashboard/     ← Next.js 14 + Tailwind CSS dashboard
β”‚   β”œβ”€β”€ examples/      ← Example usage of ping-me
β”‚   └── api/           ← Serverless API routes
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/          ← Framework-agnostic ping logic
β”‚   β”œβ”€β”€ cli/           ← CLI: npx ping-me init
β”‚   β”œβ”€β”€ express/       ← Express adapter
β”‚   β”œβ”€β”€ fastify/       ← Fastify adapter
β”‚   β”œβ”€β”€ next/          ← Next.js adapter
β”‚   β”œβ”€β”€ koa/           ← Koa adapter
β”‚   β”œβ”€β”€ hono/          ← Hono adapter
β”‚   └── metrics-server/ ← Metrics Server

🀝 Contributing

We welcome contributions! See CONTRIBUTING.md for details.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Install dependencies: pnpm install
  4. Make your changes
  5. Run tests: pnpm test
  6. Commit your changes: git commit -m 'Add some amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ’– Sponsorship

If you find Ping-Me useful, please consider sponsoring the project:

GitHub Sponsors Buy Me a Coffee


Made with ❀️ by @mreshank

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors