Default node HTTP server config values
All of these can be modified and passed into new server.Server(myConfigs)
or server.deploy(myConfigs)
const myConfig=new server.Config;
myConfig.verbose=true;
myConfig.port=9922;
const myServer=new server.Server(config);
myServer.deploy();
server.deploy({port:9922,verbose:true});
Detailed default config docs and explination
const defaultConfigs={
verbose : (args.verbose=='true')||false,
port : args.port||defaults.port,
root : args.root||defaults.root,
domain : args.domain||defaults.domain,
log : false,
logFunction : serverLogging,
domains : {
},
server : {
index : args.index||defaults.index,
noCache : args.noCache=='false' ? false : true,
timeout : 30000
},
https:{
ca:'',
privateKey:'',
certificate:'',
passphrase:false,
port:443,
only:false
},
contentType : {
html : 'text/html',
css : 'text/css',
js : 'text/javascript',
json : 'application/json',
txt : 'text/plain',
jpeg : 'image/jpeg',
jpg : 'image/jpeg',
png : 'image/png',
gif : 'image/gif',
ico : 'image/x-icon',
appcache: 'text/cache-manifest'
},
restrictedType: {
},
errors:{
headers : {
'Content-Type' : 'text/plain'
},
404: '404 MIA',
415: '415 File type not supported',
403: '403 Access Denied',
500: '500 {{err}}'
}
};
function serverLogging(data){
fs.exists(
this.log,
function serverLogExsits(exists){
data.timestamp=new Date().getTime();
const JSONData=JSON.stringify(data);
let method='appendFile';
if(!exists){
method='writeFile';
}
fs[method](
this.log,
JSONData,
function fsMethod(err) {
if(err){
console.log(err);
}
}
);
}.bind(this)
);
}
module.exports=Config;