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(() => { apiRouter.loadAPIMethods().then(() => {
app.route("/", apiRouter.root) app.route("/", apiRouter.root)
console.log("API OK!") 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 // index, clone
@ -104,20 +121,4 @@ app.get("/", async (ctx) =>
file serving 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 export default app

View file

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

View file

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