-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathst.express.txt
76 lines (71 loc) · 4.81 KB
/
st.express.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
┏━━━━━━━━┓
┃ ST ┃
┗━━━━━━━━┛
ALTERNATIVES ==> #See serve-static
VERSION ==> #Node module (1.2.2)
#Serves static files.
ST(OBJ|PATH) #Express MIDWR
#PATH is same as { path: PATH }. OBJ:
# - path PATH: served PATH root
# - url PATH: requested PATH root (def: "/")
# - gzip BOOL (def: true):
# - gzip and serve with Content-Encoding: gzip, Transfer-Encoding: chunked
# - only if Accept-Encoding: gzip
# - passthrough BOOL: if true, when not found, calls NEXT(). If false (def), sends 404.
# - dot BOOL: if false (def), sends 403 for dotfiles.
# - index PATH|BOOL: when request directories:
# - if true (def), show directories listing
# If no trailing slash, redirect 301 to version with slash
# - if PATH, sends PATH (e.g. "index.html") if requested "/"
# - if false, sends 404
# - cors BOOL (def: false)
# - cache false|OBJ:
# - in any case:
# - sets ETag (inode + mtime), last-modified
# - respond with 304 if need be
# - cache-control is according to cache.content:
# - if false, no-cache
# - if cache.content.cacheControl STR, use this one
# - otherwise, public, max-age=cache.content.maxAge
# - OBJ:
# - KEY:
# - max NUM:
# - fd, stat, readdir: number of objects
# - content, index: number of bytes
# - maxAge NUM:
# - lifetime of objects, in ms
# - must be at least 1, so set KEY: { maxAge: 1 } to disallow cache
# - KEY can be:
# - fd: file descriptor, content linked to a specific path (def: 1000, 1h)
# - stat: files metainfos (FS.stat()), used for etags, Last-Modified, isDirectory
# (for index) (def: 5000, 1 min.)
# - content: content linked to a specific size and ETag (def: 64MB, 10 min.)
# - index: index page for a specific path (with index true) (def: 8KB, 10 min.)
# - readdir: with index true, listing of directories for a specific path
# (def: 1000, 10 min.)
# - rational:
# - fd, stat, index, readdir:
# - will all keep a specific version of a file for a given path in memory even if
# it changed
# - fd|stat: should put as high as possible, then using timestamps
# - index|readdir: cannot use timestamps
# - differences between each is only about how much memory to invest
# - content:
# - if file changed, ETag will too, so does not affect caching server-side
# - but can set cache-control header for client
# - best is to put as high as possible, then use cache.content.cacheControl STR
st #Command line launching a simple Express server with ST MIDWR
-d DIR #PATH (def: $PWD)
-u
--url PATH #
-H HOST
--host HOST #
-l
--localhost #Same as -H localhost
-p PORT #Def: 1337
--index PATH|BOOL #
--dot BOOL #
--no-cache #Do cache: false
--age NUM #Do cache: KEY: maxAge: NUM for all KEY
-co
--cors #