项目作者: hatsyjs

项目描述 :
Hatsy request handler that serves static content
高级语言: TypeScript
项目地址: git://github.com/hatsyjs/serve-static.git
创建时间: 2020-11-27T06:39:59Z
项目社区:https://github.com/hatsyjs/serve-static

开源协议:MIT License

下载


Static Content Handler

@hatsy/serve-static"">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.

  1. import { httpListener } from '@hatsy/hatsy';
  2. import { dispatchByName, Routing } from '@hatsy/router';
  3. import { serveStatic } from '@hatsy/serve-static';
  4. import { createServer } from 'http';
  5. const server = createServer(
  6. httpListener(
  7. Routing.for(
  8. dispatchByName({
  9. assets: serveStatic('static_html/assets', { extensions: ['png', 'jpeg', 'gif'] }),
  10. }),
  11. ),
  12. ),
  13. );
  14. server.listen(8080);