<commit_before>/* jshint node: true */
var browserify = require('browserify-middleware');

module.exports = function(snap, server) {

  var expressApp = server.expressApp;

  // Serve Supervisor bootstraping script
  expressApp.get(
    '/scripts/supervisor.js',
    browserify('../../client/bootstrap/supervisor.js')
  );

  var scriptsHandler = browserify(
    snap.plugins.getClientScripts()
  );

  // Serve plugins scripts
  expressApp.get(
    '/scripts/plugins.js',
    function handlePlugins(req, res, next) {
      var clientScripts = snap.plugins.getClientScripts();
      var hasScripts =  clientScripts.length > 0;
      if(hasScripts) {
        return scriptsHandler(req, res, next);
      } else {
        return res.send(204);
      }
    }
  );

  // Serve plugin scripts bootstrap
  expressApp.get(
    '/scripts/bootstrap.js',
    snap.plugins.handlePluginsBootstrap
  );

    // Serve Snap application client
  expressApp.get(
    '/apps/:appName/snap.js',
    browserify('../../client/bootstrap/snap.js')
  );

};<commit_msg>Fix client side injection<commit_after>/* jshint node: true */
var browserify = require('browserify-middleware');

module.exports = function(snap, server) {

  var expressApp = server.expressApp;

  // Serve Supervisor bootstraping script
  expressApp.get(
    '/scripts/supervisor.js',
    browserify('../../client/bootstrap/supervisor.js')
  );

  // Serve plugins scripts
  expressApp.get(
    '/scripts/plugins.js',
    function handlePlugins(req, res, next) {
      var clientScripts = snap.plugins.getClientScripts();
      var hasScripts =  clientScripts.length > 0;
      if(hasScripts) {
        var scriptsHandler = browserify(
          snap.plugins.getClientScripts()
        );
        return scriptsHandler(req, res, next);
      } else {
        return res.send(204);
      }
    }
  );

  // Serve plugin scripts bootstrap
  expressApp.get(
    '/scripts/bootstrap.js',
    snap.plugins.handlePluginsBootstrap
  );

    // Serve Snap application client
  expressApp.get(
    '/apps/:appName/snap.js',
    browserify('../../client/bootstrap/snap.js')
  );

};
{'fraction_non_alphanumeric': 0.13496932515337423, 'fraction_numerical': 0.0037753657385559227, 'mean_word_length': 2.7924865831842576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1656381', 'n_tokens_mistral': 665, 'n_tokens_neox': 635, 'n_words': 127}