diff --git a/backend/src/index.ts b/backend/src/index.ts index cc15439..614e27b 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,13 +1,30 @@ import { Hono } from "hono"; import { validator } from "hono/validator"; +let canConnectBridgeServer: boolean = true +try { + await Bun.connect({ + hostname: "localhost", + port: 8081, + socket: { + data: () => { }, + }, + }) +} catch (e) { + canConnectBridgeServer = false +} + +if (!canConnectBridgeServer) { + console.log("Connect to bridge: localhost:8081 failed"); + process.exit(1) +} + const appTmp = new Hono() const app = appTmp.basePath("/watermark") - /** * param: image: 图片大小必须<=10MB * param: payload: 必须是长度<=8的字母大小写或数字组合 - * param: strength: 取值>=0,一般取值0~1.5 + * param: strength: 取值0~100,一般取值0~1.5 * param: outputType: 输出的文件类型,只允许 jpeg | png */ app.post("/encode",