-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
231 lines (193 loc) · 4.9 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
require('./message');
const { tiktok, capcut, igdl, fbdl, aiodl, tiktoks } = require('./danz');
const express = require('express');
const rateLimit = require('express-rate-limit');
const compression = require('compression');
const session = require('express-session');
const cookieParser = require('cookie-parser');
const memoryStore = require('memorystore')(session);
const cors = require('cors');
const secure = require('ssl-express-www');
const path = require('path');
const { GoogleGenerativeAI } = require("@google/generative-ai");
const genAI = new GoogleGenerativeAI(pickRandom(['AIzaSyAxyeDIZautcsjCWYEfsranT9z-i14wDLU', 'AIzaSyCfH7p_qrkbNJ4pTE51_oU8I6G5tKR8kIs']));
var model = genAI.getGenerativeModel({ model: "gemini-pro" });
const author = "DannTeam";
const PORT = process.env.PORT || 3000;
const app = express();
// Function
function pickRandom(list) {
return list[Math.floor(list.length * Math.random())]
}
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.set('trust proxy', 1);
app.use(compression());
const limit = rateLimit({
windowMs: 1 * 60 * 1000,
max: 2000,
message: 'Oops too many requests'
});
app.use(limit);
app.use(cors())
app.use(secure)
app.use(session({
secret: 'secret',
resave: true,
saveUninitialized: true,
cookie: { maxAge: 86400000 },
store: new memoryStore({
checkPeriod: 86400000
}),
}));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cookieParser());
// Routes
app.get('/', (req, res) => {
res.render('index');
});
app.get('/api', (req, res) => {
res.render('api', { title: 'Endpoint - DannTeam API'})
});
app.get('/tiktokdl', (req, res) => {
res.render('tiktokdl')
});
app.get('/douyindl', (req, res) => {
res.render('douyindl')
});
app.get('/remini', (req, res) => {
res.render('remini')
});
app.get('/speech', (req, res) => {
res.render('speech')
})
app.get('/docs', (req, res) => {
res.render('docs')
});
// Downloader
app.get('/tiktok', async (req, res) => {
const url = req.query.url;
if (!url) return res.json(msg.paramurl);
try {
const data = await tiktok(url);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.get('/instagram', async (req, res) => {
const url = req.query.url;
if (!url) return res.json(msg.paramurl);
try {
const data = await igdl(url);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.get('/capcut', async (req, res) => {
const url = req.query.url;
if (!url) return res.json(msg.paramurl);
try {
const data = await capcut(url);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.get('/facebook', async (req, res) => {
const url = req.query.url;
if (!url) return res.json(msg.paramurl);
try {
const data = await fbdl(url);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.get('/aio', async (req, res) => {
const url = req.query.url;
if (!url) return res.json(msg.paramurl);
try {
const data = await aiodl(url);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
// Search
app.get('/tiktoksearch', async (req, res) => {
const query = req.query.query;
if (!query) return res.json(msg.paramquery);
try {
const data = await tiktoks(query);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
// AI
app.get('/gemini', async (req, res) => {
const query = req.query.query;
if (!query) return res.json(msg.paramquery);
try {
const data = await model.generateContent(query);
if (!data) {
return res.json({ status: false, message: msg.nodata });
}
res.json({
status: true,
creator: author,
result: data.response.text()
});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
// Stalker
app.listen(PORT, () => {
console.log(`[STATUS] >> Server is running on port ${PORT}`);
});