expressjs / serve-static

Serve static files
MIT License
1.39k stars 228 forks source link

Enable use with memory-fs #83

Open gajus opened 7 years ago

gajus commented 7 years ago

I am producing all the files and storing them only in memory, i.e. https://github.com/webpack/memory-fs. I'd like there to be an option to tell serve-static which fs to use.

dougwilson commented 7 years ago

Does that module actually implement enough of the features to work here? I didn't look at it immediately but I remember at least one previous issue about this. Of course, please feel so inclined to make a PR in which you think the ideal implementation should be. This module does not require(fs) anywhere, so the change here is not obvious to me.

gajus commented 7 years ago

This module does not require(fs) anywhere, so the change here is not obvious to me.

serve-static is using send to read-stream files.

https://github.com/expressjs/serve-static/blob/f75f96908b3b4add99352a59af13560859a1b10a/index.js#L96

Bummer. This would require modification of send as well as serve-static.

I see that send is using only stat and createReadStream. memory-fs implements these methods.

Supporting this feature would require send to introduce a factory abstraction.

This is too low of a priority for me to champion such change. I will rather simply write to the disk and continue using serve-static.

Lets leave this open and see if more people require this feature. I am sensing it might be an edge use case.

acupofspirt commented 6 years ago

I have the same issue. Is there any way to provide fs module?

hinell commented 5 years ago

Highly related #pillarjs/send/issues/160