This package has been deprecated

Author message:

use @chubbyts/chubbyts-http-static-file

@chubbyts/chubbyts-static-file

2.0.1 • Public • Published

chubbyts-static-file

CI Coverage Status Infection MSI npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A minimal static file handler for chubbyts-http-types.

Requirements

Installation

Through NPM as @chubbyts/chubbyts-static-file.

npm i @chubbyts/chubbyts-static-file@^2.0.1

Usage

import { createStaticFileHandler } from '@chubbyts/chubbyts-static-file/dist/handler';
import type { ResponseFactory, StreamFromFileFactory } from '@chubbyts/chubbyts-http-types/dist/message-factory';
import { createGetRoute } from '@chubbyts/chubbyts-framework/dist/router/route';

const responseFactory: ResponseFactory = ...;
const streamFromFileFactory: StreamFromFileFactory = ...;

const handler = createStaticFileHandler(
  responseFactory,
  streamFromFileFactory,
  '/path/to/public/directory',
  (await import('../src/mimetypes')).default, // typescript / ecmascript module
  // require('../src/mimetypes').default, // commonjs (cjs)
);

// for example as a fallback route matching everything
const route = createGetRoute({
  path: '/(.*)',
  name: 'static_file',
  handler,
});

Copyright

2023 Dominik Zogg

Package Sidebar

Install

npm i @chubbyts/chubbyts-static-file

Weekly Downloads

1

Version

2.0.1

License

MIT

Unpacked Size

93.7 kB

Total Files

9

Last publish

Collaborators

  • dominikzogg