Tired of receiving Database Hibernated messages? Keep Your DB Awake with Hibernot !


Hey there, fellow devs! I’m super excited to share something I’ve been working on. On May 24, 2025, I published my first npm package, Hibernot, and as of today (09:12 PM IST, May 25, 2025), I’m here to tell you how it can save your portfolio projects from those awkward hibernation fails. If you’re a student dev like me, this tool is gonna be your new best friend. Let’s dive in!



The Struggle is Real: Why We Need Hibernot 😓

As student developers, we’re always building cool projects to show off in our portfolios—think side gigs, hackathons, or that app you’re proud to put on your resume. We often use free-tier services like Supabase, MongoDB Atlas, NeonDB, or Langflow because, well, we’re broke, right? These services are awesome, but there’s a catch: they hibernate after inactivity.
Received one of these ?

Image description

Picture this: you’ve shared your project link with a recruiter, they click it, and… the database is asleep. The app stalls, the request fails, and by the time the DB wakes up, they’ve already closed the tab. I’ve been there—gotten those “your DB is inactive” emails way too many times. It’s frustrating, and it makes your project look unprofessional. We need a way to keep our backends awake so our apps are always ready to shine. That’s where Hibernot comes in!



What is Hibernot? A Simple, Revolutionary Dev Tool 🌟

Hibernot is a lightweight npm package I built to keep your free-tier backend services active by automatically running a function (like a DB query) after a set period of inactivity. No more sleepy databases—your app stays live, ready for anyone to check out.

Here’s why it’s a game-changer:

  • Useful for Devs: It ensures your portfolio projects are always responsive, especially when HR or collaborators are viewing them.
  • Easy Setup: You can get it running in your Express app in under 5 minutes.
  • Revolutionary: No more manual pings or hacky workarounds—Hibernot handles it automatically, with features like retries and hit tracking built in.

You can grab it now:



How to Set Up Hibernot: It’s Crazy Simple! 🚀

Let’s set up Hibernot in a basic Express app. I’ll show you how easy it is to integrate and how it keeps your backend awake. Follow along—this takes just a few steps.



Step 1: Create a New Project

Make a new folder and initialize a Node project:

mkdir hibernot-demo
cd hibernot-demo
npm init -y
Enter fullscreen mode

Exit fullscreen mode



Step 2: Install Dependencies

Install Express and Hibernot:

npm install express hibernot
Enter fullscreen mode

Exit fullscreen mode



Step 3: Create Your Express App

Create an index.js file and add this code:

const express = require('express');
const { Hibernot } = require('hibernot');

const app = express();
const port = 3000;

// Simulate a DB query
const fetchRecords = async () => {
  return [{ id: 1, name: 'Demo Record' }];
};

// Set up Hibernot to keep the backend awake
const hibernotDB = new Hibernot({
  name: 'DemoDB',
  inactivityLimit: 10000, // 10 seconds for testing (use 300000 for 5 mins in production)
  maxRetries: 3, // Retries if the keep-alive fails
  keepAliveFn: async () => {
    const records = await fetchRecords();
    console.log('[DemoDB] Keep-alive query:', records);
  },
});

// Track API hits with Hibernot middleware
app.use('/', hibernotDB.middleware());

// Basic route to test
app.get('/', async (req, res) => {
  const records = await fetchRecords();
  res.json({
    message: 'Hibernot Demo API',
    records,
    stats: hibernotDB.getStats(),
  });
});

// Stats route to check Hibernot's status
app.get('/stats', (req, res) => {
  res.json({ demoDB: hibernotDB.getStats() });
});

app.listen(port, () => console.log(`Running on http://localhost:${port}`));
Enter fullscreen mode

Exit fullscreen mode



Step 4: Update package.json

Add a start script to your package.json:

{
  "scripts": {
    "start": "node index.js"
  }
}
Enter fullscreen mode

Exit fullscreen mode



Step 5: Run and Test

Start the app:

npm start
Enter fullscreen mode

Exit fullscreen mode

  • Hit http://localhost:3000/ (via browser or curl):
  {
    "message": "Hibernot Demo API",
    "records": [{ "id": 1, "name": "Demo Record" }],
    "stats": {
      "getCounter": 1,
      "lastAPIhit": 1745177000000,
      "name": "DemoDB"
    }
  }
Enter fullscreen mode

Exit fullscreen mode

  • Wait 10 seconds, and check the console:
  [DemoDB] Keep-alive query: [ { id: 1, name: 'Demo Record' } ]
Enter fullscreen mode

Exit fullscreen mode

  • Hit http://localhost:3000/stats to see the updated stats:
  {
    "demoDB": {
      "getCounter": 2,
      "lastAPIhit": 1745177010000,
      "name": "DemoDB"
    }
  }
Enter fullscreen mode

Exit fullscreen mode

That’s it! In just a few lines, Hibernot is keeping your backend awake, tracking hits, and retrying failed keep-alive attempts. You can swap fetchRecords with a real DB query (like MongoDB or Supabase) to keep your actual service active.



Why Hibernot is a Must-Have Dev Tool 🔧

  • Saves Your Portfolio: No more awkward fails when someone checks your project.
  • Minimal Setup: A few lines of code, and you’re done—no complex configs.
  • Dev-Friendly Features: Hit tracking, retry logic, and clear logs make debugging a breeze.
  • Lightweight: No heavy dependencies, just a lean solution for free-tier apps.

I built Hibernot because I’ve felt the pain of hibernation issues, and I know many of you have too. It’s a small tool, but it can make a big difference for student devs like us. Give it a try, and let me know what you think in the comments—I’d love to hear your feedback!

Happy coding! 😄



Source link