Skip to content
Browse files

abstracted into a package, added index.js which uses require assassin…

….js,

fixed for in loops bug
  • Loading branch information...
1 parent 60f87eb commit e1f603a41f27a451aba3484909428f71bcc4968e Adithya C committed Mar 7, 2013
Showing with 129 additions and 1,703 deletions.
  1. +17 −14 assassin.js
  2. +1 −5 fileserver/contenttypelist.js
  3. +12 −0 index.js
  4. +6 −6 system/config.js
  5. +93 −1,678 system/log.txt
View
31 assassin.js
@@ -1,9 +1,8 @@
-/* index.js
+/* assassin.js
***** Part of AssassinJS *****
- (c)2013 Adithya and Sai Teja under MIT (Open Source) License
- This is the file that needs to be run by node.
- It initializes the server to listen on Specified Port Number and Address.
+ This is the file that initializes the server to listen on Specified Port Number and Address.
The settings are taken from the configuration file.
All the actions are logged using the logger.
@@ -16,17 +15,21 @@ system['config'] = require('./system/config');
system['logger'] = require('./system/logger');
system['router'] = require('./system/router');
-var server = http.createServer();
-
-var config = system.config.getConfig();
-system.logger.write('config object='+JSON.stringify(config));
-server.on('request',system.router.route);
-
-if(config.port!=undefined && config.address!=undefined)
+function assassinate()
{
- server.listen(config.port,config.address);
- system.logger.write('Server running at '+config.address+':'+config.port);
+ var server = http.createServer();
+ var config = system.config.getConfig();
+ //system.logger.write('config object='+JSON.stringify(config));
+ server.on('request',system.router.route);
+
+ if(config.port!=undefined && config.address!=undefined)
+ {
+ server.listen(config.port,config.address);
+ system.logger.write('Server running at '+config.address+':'+config.port);
+ }
+ else
+ system.logger.write('Config Parameters not defined: port and address');
}
-else
- system.logger.write('Config Parameters not defined: port and address');
+
+exports.assassinate = assassinate;
View
6 fileserver/contenttypelist.js
@@ -15,14 +15,10 @@ fs.readFile('./fileserver/filetypelist.txt',function(err,data2){
for(row in listentries)
{
+ row = listentries[row];
filetypemap[row.split('\t')[0].split('.')[1]] = row.split('\t')[1];
}
- /*
- $.each(listentries,function(key,value){
- filetypemap[value.split('\t')[0].split('.')[1]] = value.split('\t')[1];
- });
- */
}
});
View
12 index.js
@@ -0,0 +1,12 @@
+/* index.js
+ ***** Part of AssassinJS *****
+ - (c)2013 Adithya and Sai Teja under MIT (Open Source) License
+
+ This is the file that needs to be run by node.
+
+*/
+
+var assassin = require('./assassin');
+
+//This function invokes assassin
+assassin.assassinate();
View
12 system/config.js
@@ -19,8 +19,9 @@ else
var listentries = data.toString().split('\n');
for(row in listentries)
- {
- var valuepair = row.split('\t');
+ {
+ var valuepair = listentries[row].split('\t');
+ //logger.write(listentries[row]+','+valuepair);
config[valuepair[0]] = valuepair[1];
}
@@ -41,22 +42,21 @@ else
for(row in listentries)
{
- var values = row.split('\t');
+ var values = listentries[row].split('\t');
var routeObj={};
routeObj.path=values[1];
routeObj.method=values[0];
routeObj.target=values[2];
if(routes[routeObj.path]===undefined && routeObj.path!=undefined) routes[routeObj.path]={};
if(routes[routeObj.path]!=undefined)routes[routeObj.path][routeObj.method] = routeObj.target;
- logger.write('routeObj = '+JSON.stringify(routeObj)+' and routes= '+JSON.stringify(routes));
+ //logger.write('routeObj = '+JSON.stringify(routeObj)+' and routes= '+JSON.stringify(routes));
}
}
-
function getConfig()
{
- logger.write('returning config');
+ logger.write('returning config = '+JSON.stringify(config));
return config;
}
View
1,771 system/log.txt
93 additions, 1,678 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit e1f603a

Please sign in to comment.
Something went wrong with that request. Please try again.