Spaces:
Paused
Paused
Vo Hoang Minh commited on
Commit ·
379141e
1
Parent(s): acb39cf
up
Browse files- package.json +4 -4
- src/server.mjs +10 -10
package.json
CHANGED
|
@@ -14,9 +14,9 @@
|
|
| 14 |
"license": "ISC",
|
| 15 |
"packageManager": "pnpm@10.10.0",
|
| 16 |
"dependencies": {
|
|
|
|
|
|
|
| 17 |
"hono": "^4.7.10",
|
| 18 |
-
"puppeteer-core": "^21.0.0"
|
| 19 |
-
|
| 20 |
-
},
|
| 21 |
-
"devDependencies": {}
|
| 22 |
}
|
|
|
|
| 14 |
"license": "ISC",
|
| 15 |
"packageManager": "pnpm@10.10.0",
|
| 16 |
"dependencies": {
|
| 17 |
+
"@hono/node-server": "^1.14.2",
|
| 18 |
+
"gologin": "^1.0.51",
|
| 19 |
"hono": "^4.7.10",
|
| 20 |
+
"puppeteer-core": "^21.0.0"
|
| 21 |
+
}
|
|
|
|
|
|
|
| 22 |
}
|
src/server.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { Hono } from "hono";
|
| 2 |
import puppeteer from "puppeteer-core";
|
| 3 |
import { default as GoLogin } from "gologin";
|
|
|
|
| 4 |
|
| 5 |
const app = new Hono();
|
| 6 |
const PORT = process.env.PORT || 3000;
|
|
@@ -14,14 +15,14 @@ const GL = new GoLogin({
|
|
| 14 |
profileId: "67eeac2670e340a5f67b7c3f66b3f1",
|
| 15 |
});
|
| 16 |
|
| 17 |
-
app.get("/", (c) => {
|
| 18 |
return c.json({
|
| 19 |
message: "Hello",
|
| 20 |
});
|
| 21 |
});
|
| 22 |
|
| 23 |
// API endpoint để khởi tạo trình duyệt
|
| 24 |
-
app.post("/browser/start", async (c) => {
|
| 25 |
try {
|
| 26 |
// Tạo profile mới
|
| 27 |
|
|
@@ -49,7 +50,7 @@ app.post("/browser/start", async (c) => {
|
|
| 49 |
});
|
| 50 |
|
| 51 |
// API endpoint để điều hướng trình duyệt
|
| 52 |
-
app.post("/browser/navigate", async (c) => {
|
| 53 |
try {
|
| 54 |
const { profileId, url } = await c.req.json();
|
| 55 |
|
|
@@ -97,7 +98,7 @@ app.post("/browser/navigate", async (c) => {
|
|
| 97 |
});
|
| 98 |
|
| 99 |
// API endpoint để đóng trình duyệt
|
| 100 |
-
app.post("/browser/stop", async (c) => {
|
| 101 |
try {
|
| 102 |
const { profileId } = await c.req.json();
|
| 103 |
|
|
@@ -131,7 +132,7 @@ app.post("/browser/stop", async (c) => {
|
|
| 131 |
});
|
| 132 |
|
| 133 |
// Trang chủ
|
| 134 |
-
app.get("/", (c) => {
|
| 135 |
return c.html(`
|
| 136 |
<!DOCTYPE html>
|
| 137 |
<html lang="en">
|
|
@@ -175,8 +176,7 @@ app.get("/", (c) => {
|
|
| 175 |
console.log(`Server is starting on port ${PORT}...`);
|
| 176 |
|
| 177 |
// Bắt đầu lắng nghe kết nối
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
export default app;
|
|
|
|
| 1 |
import { Hono } from "hono";
|
| 2 |
import puppeteer from "puppeteer-core";
|
| 3 |
import { default as GoLogin } from "gologin";
|
| 4 |
+
import { serve } from '@hono/node-server'
|
| 5 |
|
| 6 |
const app = new Hono();
|
| 7 |
const PORT = process.env.PORT || 3000;
|
|
|
|
| 15 |
profileId: "67eeac2670e340a5f67b7c3f66b3f1",
|
| 16 |
});
|
| 17 |
|
| 18 |
+
app.get("/api/ping", (c) => {
|
| 19 |
return c.json({
|
| 20 |
message: "Hello",
|
| 21 |
});
|
| 22 |
});
|
| 23 |
|
| 24 |
// API endpoint để khởi tạo trình duyệt
|
| 25 |
+
app.post("/api/browser/start", async (c) => {
|
| 26 |
try {
|
| 27 |
// Tạo profile mới
|
| 28 |
|
|
|
|
| 50 |
});
|
| 51 |
|
| 52 |
// API endpoint để điều hướng trình duyệt
|
| 53 |
+
app.post("/api/browser/navigate", async (c) => {
|
| 54 |
try {
|
| 55 |
const { profileId, url } = await c.req.json();
|
| 56 |
|
|
|
|
| 98 |
});
|
| 99 |
|
| 100 |
// API endpoint để đóng trình duyệt
|
| 101 |
+
app.post("/api/browser/stop", async (c) => {
|
| 102 |
try {
|
| 103 |
const { profileId } = await c.req.json();
|
| 104 |
|
|
|
|
| 132 |
});
|
| 133 |
|
| 134 |
// Trang chủ
|
| 135 |
+
app.get("/api", (c) => {
|
| 136 |
return c.html(`
|
| 137 |
<!DOCTYPE html>
|
| 138 |
<html lang="en">
|
|
|
|
| 176 |
console.log(`Server is starting on port ${PORT}...`);
|
| 177 |
|
| 178 |
// Bắt đầu lắng nghe kết nối
|
| 179 |
+
serve({
|
| 180 |
+
fetch: app.fetch,
|
| 181 |
+
port: 3000,
|
| 182 |
+
})
|
|
|