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

greenlock-hapi

v2.1.3

Published

An Automated HTTPS ACME client (Let's Encrypt v2) for hapi

Downloads

12

Readme

Greenlock™ for hapi

An Automated HTTPS ACME client (Let's Encrypt v2) for hapi

| Sponsered by ppl | Greenlock™ is for Browsers, Node.js, Commandline, Express.js, Node.js Cluster, hapi, Koa, and rill |

Features

  • [x] Automatic Registration via SNI (httpsOptions.SNICallback)
  • [x] Secure domain approval callback
  • [x] Automatic renewal between 10 and 14 days before expiration
  • [x] Virtual Hosting (vhost) with Multiple Domains & SAN
  • [x] plugins for AWS, redis, etc
  • [x] and more

This module is just an alias for greenlock-express.js, which works with any middleware system.

Install

npm install --save [email protected]

QuickStart

'use strict';

//////////////////////
// Greenlock Setup  //
//////////////////////

var greenlock = require('greenlock-hapi').create({
  version: 'draft-11' // Let's Encrypt v2
  // You MUST change this to 'https://acme-v02.api.letsencrypt.org/directory' in production
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'

, email: '[email protected]'
, agreeTos: true
, approveDomains: [ 'example.com' ]

  // Join the community to get notified of important updates
  // and help make greenlock better
, communityMember: true

, configDir: require('os').homedir() + '/acme/etc'

//, debug: true
});


///////////////////
// Just add hapi //
///////////////////

var hapi = require('hapi');
var https = require('https');
var server = new hapi.Server();
var acmeResponder = greenlock.middleware();
var httpsServer = https.createServer(greenlock.httpsOptions).listen(443);

server.connection({ listener: httpsServer, autoListen: false, tls: true });

server.route({
  method: 'GET'
, path: '/.well-known/acme-challenge'
, handler: function (request, reply) {
    var req = request.raw.req;
    var res = request.raw.res;

    reply.close(false);
    acmeResponder(req, res);
  }
});

server.route({
  method: 'GET'
, path: '/'
, handler: function (request, reply) {
    reply("Hello, I'm so Hapi!");
  }
});


//
// http redirect to https
//
var http = require('http');
var redirectHttps = require('redirect-https')();

http.createServer(greenlock.middleware(redirectHttps)).listen(80, function () {
  console.log('Listening on port 80 to handle ACME http-01 challenge and redirect to https');
});

Usage & Troubleshooting

See https://git.coolaj86.com/coolaj86/greenlock-express.js

Handling a dynamic list of domains

In the oversimplified exapmple above we handle a static list of domains. If you add domains programmatically you'll want to use the approveDomains callback.

SECURITY: Be careful with this. If you don't check that the domains being requested are the domains you allow an attacker can make you hit your rate limit for failed verification attempts.

We have a vhost example that allows any domain for which there is a folder on the filesystem in a specific location.

See that example for an idea of how this is done.