Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

geoffb/mousepox-static-server

Repository files navigation

@mousepox/static-server

A dead simple, zero-dependency static file server for Node.js.

Actions Status

Quick Start

import { StaticServer } from "@mousepox/static-server";

// Create server from a path to static resources
const server = new StaticServer("path/to/static/resources");

// Start listening
server.listen(8081);

MIME Types

Content types are inferred from file extensions. By default, common extensions are mapped to their appropriate MIME types. For example, .js => text/javascript.

However, custom mappings can be set using the setMIMEType method:

server.setMIMEType(".xml", "application/xml");