-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (51 loc) · 4.35 KB
/
Copy pathindex.js
File metadata and controls
57 lines (51 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const cool = require('cool-ascii-faces')
const funky_intro = require('funny-words')
const express = require('express')
const emoji = require('emoji-cool');
const app = express();
app.engine('html', require('ejs').renderFile); app.set('view engine', 'html');
app.get('/', function(req, res) {
res.send('Hello Mars! <br> Days until next year:' + Math.round(( new Date().setFullYear(new Date().getFullYear() + 1, 0, 1) - new Date() )/(1000 * 60 * 60 * 24)));
})
app.get('/source', function(req, res){ res.redirect('https://github.com/jkup/one-line/');
console.log("Here you can contribute to this project!")})
app.get('/hangUnlessSomeoneElseReturnsFromHere', function(req, res) {
res.redirect('https://www.google.com/?tbm=isch&q=when+will+my+husband+return+from+war');
}); // To make this route work, someone else needs to return a response
app.get('/useless', function(req, res){ res.redirect('http://www.theuselessweb.com/'); })
app.get('/findMoreHacktoberfestLabelledIssues', function(req, res){ res.redirect('http://issuehub.io/?label[]=hacktoberfest'); })
app.get('/randNum/cake', function(req, res) { res.json({num: 44}); });
app.get('/hello/:name', function(req, res) { res.json({"hello" : req.params.name}); })
app.get('/goodbye/:name', function(req, res) { res.json({"goodbye" : req.params.name}); })
app.get('/admin', function(req, res) { res.json("ACCESS DENIED"); })
app.get('/haveSomeFunCats', function(req, res) { res.redirect('http://www.catgifpage.com/'); });
app.get('/leftpad/:val/:len', function(req, res) { res.json({ 'response': (+req.params.len > 0) ? (Array(+req.params.len-req.params.val.length).fill(0).join('') + req.params.val).slice(-req.params.res) : req.params.val })});
app.get('/add/:x/:y', function(req, res) { res.json({x: req.params.x, y: req.params.y, sum: (Number(req.params.x) + Number(req.params.y))}); });
app.get('/subtract/:x/:y', function(req, res) { res.json({x: req.params.x, y: req.params.y, difference: Number(req.params.x) - Number(req.params.y)}); });
app.get('/fizzbuzz', function(req, res) { for(var i = 1, arr = []; i<51 ;i++) { arr.push(((i % 3 ? '' : 'fizz') + (i % 5 ? '' : 'buzz')) || i)}; res.json(arr); });
app.get('/meaningOfLife', function(req, res) { res.json({ 1337: 42 }) });
app.get('/hacktoberfest-countdown', function (req, res) {
res.send('Hacktoberfest ends in ' + (new Date(2017, 9, 31).getTime() - Date.now())/1000/(24*60*60) + ' days.');
console.log("Better get those PRs in soon, buddy!");
});
app.get('/currency/:from/:to', function(req, res) { res.redirect('http://api.fixer.io/latest?base=' + req.params.from + '&symbols='+ req.params.to); });
app.get('/duckduckgo/:search', function(req, res) { res.redirect('https://duckduckgo.com/?q=' + req.params.search)})
app.get('/beAwesome', function(req, res){ res.redirect('https://github.com/sindresorhus/awesome'); })
app.get('/motivateMe', function(req, res) {res.redirect('https://www.brainyquote.com/quotes/topics/topic_motivational.html')});
app.get('/cloud2butt/:text', function(req, res) {res.send(req.params.text.toLowerCase().split('cloud').join('butt'));});
//51 lines in and NOBODY has commented??? Shame. Well, hello everyone and happy Hacktoberfest. Have fun!
app.get('/hacktoberfest-checker', function(req, res){ res.redirect('https://hacktoberfestchecker.herokuapp.com/'); })
app.get('/findme', function(req,res){ res.redirect('https://github.com/mbj36');})
app.get('/greet', function(req, res) { res.send('🖖'); });
app.get('/nativescript-vue', function(req, res) { res.send('Want to build native apps with vue? Here you go: https://nativescript-vue.org/'); });
app.get('/rollTheDice/:dice', function(req, res) {res.json({"rollValue" : Math.floor(Math.random() * req.params.dice) + 1 })});
app.get('/ispalindrome/:word', (req, res) => res.send([req.params.word].map(w => w.toLowerCase()).map(w => w.replace(/[^a-zA-Z]+/g, "")).map(w => {console.log(w); return w}).reduce((acc, next) => acc ? acc : [...next].reverse().join('') === next, false)))
app.use(function (req, res, next) { res.status(404); res.render('404'); });
console.log(emoji)
console.log(cool())
console.log(funky_intro("Welcome to jkup, a Node.js app where you can only contribute one line at a time. Inspired by jkup himself."))
var server = app.listen(process.env.PORT || 3000, function () { // now we can close it if needed
console.log("Server started");
});
app.use(express.static('public'));
console.log("I like this idea. :p");