vibora 3.1.3 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/index.js +43 -43
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -146913,49 +146913,6 @@ function generateFilename(extension) {
|
|
|
146913
146913
|
const time2 = now.toTimeString().slice(0, 8).replace(/:/g, "");
|
|
146914
146914
|
return `clipboard-${date}-${time2}.${extension}`;
|
|
146915
146915
|
}
|
|
146916
|
-
app6.post("/", async (c) => {
|
|
146917
|
-
const body = await c.req.parseBody();
|
|
146918
|
-
const file = body["file"];
|
|
146919
|
-
if (!file || !(file instanceof File)) {
|
|
146920
|
-
return c.json({ error: "No file provided" }, 400);
|
|
146921
|
-
}
|
|
146922
|
-
if (!file.type.startsWith("image/")) {
|
|
146923
|
-
return c.json({ error: "File must be an image" }, 400);
|
|
146924
|
-
}
|
|
146925
|
-
const mimeToExt = {
|
|
146926
|
-
"image/png": "png",
|
|
146927
|
-
"image/jpeg": "jpg",
|
|
146928
|
-
"image/gif": "gif",
|
|
146929
|
-
"image/webp": "webp",
|
|
146930
|
-
"image/svg+xml": "svg"
|
|
146931
|
-
};
|
|
146932
|
-
const extension = mimeToExt[file.type] || "png";
|
|
146933
|
-
const saveDir = join10(getViboraDir(), "uploads");
|
|
146934
|
-
if (!existsSync8(saveDir)) {
|
|
146935
|
-
await mkdir(saveDir, { recursive: true });
|
|
146936
|
-
}
|
|
146937
|
-
const filename = generateFilename(extension);
|
|
146938
|
-
const filePath = join10(saveDir, filename);
|
|
146939
|
-
const arrayBuffer = await file.arrayBuffer();
|
|
146940
|
-
await writeFile(filePath, Buffer.from(arrayBuffer));
|
|
146941
|
-
return c.json({ path: filePath });
|
|
146942
|
-
});
|
|
146943
|
-
app6.get("/:filename", async (c) => {
|
|
146944
|
-
const filename = c.req.param("filename");
|
|
146945
|
-
if (!/^clipboard-\d{4}-\d{2}-\d{2}-\d{6}\.\w+$/.test(filename)) {
|
|
146946
|
-
return c.notFound();
|
|
146947
|
-
}
|
|
146948
|
-
const filePath = join10(getViboraDir(), "uploads", filename);
|
|
146949
|
-
if (!existsSync8(filePath)) {
|
|
146950
|
-
return c.notFound();
|
|
146951
|
-
}
|
|
146952
|
-
const ext2 = filename.split(".").pop()?.toLowerCase() || "";
|
|
146953
|
-
const contentType = mimeTypes[ext2] || "application/octet-stream";
|
|
146954
|
-
const content = await readFile(filePath);
|
|
146955
|
-
return new Response(content, {
|
|
146956
|
-
headers: { "Content-Type": contentType }
|
|
146957
|
-
});
|
|
146958
|
-
});
|
|
146959
146916
|
app6.post("/sound", async (c) => {
|
|
146960
146917
|
const body = await c.req.parseBody();
|
|
146961
146918
|
const file = body["file"];
|
|
@@ -147025,6 +146982,49 @@ app6.get("/sound", async (c) => {
|
|
|
147025
146982
|
headers: { "Content-Type": contentType }
|
|
147026
146983
|
});
|
|
147027
146984
|
});
|
|
146985
|
+
app6.post("/", async (c) => {
|
|
146986
|
+
const body = await c.req.parseBody();
|
|
146987
|
+
const file = body["file"];
|
|
146988
|
+
if (!file || !(file instanceof File)) {
|
|
146989
|
+
return c.json({ error: "No file provided" }, 400);
|
|
146990
|
+
}
|
|
146991
|
+
if (!file.type.startsWith("image/")) {
|
|
146992
|
+
return c.json({ error: "File must be an image" }, 400);
|
|
146993
|
+
}
|
|
146994
|
+
const mimeToExt = {
|
|
146995
|
+
"image/png": "png",
|
|
146996
|
+
"image/jpeg": "jpg",
|
|
146997
|
+
"image/gif": "gif",
|
|
146998
|
+
"image/webp": "webp",
|
|
146999
|
+
"image/svg+xml": "svg"
|
|
147000
|
+
};
|
|
147001
|
+
const extension = mimeToExt[file.type] || "png";
|
|
147002
|
+
const saveDir = join10(getViboraDir(), "uploads");
|
|
147003
|
+
if (!existsSync8(saveDir)) {
|
|
147004
|
+
await mkdir(saveDir, { recursive: true });
|
|
147005
|
+
}
|
|
147006
|
+
const filename = generateFilename(extension);
|
|
147007
|
+
const filePath = join10(saveDir, filename);
|
|
147008
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
147009
|
+
await writeFile(filePath, Buffer.from(arrayBuffer));
|
|
147010
|
+
return c.json({ path: filePath });
|
|
147011
|
+
});
|
|
147012
|
+
app6.get("/:filename", async (c) => {
|
|
147013
|
+
const filename = c.req.param("filename");
|
|
147014
|
+
if (!/^clipboard-\d{4}-\d{2}-\d{2}-\d{6}\.\w+$/.test(filename)) {
|
|
147015
|
+
return c.notFound();
|
|
147016
|
+
}
|
|
147017
|
+
const filePath = join10(getViboraDir(), "uploads", filename);
|
|
147018
|
+
if (!existsSync8(filePath)) {
|
|
147019
|
+
return c.notFound();
|
|
147020
|
+
}
|
|
147021
|
+
const ext2 = filename.split(".").pop()?.toLowerCase() || "";
|
|
147022
|
+
const contentType = mimeTypes[ext2] || "application/octet-stream";
|
|
147023
|
+
const content = await readFile(filePath);
|
|
147024
|
+
return new Response(content, {
|
|
147025
|
+
headers: { "Content-Type": contentType }
|
|
147026
|
+
});
|
|
147027
|
+
});
|
|
147028
147028
|
var uploads_default = app6;
|
|
147029
147029
|
|
|
147030
147030
|
// node_modules/hono/dist/utils/stream.js
|