Socket
Socket
Sign inDemoInstall

ecstatic

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecstatic

A simple static file server middleware that works with both Express and Flatiron


Version published
Weekly downloads
142K
decreased by-51.8%
Maintainers
2
Weekly downloads
 
Created

What is ecstatic?

The 'ecstatic' npm package is a simple static file server middleware for Node.js. It allows you to serve static files with ease, making it useful for development and simple web servers.

What are ecstatic's main functionalities?

Basic Static File Serving

This feature allows you to serve static files from a specified directory. In this example, files from the 'public' directory will be served on port 8080.

const http = require('http');
const ecstatic = require('ecstatic');
const server = http.createServer(
  ecstatic({ root: __dirname + '/public' })
);
server.listen(8080);

Custom Error Pages

This feature allows you to handle errors and serve custom error pages. In this example, a custom 404 error page is served when a file is not found.

const http = require('http');
const ecstatic = require('ecstatic');
const server = http.createServer(
  ecstatic({ root: __dirname + '/public', handleError: false })
);
server.on('request', (req, res) => {
  res.on('error', (err) => {
    res.writeHead(404, { 'Content-Type': 'text/html' });
    res.end('<h1>Custom 404 Page</h1>');
  });
});
server.listen(8080);

Cache Control

This feature allows you to set cache control headers for the served files. In this example, the cache is set to expire in 3600 seconds (1 hour).

const http = require('http');
const ecstatic = require('ecstatic');
const server = http.createServer(
  ecstatic({ root: __dirname + '/public', cache: 'max-age=3600' })
);
server.listen(8080);

Other packages similar to ecstatic

Keywords

FAQs

Package last updated on 15 Nov 2015

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc