forEach callback is synchronous

Code is less error prone if counters are not used. Counter should
only be needed if callback is asynchronous. When asynchronous you
should use the extra parameters of the forEach callback rather than
a counter: i.e.
[1,2,3].forEach(function(e,i,a) {
 console.log(e);
 if(i === a.length-1) {console.log('done');}
});
Use regexp for repeated substitutions
Don't open file with write permission
readFile is already relative to current directory

Use path.join(path1, path2) for joining paths
Never ignore errors.

Throw or handle
Remove temporary variable.

Don't bother buffering in javascript, needlessly slows down transmission.
Escape SQL parameters
Don't ignore errors.
Wait for listening callback
Terminate variably assigned functions
Don't ignore database errors
Javascript bind magic
Extract index method
Extract render method
Use scoped function

Simplifies invocation.
Maintains 'err' as first parameter convention.
Named functions and common render method

Assists debugging, simplifies rendering files
Refactor to use callback convention
Extract to module, fix bugs

* Files are loaded as buffers, need toString to perform replace
* '.replace' method is not in place, fixed with self assigning
Extract render to module, remove default on readFile
Use reduce for template