0.5.25 • Published 6 months ago

@wooksjs/http-static v0.5.25

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Wooks Serve File

!!! This is work-in-progress library, breaking changes are expected !!!

Wooks Serve File is composable static file server for @wooksjs/event-http.

serveFile returns a readable stream and prepares all the neccessary response headers (like content-length, content-type etc).

  • ✅ returns a readable stream
  • ✅ prepares all the neccessary response headers (like content-length, content-type etc)
  • ✅ can handle etag
  • ✅ can handle ranges

Installation

npm install @wooksjs/http-static

Usage

import { serveFile } from '@wooksjs/http-static'
// ...
serveFile(filePath, options)

serveFile options

{
    // Any header to add
    headers?: Record<string, string>,

    // Cache-Control header
    cacheControl?: TCacheControl,

    // Expires header
    expires?: Date | string | number,

    // when true a header "Pragma: no-cache" will be added
    pragmaNoCache?: boolean,

    // the base directory path
    baseDir?: string,

    // default extension will be added to the filePath
    defaultExt?: string,

    // when true lists files in directory
    listDirectory?: boolean,

    // put 'index.html'
    // to automatically serve it from the folder
    index?: string,
}

Built-in file server example:

import { useRouteParams } from 'wooks'
import { serveFile } from '@wooksjs/http-static'
app.get('static/*', () => {
  const { get } = useRouteParams()
  return serveFile(get('*'), { cacheControl: { maxAge: '10m' } })
})

cacheControl here is the same object as used in useSetCacheControl().setCacheControl({ ... }) from @wooksjs/composables

Documentation

To check out docs, visit wooks.moost.org.

0.5.25

6 months ago

0.5.20

7 months ago

0.5.18

7 months ago

0.5.19

7 months ago

0.5.17

7 months ago

0.5.16

8 months ago

0.5.15

8 months ago

0.5.14

8 months ago

0.5.13

1 year ago

0.5.10

1 year ago

0.5.11

1 year ago

0.5.12

1 year ago

0.4.37

1 year ago

0.4.36

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.6

1 year ago

0.5.5

1 year ago

0.5.0

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.8

1 year ago

0.5.7

1 year ago

0.5.9

1 year ago

0.4.35

1 year ago

0.4.33

1 year ago

0.4.34

1 year ago

0.4.31

1 year ago

0.4.32

1 year ago

0.4.30

1 year ago

0.4.28

1 year ago

0.4.29

1 year ago

0.4.27

1 year ago

0.4.26

2 years ago

0.4.24

2 years ago

0.4.23

2 years ago

0.4.22

2 years ago

0.4.20

2 years ago

0.4.21

2 years ago

0.4.18

2 years ago

0.4.17

2 years ago

0.4.15

2 years ago

0.4.16

2 years ago

0.4.14

2 years ago

0.4.13

2 years ago

0.4.12

2 years ago

0.4.10

2 years ago

0.4.11

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.9

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.21

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.3.0

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.1.0

3 years ago