Few quick patches

This commit is contained in:
May 2024-03-09 17:22:08 -08:00
parent 490098f33b
commit 8f1b1ada84
3 changed files with 26 additions and 27 deletions

View file

@ -85,6 +85,23 @@ const apiRouter = new APIRouter(files)
apiRouter.loadAPIMethods().then(() => {
app.route("/", apiRouter.root)
console.log("API OK!")
// listen on 3000 or MONOFILE_PORT
// moved here to prevent a crash if someone manages to access monofile before api routes are mounted
serve(
{
fetch: app.fetch,
port: Number(process.env.MONOFILE_PORT || 3000),
serverOptions: {
//@ts-ignore
requestTimeout: config.requestTimeout
}
},
(info) => {
console.log("Web OK!", info.port, info.address)
}
)
})
// index, clone
@ -104,20 +121,4 @@ app.get("/", async (ctx) =>
file serving
*/
// listen on 3000 or MONOFILE_PORT
serve(
{
fetch: app.fetch,
port: Number(process.env.MONOFILE_PORT || 3000),
serverOptions: {
//@ts-ignore
requestTimeout: config.requestTimeout
}
},
(info) => {
console.log("Web OK!", info.port, info.address)
}
)
export default app

View file

@ -107,9 +107,7 @@ export default function (files: Files) {
: `@${fileOwner?.username || "Deleted User"}`
)
)
} else {
ServeError(ctx, 404, "file not found")
}
} else return ServeError(ctx, 404, "file not found")
})
return router

View file

@ -4,6 +4,7 @@
import { fade } from "svelte/transition"
import { circIn, circOut } from "svelte/easing"
import { serverStats, refresh_stats, account } from "./stores.mjs"
import bytes from "bytes"
import AttachmentZone from "./uploader/AttachmentZone.svelte"
@ -213,9 +214,7 @@
{upload[1].name}
<span style:color="#999999" style:font-weight="400"
>{upload[1].type}{@html upload[1].type == "upload"
? `&nbsp;(${Math.round(
upload[1].file.size / 1048576
)}MiB)`
? `&nbsp;(${bytes(upload[1].file.size)})`
: ""}</span
>
</h2>
@ -372,11 +371,12 @@
>{$serverStats.files || "•••"}</span
>
files — Maximum filesize is
<span class="number" style:font-weight="600"
>{(($serverStats.maxDiscordFileSize || 0) *
($serverStats.maxDiscordFiles || 0)) /
1048576 || "•••"}MiB</span
>
<span class="number" style:font-weight="600">
{
$serverStats.maxDiscordFiles
? bytes($serverStats.maxDiscordFileSize * $serverStats.maxDiscordFiles)
: "•••"
}</span>
<br />
</p>
<p style:color="#999999" style:text-align="center" style:font-size="12px">