feat: add route to verify is robot is running
This commit is contained in:
@@ -16,6 +16,7 @@ import stealthPlugin from 'puppeteer-extra-plugin-stealth';
|
||||
import logger from "../logger";
|
||||
import { getDecryptedProxyConfig } from './proxy';
|
||||
import { requireSignIn } from '../middlewares/auth';
|
||||
import { browserPool } from '../server';
|
||||
|
||||
export const router = Router();
|
||||
chromium.use(stealthPlugin());
|
||||
@@ -33,6 +34,17 @@ router.all('/', requireSignIn, (req, res, next) => {
|
||||
next() // pass control to the next handler
|
||||
})
|
||||
|
||||
router.use('/', requireSignIn, (req: AuthenticatedRequest, res: Response, next) => {
|
||||
if (browserPool.hasActiveRobotRun()) {
|
||||
logger.log('debug', 'Preventing browser initialization - robot run in progress');
|
||||
return res.status(403).json({
|
||||
error: 'Cannot initialize recording browser while a robot run is in progress'
|
||||
});
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* GET endpoint for starting the remote browser recording session.
|
||||
* returns session's id
|
||||
|
||||
Reference in New Issue
Block a user