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

st

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

st

A module for serving static files. Does etags, caching, etc.

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
146K
increased by0.5%
Maintainers
1
Weekly downloads
 
Created

What is st?

The 'st' npm package is a simple and efficient static file server middleware for Node.js. It is designed to serve static files and resources with minimal configuration and overhead.

What are st's main functionalities?

Serve Static Files

This feature allows you to serve static files from a specified directory. In this example, files from the 'public' directory are served under the '/static' URL path.

const http = require('http');
const st = require('st');

const mount = st({
  path: __dirname + '/public',
  url: '/static'
});

http.createServer((req, res) => {
  if (mount(req, res)) return;
  res.end('Hello World');
}).listen(8080);

Cache Control

This feature allows you to configure caching for file descriptors, file stats, and file content. This can help improve performance by reducing the need to repeatedly access the filesystem.

const st = require('st');

const mount = st({
  path: __dirname + '/public',
  url: '/static',
  cache: {
    fd: {
      max: 1000,
      maxAge: 1000 * 60 * 60
    },
    stat: {
      max: 5000,
      maxAge: 1000 * 60
    },
    content: {
      max: 1024 * 1024 * 64,
      maxAge: 1000 * 60 * 10
    }
  }
});

Custom Index Files

This feature allows you to specify a custom index file to be served when a directory is requested. In this example, 'custom-index.html' will be served instead of the default 'index.html'.

const st = require('st');

const mount = st({
  path: __dirname + '/public',
  url: '/static',
  index: 'custom-index.html'
});

Other packages similar to st

Keywords

FAQs

Package last updated on 04 Feb 2014

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