/** * 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;