1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-02 16:08:31 +00:00

Initial commit for modular FrankerFaceZ rewrite.

This commit is contained in:
SirStendec 2015-01-12 17:58:07 -05:00
parent b74fdaa22b
commit f1377bc989
27 changed files with 2717 additions and 1034 deletions

39
test/server.js Normal file
View file

@ -0,0 +1,39 @@
var fs = require("fs"),
http = require("http"),
path = require("path"),
request = require("request"),
url = require("url");
http.createServer(function(req, res) {
var uri = url.parse(req.url).pathname,
lpath = path.join(uri).split(path.sep);
if ( ! lpath[0] )
lpath.shift();
if ( lpath[0] == "script" )
lpath.shift();
else
lpath.splice(0, 0, "cdn");
var file = path.join(process.cwd(), lpath.join(path.sep));
fs.exists(file, function(exists) {
if ( ! exists ) {
console.log("[CDN] GET " + uri);
return request.get("http://cdn.frankerfacez.com/" + uri).pipe(res);
}
if ( fs.lstatSync(file).isDirectory() ) {
console.log("[403] GET " + uri);
res.writeHead(403);
res.write('403 Forbidden');
return res.end();
}
console.log("[200] GET " + uri);
res.writeHead(200, {"Access-Control-Allow-Origin": "*"});
fs.createReadStream(file).pipe(res);
});
}).listen(8000);