Compare commits

..

No commits in common. "e96c5f682054e8fd1af30fdd686d2e411c467160" and "34c47b05400768fdaf08504d23adf3113d20ef75" have entirely different histories.

19
u2b.js
View File

@ -1,9 +1,7 @@
var singleflightCache = {};
const timeoutMs = 1000*60*60*6;
async function handle(req, res) {
console.log(new Date().toISOString(), req.socket.remoteAddress, req.headers["x-forwarded-for"] || '-', req.method, req.url, req.headers["user-agent"] || '-');
require("http").createServer(async function (req, res) {
if (req.url == "/") {
res.writeHead(302, {"Location": "https://www.u2b.cx/"});
res.end();
@ -77,7 +75,8 @@ async function handle(req, res) {
"Expires": new Date((promise?.date?.valueOf() || Date.now()) + timeoutMs).toUTCString()
});
res.end();
}
}).listen(process.env.PORT || 8494, process.env.ADDRESS);
async function videoIdsFromYouTubeSearch(query) {
console.log("search", query);
@ -96,15 +95,3 @@ async function videoIdsFromYouTubeSearch(query) {
.filter(x => x.videoRenderer)
.map(x => x.videoRenderer.videoId);
}
require("http").createServer((req, res) => {
handle(req, res).catch(error => {
console.error(req.url, error.stack);
try {
res.writeHead(500);
res.end();
} catch (error) {
console.error(error.stack);
}
});
}).listen(process.env.PORT || 8494, process.env.ADDRESS);