forked from cyclic-software/starter-express-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (35 loc) · 1.29 KB
/
index.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
const express = require('express');
const https = require('https');
const app = express();
const options = {
headers: {
'user-agent': 'Android Vinebre Software'
},
rejectUnauthorized: false
};
app.get('/akotv', (req, res) => {
const s = req.query.s || 'default value';
https.get('https://config.e-droid.net/srv/config.php?v=142&vname=2.0&idapp=2174667&idusu=0&cod_g=&gp=0&am=0&idl=en&pa_env=1&pa=US&pn=com.chacha2022&fus=010100000000&aid=a5417094071fea1a', options, (response) => {
let data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
const delimiter = '[s21700473_url=';
const first_step = data.includes(delimiter) ? data.split(delimiter) : [];
const second_step = first_step.length > 1 ? first_step[1].split('][') : [];
const user = second_step.length > 0 ? second_step[0] : '';
const a = user.replace('/611', s);
// Set the response header to the URL
res.location(a);
res.sendStatus(302); // Send redirect response
});
}).on('error', (error) => {
console.error(error);
res.status(500).json({ error: 'Something went wrong' }); // Send error response
});
});
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});