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

@xcodebuild/static-server

v2.2.1

Published

A simple http server to serve static resource files from a local directory.

Downloads

3

Readme

Build Status

Node static server

A simple http server to serve static resource files from a local directory.

Getting started

  • Install node.js
  • Install npm package globally npm -g install static-server
  • Go to the folder you want to serve
  • Run the server static-server

Options

-h, --help                 output usage information
-V, --version              output the version number
-p, --port <n>             the port to listen to for incoming HTTP connections
-i, --index <filename>     the default index file if not specified
-f, --follow-symlink       follow links, otherwise fail with file not found
-d, --debug                enable to show error messages
-n, --not-found <filename> the error 404 file
-c, --cors <pattern>       Cross Origin Pattern. Use "*" to allow all origins
-z, --no-cache           disable cache (http 304) responses.
-o, --open                 open server in the local browser

Using as a node module

The server may be used as a dependency HTTP server.

Example

var StaticServer = require('static-server');
var server = new StaticServer({
  rootPath: '.',            // required, the root of the server file tree
  port: 1337,               // required, the port to listen
  name: 'my-http-server',   // optional, will set "X-Powered-by" HTTP header
  host: '10.0.0.100',       // optional, defaults to any interface
  cors: '*',                // optional, defaults to undefined
  followSymlink: true,      // optional, defaults to a 404 error
  templates: {
    index: 'foo.html',      // optional, defaults to 'index.html'
    notFound: '404.html'    // optional, defaults to undefined
  }
});

server.start(function () {
  console.log('Server listening to', server.port);
});

server.on('request', function (req, res) {
  // req.path is the URL resource (file name) from server.rootPath
  // req.elapsedTime returns a string of the request's elapsed time
});

server.on('symbolicLink', function (link, file) {
  // link is the source of the reference
  // file is the link reference
  console.log('File', link, 'is a link to', file);
});

server.on('response', function (req, res, err, file, stat) {
  // res.status is the response status sent to the client
  // res.headers are the headers sent
  // err is any error message thrown
  // file the file being served (may be null)
  // stat the stat of the file being served (is null if file is null)

  // NOTE: the response has already been sent at this point
});

FAQ

  • Can I use this project in production environments? Obviously not.
  • Can this server run php, ruby, python or any other cgi script? No.
  • Is this server ready to receive thousands of requests? Preferably not.

Contributors

An special thank you to all contributors who allow this project to continue to evolve.

License

The MIT License (MIT)