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

ecstatic

Package Overview
Dependencies
Maintainers
1
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

  • 0.4.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
241K
decreased by-57.34%
Maintainers
1
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 17 Aug 2013

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