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

localhandler

v0.2.0

Published

HTTP server that resolves local html files that use Englishtown handler syntax for blurbs, CCLs, medias and CMS

Downloads

4

Readme

local handler

A HTTP server that interprets Englishtown handler syntax of blurbs, CCLs, medias and CMSs used in HTML files, it is primarily targeted to be used in conjunction with a reverse proxy that serve local files in front-end dev environment, enabling you to preview changes and make local debugging a lot easier, check the below Configure Reverse Proxy configurations section to understand how it works.

Installation

npm i -g localhandler

Basic Usage

Start the localhandler as a local HTTP server in your application working copy:

> cd your-app
> localhandler -b school/e12
localhandler is running on port:3000

Command Line Options

'-b, --basepath' : the base URL on which your application is mounted

This option set the root path of the web application, so local files are resolved relative to this base path. Use this option to make the local handler URL matches with the virtual path configuration of your HTTP server, default to the root path '/'.

'-f, --processor' : local module implements a custom content processor function

This option specified a javascript file that export a function, for custom processing as the tip of the HTML processing pipeline, basically transform the file contents that are supposed to be consumed by the next processor, e.g.

module.exports = function preProcess(html) {
  // reinforce "dev" environment, and use local static file instead of the CDN version
  return html.replace(new RegExp('{CCL:myapp.ui.env}', 'gi'), 'dev')
    .replace(new RegExp('{CCL:configuration.servers.cache}/_shared/myapp/{CCL:myapp.ui.version}/?', 'gi'), '');
};

'-p, --port' : specify your custom port to listen for HTTP request, default to '3000'

This option is just to override the server port to listen for incoming HTTP requests.

Integrate with other Reverse Proxies

Depending on your HTTP Reverse Proxy of choice, the configuration would vary while here we exemplify the Apache mod_proxy configurations that are required to integrate the localhandler server to setup a sample Englishtown UAT dev environment.

# Sample Reverse Proxy for the UAT server environment
<VirtualHost *:80>
    DocumentRoot /Users/garry/Stash/labs-school/school-ui
    ServerName schooluat.dev
    ServerAlias schooluat.englishtown.local
    # This delegate all requests for HTML files to the localhandler server
    ProxyPassMatch ^/(.*\.html)$ http://localhost:3000/$1
    ProxyPass / http://schooluat.englishtown.com/
    ProxyPassReverse / http://schooluat.englishtown.com/
    ProxyPassReverseCookieDomain schooluat.englishtown.com schooluat.dev
    ProxyPassReverseCookieDomain schooluat.englishtown.com schooluat.englishtown.local
</VirtualHost> 
# Sample Reverse Proxy for the UAT server environment on Nginx
http {
    server {
        listen 80;
        server_name schooluat.dev schooluat.englishtown.local;
        root /Users/garry/Stash/labs-school/school-ui;
        add_header Cache-Control "public, max-age=0";

        proxy_set_header Host $proxy_host;
        proxy_cookie_domain $proxy_host $host;

        location ~* \.html$ {
            proxy_pass http://127.0.0.1:3000;
        }

        location / {
            resolver 10.128.34.91 10.128.34.94;
            proxy_pass http://schooluxuat.englishtown.com;
        }
    }
}