You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
59 lines
1.2 KiB
/** |
|
* Express router of api/ |
|
*/ |
|
|
|
import express from 'express'; |
|
import common from './common.mjs'; |
|
import HeroUnion from './heroUnion.mjs'; |
|
|
|
//初始化爬虫联盟 |
|
const heroUnion = new HeroUnion(); |
|
heroUnion.init(); |
|
|
|
|
|
const router = express.Router(); |
|
|
|
router.get('/', async (req, res) => { |
|
const apiList = { |
|
"/api/": "查看所有API", |
|
"/api/stats/": "查看联盟状态", |
|
}; |
|
|
|
const data = { |
|
name: heroUnion.config.name, |
|
version: heroUnion.config.version, |
|
apis: apiList |
|
}; |
|
return res.status(200).json(data); |
|
}); |
|
|
|
router.post('/newtask/', async (req, res) => { |
|
|
|
return res.send('api/newtask/'); |
|
}); |
|
|
|
router.get('/gettask/', async (req, res) => { |
|
|
|
return res.send('api/gettask/'); |
|
}); |
|
|
|
router.post('/savetask/', async (req, res) => { |
|
|
|
return res.send('api/savetask/'); |
|
}); |
|
|
|
router.get('/querytask/', async (req, res) => { |
|
|
|
return res.send('api/querytask/'); |
|
}); |
|
|
|
router.post('/onboard/', async (req, res) => { |
|
|
|
return res.send('api/onboard/'); |
|
}); |
|
|
|
router.get('/stats/', async (req, res) => { |
|
return res.status(200).json(heroUnion.getStats()); |
|
}); |
|
|
|
export default router;
|
|
|