init
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.vscode/
|
||||||
|
node_modules/
|
||||||
23
package.json
Normal file
23
package.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "redirect.tparnell.io",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "node server.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/tparnell8/redirect.tparnell.io.git"
|
||||||
|
},
|
||||||
|
"author": "Tommy Parnell",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/tparnell8/redirect.tparnell.io/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.13.3",
|
||||||
|
"string": "^3.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
26
server.js
Normal file
26
server.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var S = require('string');
|
||||||
|
var app = express();
|
||||||
|
|
||||||
|
|
||||||
|
app.get('/*', function (req, res) {
|
||||||
|
var host = S(req.headers.host);
|
||||||
|
|
||||||
|
if(host.contains('github')){
|
||||||
|
return res.redirect(301, 'https://github.com/tparnell8');
|
||||||
|
}
|
||||||
|
if(host.contains('blog')){
|
||||||
|
return res.redirect(301,'http://blog.tparnell.io');
|
||||||
|
}
|
||||||
|
if(host.contains('resume')){
|
||||||
|
return res.redirect(301,'http://resume.tparnell.io');
|
||||||
|
}
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
var server = app.listen(3000, function () {
|
||||||
|
var host = server.address().address;
|
||||||
|
var port = server.address().port;
|
||||||
|
|
||||||
|
console.log('Example app listening at http://%s:%s', host, port);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user