Skip to content

Commit

Permalink
fix(pup): pup try-catch (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
KRoses96 authored Aug 20, 2024
1 parent d37c5cd commit e223232
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { instrument } from "@socket.io/admin-ui";
import cors from "cors";
import express from "express";
import { rateLimit } from "express-rate-limit";
import morgan from "morgan";
import { Server } from "socket.io";
import swaggerUi from "swagger-ui-express";
import swaggerDocument from "../swagger.json";
Expand All @@ -13,7 +14,6 @@ import userMethods from "./models/userMethods";
import { authRouter } from "./routes/auth";
import spaceRouter from "./routes/space";
import userRouter from "./routes/user";
import morgan from "morgan";

const app = express();

Expand Down
56 changes: 29 additions & 27 deletions src/screenBot/screenCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,34 @@ export const printBot = async () => {
});

for (const space of activeSpaces) {
const page = await browser.newPage();

await page.goto(space.flyUrl);

await page.setViewport({ width: 1920, height: 1024 });
await page.locator("text/Connect").click();
await delay(2000);
await page.locator("#noVNC_password_input").click();
await delay(1000);
await page.keyboard.type(`${space.password}`);
await delay(500);
await page.locator("text/Send Password").click();
await delay(2000);
await page.screenshot({ path: "src/screenBot/screenshot.png" });

const pictureLink = await cloudinary.uploader.upload(
"src/screenBot/screenshot.png",
);

await db
.update(spaces)
.set({
thumbnail: pictureLink.url,
})
.where(eq(spaces.id, space.id));

await page.close();
try {
const page = await browser.newPage();

await page.goto(space.flyUrl);

await page.setViewport({ width: 1920, height: 1024 });
await page.locator("text/Connect").click();
await delay(2000);
await page.locator("#noVNC_password_input").click();
await delay(1000);
await page.keyboard.type(`${space.password}`);
await delay(500);
await page.locator("text/Send Password").click();
await delay(2000);
await page.screenshot({ path: "src/screenBot/screenshot.png" });

const pictureLink = await cloudinary.uploader.upload(
"src/screenBot/screenshot.png",
);

await db
.update(spaces)
.set({
thumbnail: pictureLink.url,
})
.where(eq(spaces.id, space.id));

await page.close();
} catch (err) {}
}
};

0 comments on commit e223232

Please sign in to comment.