forked from hyc-official/rainyun-auto-rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.cjs
42 lines (37 loc) · 1.08 KB
/
app.cjs
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
const fetch = require("node-fetch");
const express = require("express");
const app = express();
const port = process.env.PORT || 3000;
const apikey = process.env.apikey;
const apis = [
{
path: "/daily-rewards",
rainyun_apiurl : "https://api.v2.rainyun.com/user/reward/tasks",
fetch_options: {
method: "POST",
headers: {
"X-Api-Key": apikey,
"User-Agent": "Apifox/1.0.0 (https://apifox.com)",
"Content-Type": "application/json",
},
body: JSON.stringify({
task_name: "每日签到",
}),
redirect: "follow",
},
},
];
apis.forEach((e) => {
app.get(e.path, (req, res, next) => {
(async (req, res) => {
const rp = await fetch(e.rainyun_apiurl, e.fetch_options);
res.status(rp.status).send(await rp.text());
})(req, res).catch(next);
});
});
if (require.main === module) {
app.listen(port, () => {
console.log(`App started on port ${port}`);
});
}
module.exports = app;