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

serve-directory

v5.0.0

Published

Serve directory listings

Downloads

404

Readme

serve-directory

Build Status devDependencies Coveralls github LGTM Grade Issues Issues GitHub last commit GitHub Release Date

npm npm dependencies Snyk Vulnerabilities for npm package version install size

styled with prettier MIT license

Serves pages that contain directory listings for a given path. forked from expressjs/serve-directory

Installation

yarn add serve-directory

Usage

import serveDirectory from 'serve-directory'

const directory = serveDirectory('wwwroot', options)

Serve directory indexes with vanilla node.js http server

see example.js

serveDirectory(path, options)

Returns middleware that serves an index of the directory in the given path.

The path is based off the req.url value, so a req.url of '/some/dir with a path of 'public' will look at 'public/some/dir'. If you are using something like express, you can change the URL "base" with app.use (see the express example).

options(Object)

serveDirectory accepts these properties in the options object.

example

defaults

{
  imports: {},
  hidden: false,
  relative: true,
  process: [
    {
      accept: 'text/html',
      render: 'lib/directory.jst'
    },
    {
      accept: 'text/plain',
      render: ({fileNames}) => fileNames.join(EOL) + EOL,
    },
    {
      accept: 'application/json',
      render: ({fileNames}) => JSON.stringify(fileNames),
    },
  ]
}

options.imports(Object)

An object to import into the template as free variables., see lodash.template

by default some useful functions will import automatically

see utils/index.js

options.hidden(Boolean)

Show hidden files(file/folder start with .) , defaults to false.

options.relative(Object)

Use relative url , default true.

options.process(Array)

Array list how data should be handled

options.accept

Array or String split with ,

space will be trim

options.render

by default we use a compiled lodash.template function to render data

see lodash.template

  • String

    a path to a template file a template string

  • Function

    a custom render function

  • falsy value

    remove default render function

data

data pass to the render function

  • path String

    physical path

  • pathname String

    decoded request pathname

  • url URL

    request URL object

  • method String

    request method

  • responseType String

    response mine-type / content-type

  • directory fs.Stats

    directory stats with additional info path pathname url

  • files Array<fs.Stats>

    directory files stats with additional info name ext type url

  • fileNames Array<String>

    directory files but name only

License

MIT © fisker Cheung