node.js - Node/Express, How do I modify static files but still have access to req.params? -


i'm new node/express, there's (hopefully) obvious answer i'm missing.

there's middleware transforming static content: https://www.npmjs.com/package/connect-static-transform/. transformation function looks like:

transform: function (path, text, send) {    send(text.touppercase(), {'content-type': 'text/plain'}); } 

so, that's great transforming content before serving, doesn't let me @ query parameters.

this answer shows how connect or express middleware modify response.body:

function modify(req, res, next){    res.body = res.body + "modified";    next(); } 

but can't figure out how run static file content. when run res.body undefined.

is there way middleware run after express.static?

my use case want serve files disk making small substitution of text based on value of query parameter. easy server-side templating, flask. want user able simple npm-install , start tiny server this. since i'm new node , express, wanted save myself bother of reading url, locating file on disk , reading it. it's becoming clear wasted more time trying approach.

the answer appears "there no answer." (as suggested pomax in comment.) annoying. didn't take me long figure out how serve , transform files myself, i'm having figure out error handling. million people have written code.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -