-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (43 loc) · 1.26 KB
/
Copy pathindex.js
File metadata and controls
53 lines (43 loc) · 1.26 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
const go = require('now-go')
const config = {
'*': (req) => {
const { url } = req
const { host } = req.headers
console.log(host + url)
switch (host) {
case 'amio.us':
case 'jins.io':
return 'https://amio.cn' + url
case 'blog.amio.us':
return 'https://blog.amio.cn' + url
case 'wuxi.sh':
case 'x.now.sh':
return cfgWuxi[url] || cfgWuxi['*']
case 'a.now.sh':
case 'jin.now.sh':
case 'amio.now.sh':
return cfgAmio[url] || cfgAmio['*']
default:
return `Yet another tinyurl service.`
}
}
}
const cfgAmio = {
"/b": "https://blog.amio.cn",
"/i": "https://www.instagram.com/amiocn",
"/t": "https://twitter.com/amiocn",
"/w": "https://weibo.com/amio",
"/": "Amio's tinyurl service. /b /i /t /w",
"*": "What are you looking for?"
}
const cfgWuxi = {
"/blog": "https://zhuanlan.zhihu.com/wu-xi",
"/weibo": "http://weibo.com/wuxiwuxiwuxi",
"/twitter": "https://twitter.com/xiluotonghua",
"/ig": "https://www.instagram.com/_humptydumpty_",
"*": "Xi's tinyurl service.\n\n/blog\n/weibo\n/twitter\n/ig (for instagram)"
}
module.exports = go.createHandler(config)
if (require.main === module) {
require('http').createServer(module.exports).listen(3000)
}