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

woke-dyno

v1.0.0

Published

woke-dyno is a tiny utility to prevent your server from sleeping when not in use

Downloads

99

Readme

woke-dyno

There are some hosting services like Render.com that will allow you to host a server for free, but with some limitations. If it does not receive any web traffic for a set period of time, your free server will be put to sleep, leaving the next user to visit with a possibly long wait time (up to thirty seconds!) as your server starts up again. This is long enough for many users to assume the site is broken and move on. woke-dyno is a tiny utility to prevent your server from sleeping when not in use.

woke-dyno will perform a simple HTTP request to whatever url you provide, at regular intervals. If you use the url of your free server, that single GET request will be sufficient to prevent it from going dormant, so that visitors will not be made to endure unreasonably long loading times.


Installation

To install with npm:

npm install --save woke-dyno

To install with Yarn:

yarn add woke-dyno

Use

Import the default export from woke-dyno (a function) and invoke it with the url of your server as an argument. Call the .start() method on the returned object to start woke-dyno:

/* Example: as used with an Express app */

import express from "express";
import wokeDyno from "woke-dyno";

const SELF_URL = "https://hotdogisasandwich.com"; // the URL of the server to keep awake

// create an Express app
const app = express();

...

// configure wokeDyno
const dynoWaker = wokeDyno(SELF_URL);

// start the server, then start wokeDyno
app.listen(PORT, () => {
    dynoWaker.start();
});

Options

By default, woke-dyno will make its HTTP request once every 14 minutes, with no naptime. By passing an options object, instead of a string, you can change the default settings:

/* Example: with custom options */

...

// configure wokeDyno
const dynoWaker = wokeDyno({
  url: SELF_URL,  // url string
  interval: 1000 * 60 * 20, // interval in milliseconds (20 minutes in this example)
  startNap: [5, 0, 0, 0], // the time to start nap in UTC, as [h, m, s, ms] (05:00 UTC in this example)
  endNap: [9, 59, 59, 999] // time to wake up again, in UTC (09:59:59.999 in this example)
});

// start the server, then start wokeDyno
app.listen(PORT, () => {
  dynoWaker.start(); 
});
  • url (String): The URL of the server to wake
  • interval (Number): The interval to wait between fetch requests, in milliseconds
  • startNap (Number[]): An array of four numbers, representing the time to begin "napping" ([h, m, s, ms])
  • endNap (Number[]): An array of four numbers, representing the time to stop "napping" and resume fetch requests ([h, m, s, ms])

Because free hosting providers usually limit your free server time, you may want to use the startNap and endNap parameters to let your server sleep during times that it is unlikely to be used. The start and end times are entered as arrays in the format: [hours, minutes, seconds, milliseconds], and are in Coordinated Universal Time (UTC).


Methods

Upon invoking the default export from woke-dyno with your chosen options, you will be returned an object with two methods:

  • start(): Starts woke-dyno, using the configured options
  • stop(): Clears the current timer, stopping woke-dyno

Credits

woke-dyno was made by Dennis Hodges, a JavaScript developer.


License

Copyright © 2019 Dennis Hodges

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.