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

superstatic

Package Overview
Dependencies
Maintainers
4
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superstatic

A static file server for fancy apps

  • 7.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
390K
decreased by-11.8%
Maintainers
4
Weekly downloads
 
Created

What is superstatic?

Superstatic is a static file server that supports modern web development features such as clean URLs, custom headers, and redirects. It is often used for serving static websites and single-page applications (SPAs) with ease.

What are superstatic's main functionalities?

Serving Static Files

This feature allows you to serve static files from a specified directory. In this example, the server serves files from the './public' directory on port 3474.

const superstatic = require('superstatic');
const connect = require('connect');

const app = connect().use(superstatic({
  root: './public'
}));

app.listen(3474, () => {
  console.log('Server running on port 3474');
});

Clean URLs

This feature enables clean URLs, which means you can serve files without the '.html' extension. For example, 'example.com/about' will serve 'about.html'.

const superstatic = require('superstatic');
const connect = require('connect');

const app = connect().use(superstatic({
  root: './public',
  cleanUrls: true
}));

app.listen(3474, () => {
  console.log('Server running on port 3474');
});

Custom Headers

This feature allows you to set custom headers for your files. In this example, all HTML files will have a 'Cache-Control' header set to 'no-cache'.

const superstatic = require('superstatic');
const connect = require('connect');

const app = connect().use(superstatic({
  root: './public',
  headers: [{
    source: '**/*.html',
    headers: [{
      key: 'Cache-Control',
      value: 'no-cache'
    }]
  }]
}));

app.listen(3474, () => {
  console.log('Server running on port 3474');
});

Redirects

This feature allows you to set up redirects. In this example, requests to '/old-page' will be redirected to '/new-page' with a 301 status code.

const superstatic = require('superstatic');
const connect = require('connect');

const app = connect().use(superstatic({
  root: './public',
  redirects: [{
    source: '/old-page',
    destination: '/new-page',
    type: 301
  }]
}));

app.listen(3474, () => {
  console.log('Server running on port 3474');
});

Other packages similar to superstatic

Keywords

FAQs

Package last updated on 25 Sep 2020

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