Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

directory-index-html

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-index-html

Make an plain html page containing a directory listing

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32
decreased by-61.9%
Maintainers
1
Weekly downloads
 
Created
Source

directory-index-html

Make an plain html page containing a directory listing. Similar in look and feel to NGINX's listing page.

npm install directory-index-html

Usage

var toHTML = require('directory-index-html')

var entries = [{
  name: 'test',
  size: 24424,
  mtime: new Date()
}, {
  name: 'a-dir/',
  mtime: new Date()
}]

console.log(toHTML('/foo/bar', entries))

API

var html = toHTML(dir, entries)

Render a directory name and listing to an plain HTML string.

dir should be a string containing the directory name.

entries should be an array of entries that are similar to this

{
  name: 'name-of-file-or-dir',
  size: 42424, // size in bytes
  mtime: new Date() // when was this modified
}

To figure out if an entry is a directory the module will one of the following things:

  • Check if the path ends with a /
  • See if entry.type === 'directory'
  • See if entry.mode specifies a directory

Demo

There is a small demo server bundled in the repo that serves a directory listing of your current working directory.

To try it out, run node demo.js and visit http://localhost:8080.

It should show something like this:

demo.png

License

MIT

FAQs

Package last updated on 27 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc