Sending whole folder content to client with express
<p>I made an html5 game (using GameMaker), which is constituted of an index.html and a folder "html5game" that contains the dependencies of the game - the javascript code and the resources. The problem is the resources are quite numerous and diverse (sounds, sprites, etc.) and The client needs them all to play.</p>

<p>I am looking for a way to send them all without naming them specifically.</p>

<p>I tried the glob module :</p>

<pre><code>var glob = require( 'glob' );    

var files = glob.sync( './html5game/**' ).forEach( function( file ) {
      require( path.resolve( file ) );
});
</code></pre>

<p>but I can't figure a way to send the files using res.sendFile() once I did that.</p>

<p>I tried</p>

<pre><code>var express = require('express');
var app = express();   

[...]

app.get('/aeronavale/jeu', function(req, res){
        res.sendFile(__dirname + '/aeronavale/index.html');
        res.sendFile(files)

});

[...]

app.listen(3000, function(){
    console.log('app started on port 3000, yeah !')
})
</code></pre>

<p>but it gives me the error :</p>

<pre><code>TypeError: path argument is required to res.sendFile
</code></pre>

<p>If you have an other solution, I a also interested. Thanks for your answers !</p>