mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 21:50:35 +02:00
Update scanner (server)
This commit is contained in:
@@ -48,7 +48,15 @@ router
|
||||
.post(
|
||||
validateRequest(validation.servers.scan),
|
||||
authenticateAdmin,
|
||||
controller.servers.scanServer
|
||||
controller.servers.quickScanServer
|
||||
);
|
||||
|
||||
router
|
||||
.route('/:serverId/full-scan')
|
||||
.post(
|
||||
validateRequest(validation.servers.scan),
|
||||
authenticateAdmin,
|
||||
controller.servers.fullScanServer
|
||||
);
|
||||
|
||||
router
|
||||
|
||||
@@ -1,11 +1,39 @@
|
||||
import express, { Router } from 'express';
|
||||
import { controller } from '@controllers/index';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { authenticateAdmin } from '@middleware/authenticate-admin';
|
||||
import { ApiError } from '@utils/api-error';
|
||||
import { validation } from '@validations/index';
|
||||
import { validateRequest } from '@validations/shared.validation';
|
||||
|
||||
export const router: Router = express.Router({ mergeParams: true });
|
||||
|
||||
router.post('/scan', async (_req, res) => {
|
||||
return res.status(200);
|
||||
router
|
||||
.route('/')
|
||||
.get(validateRequest(validation.tasks.list), controller.tasks.getActiveTasks);
|
||||
|
||||
router
|
||||
.route('/cancel')
|
||||
.post(
|
||||
authenticateAdmin,
|
||||
validateRequest(validation.tasks.cancelAll),
|
||||
controller.tasks.cancelAllTasks
|
||||
);
|
||||
|
||||
router.param('taskId', async (_req, _res, next, taskId) => {
|
||||
const task = await prisma.task.findUnique({ where: { id: taskId } });
|
||||
|
||||
if (!task) {
|
||||
throw ApiError.notFound('Task not found');
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
router.post('/', async (_req, res) => {
|
||||
return res.status(200).json({});
|
||||
});
|
||||
router
|
||||
.route('/:taskId/cancel')
|
||||
.post(
|
||||
authenticateAdmin,
|
||||
validateRequest(validation.tasks.cancel),
|
||||
controller.tasks.cancelTaskById
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user