@hatsy/serve-static
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Static Content Handler

NPM Build Status Code Quality Coverage GitHub Project API Documentation

serveStatic()

This module contains a serveStatic() factory of request handler able to serve static content.

It is based on send and can be configured with similar options.

import { httpListener } from '@hatsy/hatsy';
import { dispatchByName, Routing } from '@hatsy/router';
import { serveStatic } from '@hatsy/serve-static';
import { createServer } from 'http';

const server = createServer(
  httpListener(
    Routing.for(
      dispatchByName({
        assets: serveStatic('static_html/assets', { extensions: ['png', 'jpeg', 'gif'] }),
      }),
    ),
  ),
);

server.listen(8080);

Package Sidebar

Install

npm i @hatsy/serve-static

Weekly Downloads

2

Version

3.0.0

License

MIT

Unpacked Size

17.9 kB

Total Files

7

Last publish

Collaborators

  • lorus