Create api.js
Browse files
api.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require('express');
|
| 2 |
+
const crypto = require('crypto');
|
| 3 |
+
const axios = require('axios');
|
| 4 |
+
const cors = require('cors');
|
| 5 |
+
const app = express();
|
| 6 |
+
|
| 7 |
+
app.use((req, res, next) => {
|
| 8 |
+
console.log(`Request from: ${req.ip}, params: ${JSON.stringify(req.query)}`);
|
| 9 |
+
next();
|
| 10 |
+
});
|
| 11 |
+
app.use(cors());
|
| 12 |
+
|
| 13 |
+
app.use(express.static('public'));
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
app.get('/blued', async (req, res) => {
|
| 18 |
+
const { name } = req.query;
|
| 19 |
+
|
| 20 |
+
const input = `16566580507931f7c79f67099ddad3a4f0e4ed29a6name${name}page1`;
|
| 21 |
+
|
| 22 |
+
const sign = crypto.createHash('md5').update(input).digest('hex').toUpperCase();
|
| 23 |
+
|
| 24 |
+
const url = 'https://app.blued.cn/home/web-recharge/getUserInfoByNickname';
|
| 25 |
+
|
| 26 |
+
const params = {
|
| 27 |
+
name,
|
| 28 |
+
page: 1,
|
| 29 |
+
sign
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
try {
|
| 33 |
+
const response = await axios.get(url, { params });
|
| 34 |
+
res.send(response.data);
|
| 35 |
+
} catch (error) {
|
| 36 |
+
console.error(error);
|
| 37 |
+
res.status(500).send('Error getting data from Blued');
|
| 38 |
+
}
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
app.listen(3000, '0.0.0.0', () => {
|
| 42 |
+
console.log('Server listening on port 80');
|
| 43 |
+
});
|