A dead simple, zero-dependency static file server for Node.js.
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);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");