Expose github README.md at a path using express middleware

By , Sunday 24th March 2013 10:33 pm

I’ve just published the first version of a new middleware package I’ve written to expose your project’s README.md via express.

To install simply run:

npm i --save express-middleware-readme.md

At its very simplest level the module will expose your project’s README.md at the route /readme.html.  To do this simply do the following in your express configuration:


The usefulness of this code can be expanded by setting one or a number of several options. Options can be updated as follows:


Firstly you can change which file is parsed for presentation to the user by passing the key ‘filename‘ with the name of a file relative to the project root. By default this is set as ‘./README.md’.

You can also change the end point at which the file is exposed by setting the ‘endpoint‘ key. This can be a simple string e.g. ‘/readme.html’ or an array of required endpoints, e.g. ( [ ‘/readme.html’, ‘/readme.md’ ] ).

Next you can decorate the content with standard HTML scaffolding  (doctype, html, head, body) by setting the ‘htmlWrap‘ key as an empty object.

The HTML wrap can be extended by providing keys of….

  • scripts‘: string or array of URLs for javaScript files to be included
  • styles‘: string or array of URLs for CSS files to be included
  • title‘: A title tag to include
  • meta‘:  Add meta tags. Provide objects with keys … as required
    • content
    • value
    • http-equiv
    • charset

Check it out out on the NPM website: https://npmjs.org/package/express-middleware-readme.md

The code is available on github here: https://github.com/lloydwatkin/express-middleware-readme.md

It can also be seen in action on the xmpp-ftw website using the following options:

var readme = require('express-middleware-readme.md')
    htmlWrap: {
        meta: [
            { charset: 'utf-8' }
        title: 'Project Github README.md'

Liked this post? Follow this blog to get more. 

Leave a Reply

You must be logged in to post a comment.

Panorama Theme by Themocracy

3 visitors online now
2 guests, 1 bots, 0 members
Max visitors today: 6 at 06:58 am UTC
This month: 11 at 16-04-2017 11:37 pm UTC
This year: 45 at 02-01-2017 10:28 pm UTC
All time: 130 at 28-03-2011 10:40 pm UTC