<commit_before>/***
 * Copyright (c) 2015 <NAME> (@localnerve), LocalNerve LLC
 * Copyrights licensed under the BSD License. See the accompanying LICENSE file for terms.
 *
 * Entry point for the service worker.
 * The precache and data modules are generated by the build.
 */
/* global Request */
'use strict';

// For now, this only works in dev builds, sw-toolbox issue #31
var toolbox = require('sw-toolbox');
var data = require('./data');

toolbox.options.cacheName = data.cacheId + '-' + toolbox.options.cacheName;
toolbox.options.debug = data.debug;

// Setup non-project static asset precaching (cdn requests)
toolbox.precache(data.assets.map(function (asset) {
  return new Request(asset, {
    mode: 'no-cors'
  });
}));

// Setup message handling
require('./messages');

// Setup the in-project static asset precaching
require('./precache');

// TODO:
// Review this, it looks like the api reqs maybe changing depending on order.
// Handle the api gets
data.api_gets.forEach(function (path) {
  toolbox.router.get(path+'*', toolbox.networkFirst, { debug: data.debug });
});

// TODO:
// Handle the post request?
// Use background sync to handle when available.<commit_msg>add credentials to api request<commit_after>/***
 * Copyright (c) 2015 <NAME> (@localnerve), LocalNerve LLC
 * Copyrights licensed under the BSD License. See the accompanying LICENSE file for terms.
 *
 * Entry point for the service worker.
 * The precache and data modules are generated by the build.
 */
/* global Request */
'use strict';

// For now, this only works in dev builds, sw-toolbox issue #31
var toolbox = require('sw-toolbox');
var data = require('./data');

toolbox.options.cacheName = data.cacheId + '-' + toolbox.options.cacheName;
toolbox.options.debug = data.debug;

// Setup non-project static asset precaching (cdn requests)
toolbox.precache(data.assets.map(function (asset) {
  return new Request(asset, {
    mode: 'no-cors'
  });
}));

// Handle the api gets
// Broken: sw-toolbox issue #35
data.api_gets.forEach(function (path) {
  toolbox.router.get(path+'*', function (request, values, options) {
    var req = new Request(request, {
      credentials: 'include'
    });
    return toolbox.networkFirst(req, values, options);
  }, { debug: data.debug });
});

// Setup message handling
require('./messages');

// Setup the in-project static asset precaching
require('./precache');

// TODO:
// Handle the post request?
// Use background sync to handle when available.
{'fraction_non_alphanumeric': 0.1368038740920097, 'fraction_numerical': 0.005649717514124294, 'mean_word_length': 3.899209486166008, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1521664', 'n_tokens_mistral': 733, 'n_tokens_neox': 722, 'n_words': 254}