-
Notifications
You must be signed in to change notification settings - Fork 0
/
tukanimages.js
120 lines (115 loc) · 5.23 KB
/
tukanimages.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
require('dotenv').config()
const express = require('express')
const signale = require('signale')
const chalk = require('chalk')
const clear = require('clear')
const files = require('./utils/files')
const handlePost = require('./utils/post')
const handleError = require('./utils/error')
const cfg = require('./config.json')
const tuki = express()
tuki.use("/raw", express.static("files"))
tuki.get('/', function(req, res) {
res.send(`<html>
<head>
<meta name="theme-color" content="#36393e">
<meta property="og:type" content="website">
<meta property="og:title" content="${cfg.general.name} | ${cfg.general.title}">
<meta property="og:site_name" content="${cfg.general.name} | ${cfg.general.title}" />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="${cfg.general.name} | ${cfg.general.title}">
</head>
<body>
<title>${cfg.general.name} | ${cfg.general.title}</title>
<h1>${cfg.general.name}</h1>
<h3>File Storage</h3>
<h5>This is the homepage of ${cfg.general.name} ${cfg.general.title.replace("- Home", "")} system! if you are here you probably think this has any homepage, sadly it doesnt!<br>
You should probably enter correct file name after / if you dont wanna do that simply close the page.
</h5>
</body>
</html>`)
})
tuki.post('/upload', function(req, res) {
handlePost(req, res, files).catch(handleError.bind(null, req, res));
})
tuki.get('/:url', function(req, res) {
if (req.params.url != null || req.params.url != undefined) {
let rformat = req.params.url.split(".")
let formatbody = ``
let metah = ``
let htitle = ``
let projectn = ``
switch(rformat[1]) {
case "mp4":
formatbody = `<video controls><source src="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}" type="video/mp4"></video>`
metah = `<meta property="og:video:type" content="video/mp4">\n
<meta property="og:video" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">\n
<meta property="og:video:secure_url" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">\n
<meta property="og:video:width" content="720"/>\n<meta property="og:video:height" content="480"/>\n
<meta name="twitter:card" content="player" />\n
<meta name="twitter:image" content="" />\n
<meta name="twitter:player:width" content="640" />\n
<meta name="twitter:player:height" content="640" />\n
<meta name="twitter:player:stream" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}" />\n
<meta name="twitter:player:stream:content_type" content="video/mp4" />`
projectn = `${cfg.lang.videoh}`
htitle = `${cfg.lang.wib}`
break;
case "png":
formatbody = `<img src="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}"></img>`
metah = `<meta property="og:image" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">\n
<meta name="twitter:card" content="summary_large_image">`
projectn = `${cfg.lang.imgh}`
htitle = `${cfg.lang.oib}`
break;
case "jpg":
formatbody = `<img src="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}"></img>`
metah = `<meta property="og:image" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">`
projectn = `${cfg.lang.imgh}`
htitle = `${cfg.lang.oib}`
break;
case "zip" || "txt" || "rar" || "tar" || "gz" || "docx" || "doc" || "js" || "java" || "class" || "ejs" || "css" || "scss" || "html" || "php":
formatbody = `<a href="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">Download file</a>`
metah = `<meta http-equiv="Refresh" content="0; url='${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}'" />`
projectn = `${cfg.lang.fileh}`
htitle = `${cfg.lang.downl}`
break;
default:
formatbody = `<img src="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}"></img>`
metah = `<meta property="og:image" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">`
projectn = `${cfg.lang.imgh}`
htitle = `${cfg.lang.oib}`
break;
}
let format = `<html>
<head>
<meta name="theme-color" content="${cfg.general.color}">
<meta property="og:url" content="${cfg.proxy.url}${cfg.proxy.dir}${req.params.url}">
<meta property="og:type" content="website">
<meta property="og:title" content="${htitle}">
<meta property="og:site_name" content="${cfg.general.name} | ${projectn}" />
${metah}
<meta name="twitter:title" content="${cfg.general.name} | ${projectn}">
</head>
<body>
${formatbody}
</body>
</html>`
res.send(format)
} else {
res.send(`We can not search for file named "${req.params.url}", try again later!`)
}
})
let server = tuki.listen(process.env.PORT, `${process.env.HOST}`, () => {
clear();
console.log(" ");
console.log(" ");
console.log(chalk.bold(` ${cfg.general.name} - ${cfg.general.title.replace("- Home", "")}`));
console.log(" ");
console.log(" ");
console.log(chalk.grey(" (C) 2020, tukandev.xyz"));
console.log(" ");
console.log(" ");
console.log(" ");
signale.success(`Listening on ${server.address().address}:${server.address().port}`);
});