Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hyc1230 committed Oct 4, 2023
0 parents commit 3a2795d
Show file tree
Hide file tree
Showing 5 changed files with 1,127 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
42 changes: 42 additions & 0 deletions app.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
Loading

0 comments on commit 3a2795d

Please sign in to comment.