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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nodejs-server-ssi

v1.0.2

Published

## Install

Readme

nodejs-server-ssi

Install

$ npm i nodejs-server-ssi

Usage: include directive

Syntax

<!--#include file="./header.shtml" -->
<!--#include file="./components/header.shtml" -->

ps. The file path should be relative.

  1. Create an NPM project folder and install the nodejs-server-ssi module.

    # bash
    $ mkdir <yourProject>
    $ cd <yourProject>
    $ npm init -y
    $ npm i nodejs-server-ssi
  2. (Optional for testing) Clone this repo and copy the public folder inside the tests folder to your project folder.

    # bash
    $ git clone https://github.com/cv47522/nodejs-server-ssi.git
    $ cp -R path/to/nodejs-server-ssi/tests/public path/to/<yourProject>
  3. (Optional) Or create your own HTML/SHTML files following the above include directive syntax.

  4. Create an index.js and import the module. (ps. The server of the module can be started with or without specifying a port and a file directory since it has its default values.)

    # bash
    $ cd <yourProject>
    $ touch index.js

    index.js

    const path = require('path');
    const ssiServer = require('nodejs-server-ssi');
    
    const staticRoot = path.join(__dirname, 'public');
    const homepage = path.join(staticRoot, 'index.shtml');
    
    ssiServer();
    // or use specific homepage
    // ssiServer(staticRoot, homepage);
    // or use specific port
    // ssiServer(staticRoot, homepage, 5000);
  5. Start the server by running the index.js.

    # bash
    $ node .
  6. Go to (default) http://localhost:3000. ScreenShot.png

Implementation

Reference

External Libraries and Tools

Workflow

First, I created an http server serving a simple webpage with the express framework inside index.js. Next, I referenced some ssi repositories given above to implement the <!--#include file="myFile.shtml" --> SSI directive inside the lib folder. Then, I imported the SSI functionality to the index.js and exported this file as a ssiServer module. Since the ssiServer module should have its default port and static files to serve, I added some HTML and SHTML files to the public folder.

Finally, I added an example file testInclude.js to the tests along with some other HTML and SHTML files to test my nodejs-server-ssi project, packaged the whole project as an NPM module, and published it to https://www.npmjs.com/package/nodejs-server-ssi.

During the development, I always used the nodemon module to automatically reload the server whenever changing a file and debugged my Node.js project inside VS Code.

Design Pattern

Factory

The project mostly uses the factory pattern to define a generic interface for creating objects since it is useful and easier to maintain when the creation process is complex.

ssiContentGenerator.js

const ssiDecoder = require('./ssiDecoder');

const ssiContentGenerator = (rawHtml, options) => {
    options = options || {};
    options.data = options.data || {};
    options.root = options.root || '';

    return new Promise(async (resolve, reject) => {
        try {
            const htmlToJs = await ssiDecoder.decode(rawHtml, options);
            const result = generateHtml(htmlToJs, options.data);
            resolve(result);
        } catch(err) {
            reject(err);
        }
    });
}

module.exports = ssiContentGenerator;