-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathversionator.express.txt
32 lines (27 loc) · 1.91 KB
/
versionator.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
┏━━━━━━━━━━━━━━━━━┓
┃ VERSIONATOR ┃
┗━━━━━━━━━━━━━━━━━┛
VERSION ==> #0.5.0
#Static assets timestamping (unconditional caching)
# - versionPath() adds timestamp to URLs (in output) and stips it (in input)
# - e.g. in RES.locals for RES.render()
# - client will use unconditional caching (browser cache) providing timestamp is same as before
#Timestamp can be either global version ID or file content hash
VERSIONATOR.create('VERSION') #VERSION should be global and recreated at each version bump.
->VERSION #'VERSION' can be read from package.json
VERSION.middleware #Express MIDWR that strips (if present) "/VERSION/" from REQ.url
#Should be first MIDWR
VERSION.versionPath #Adds "/VERSION/" as last DIR of URL[_ARR]
('URL'[_ARR])->'URL'[_ARR] #URL should not be absolute.
VERSIONATOR.createMapFromPath
('DIR', [OBJ, ] #MAPPEDVERSION is same as VERSION but
FUNC(ERROR, FILEMAP)) # - uses "/FILE_MD5HASH/" timestamp for each file
VERSIONATOR.createMapped # - i.e. file-based (not global) unconditional caching
(FILEMAP)->MAPPEDVERSION # - 'URL' should be relative to DIR, and start with '/'
MAPPEDVERSION.middleware # - should recreate MAPPEDVERSION on file change
MAPPEDVERSION.versionPath #OPTS:
('URL'[_ARR])->'URL'[_ARR] # - followLinks BOOL (def: true): follow symlinks
VERSIONATOR.createMapFromPath
('DIR', {fileList: 'URL'_ARR},
FUNC(ERROR, FILEMAP))
VERSIONATOR.modifyMap(FILEMAP)#Faster way to update MAPPEDVERSION (do not recalculcate hashes of all files)