rid of pointless functions (thanks jack)

This commit is contained in:
May 2023-08-02 12:58:05 +00:00
parent 7651cd65ab
commit 6d6f8b1832

View file

@ -198,7 +198,15 @@ app.get("/download/:fileId",(req,res) => {
} }
}) })
let fgRQH = async (req:express.Request,res:express.Response) => { app.get("/server",(req,res) => {
res.send(JSON.stringify({
...config,
version:pkg.version,
files:Object.keys(files.files).length
}))
})
app.get(["/file/:fileId", "/cpt/:fileId/*", "/:fileId"],async (req:express.Request,res:express.Response) => {
let file = files.getFilePointer(req.params.fileId) let file = files.getFilePointer(req.params.fileId)
res.setHeader("Access-Control-Allow-Origin", "*") res.setHeader("Access-Control-Allow-Origin", "*")
@ -260,10 +268,9 @@ let fgRQH = async (req:express.Request,res:express.Response) => {
ServeError(res, 404, "file not found") ServeError(res, 404, "file not found")
} }
})
} app.head(["/file/:fileId", "/cpt/:fileId/*", "/:fileId"], (req: express.Request, res:express.Response) => {
let fgwh = (req: express.Request, res:express.Response) => {
let file = files.getFilePointer(req.params.fileId) let file = files.getFilePointer(req.params.fileId)
res.setHeader("Access-Control-Allow-Origin", "*") res.setHeader("Access-Control-Allow-Origin", "*")
if (req.query.attachment == "1") res.setHeader("Content-Disposition", "attachment") if (req.query.attachment == "1") res.setHeader("Content-Disposition", "attachment")
@ -279,24 +286,8 @@ let fgwh = (req: express.Request, res:express.Response) => {
res.setHeader("Accept-Ranges", "bytes") res.setHeader("Accept-Ranges", "bytes")
} }
} }
}
app.get("/server",(req,res) => {
res.send(JSON.stringify({
...config,
version:pkg.version,
files:Object.keys(files.files).length
}))
}) })
app.get("/file/:fileId",fgRQH)
app.get("/cpt/:fileId/*",fgRQH)
app.get("/:fileId",fgRQH)
app.head("/file/:fileId",fgwh)
app.head("/cpt/:fileId/*",fgwh)
app.head("/:fileId",fgwh)
/* /*
routes should be in this order: routes should be in this order: