2
0
Fork 0
node-ff-assets/lib/asset-assembler-config.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-02-27 00:25:57 +00:00
'use strict';
var name = 'node-ff-assets';
var downloadTimeout = (1000*10) * 6; // 1min
var downloadMaxSize = (1024*1024) * 10; // 10mb
var template = {
downloadStartDelay: null,
downloadForce: false,
downloadOptions: {
timeout: downloadTimeout,
maxResponseLength: downloadMaxSize,
agent: name+' remote fetcher',
},
linkTargetSingleResult: true,
linkTarget: null,
linkSources: [],
linkMapping: [],
assetType: null,
assetHeader: '\n/* '+name+': begin */\n\n',
assetFooter: '\n/* '+name+': end */\n\n',
assetSeperator: '\n/* '+name+': next */\n',
};
function checkConfig(config,callback) {
if (!config) {
callback(new Error('no config'));
}
if (!config.linkTarget) {
callback(new Error('no config.linkTarget'));
}
if (!config.linkSources) {
callback(new Error('no config.linkSources'));
}
if (!config.linkMapping) {
callback(new Error('no config.linkMapping'));
}
callback();
}
function fillDefaults(config,callback) {
if (config.downloadOptions === undefined) {
config.downloadOptions = template.downloadOptions;
}
if (config.assetHeader === undefined) {
config.assetHeader = template.assetHeader;
}
if (config.assetFooter === undefined) {
config.assetFooter = template.assetFooter;
}
if (config.assetSeperator === undefined) {
config.assetSeperator = template.assetSeperator;
}
callback(null,config);
}
module.exports = {
template: template,
checkConfig: checkConfig,
fillDefaults: fillDefaults,
};