Inject content into your server responses
There are times when all you want to do is inject a JS file or custom markup into the req res cycle without forcing the content generator to include custom markup on their side.
This is where infestor comes in. Just specify the regex insertion point and content. Then you are good to go.
npm install infestor --save
var http = require('http');
connect = require('connect'),
infestor = require('infestor'),
serveStatic = require('serve-static');
var app = connect()
.use(infestor({
content: "<h2> injected content! </h2>",
injectAt: '/<\/html>/'
})
.use(serveStatic(__dirname));
var server = http.createServer(app).listen(1111)Make sure that you place the infestor middleware before you serve your content or else infestor will not work.
- Details on the license can be found here
- Details on running tests and contributing can be found here
