1.4.1 • Published 3 months ago

@ln-e/ssi-middleware v1.4.1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 months ago

Express middleware to render Server Side Includes

NPM version

Express-style middleware to process SSI directives.

The #include supports both static files and virtual paths which are fetched via HTTP(S).

<html>
  <!--#include file="/static.txt"-->
  <!--#include virtual="/dynamic"-->
</html>

Other ssi instructions supported via node-ssi

Usage

See the basic usage example below. In order to resolve static files the baseDir option has to be provided, respectively baseUrl to resolve virtual paths.

  import express from 'express';
  import { ssi } from '@ln-e/ssi-middleware';

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

  app.use(ssi({
    baseDir: `${__dirname}/public`,
    baseUrl: `http://localhost:${port}`,
    request: {
      // See https://npmjs.com/package/request for options.
      // This enables the use of self-signed certificates:
      strictSSL: false
    },
    payloadFn: (req, res) => {
      return { GEO: req.headers.COUNTY_BY_IP };
    }
  }));

  app.listen(port);

License

MIT

1.4.1

3 months ago

1.4.0

3 months ago

1.2.0

2 years ago

1.1.0

2 years ago

1.3.0

2 years ago

1.0.3

2 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago