Update index.ts
This commit is contained in:
+5
-1
@@ -75,10 +75,10 @@ export const app = new Elysia()
|
||||
// Error handling: Return status code and message
|
||||
.onError(({ error, status }) => {
|
||||
if (error instanceof HttpError) {
|
||||
console.error(`[-] HTTP ${error.status}: ${error.message}`)
|
||||
if (error.content instanceof String) return status(error.status, { msg: error.message })
|
||||
else return status(error.status, error.content)
|
||||
}
|
||||
// else return status(500, { error: "Internal Server Error" })
|
||||
else throw error
|
||||
})
|
||||
.get("/", ({ redirect }) => redirect("https://aza.moe/photo"))
|
||||
@@ -87,6 +87,8 @@ export const app = new Elysia()
|
||||
const { owner_key, photo, edited_photo } = body
|
||||
checkHeaderKey(headers)
|
||||
|
||||
console.log("[+] Received upload request")
|
||||
|
||||
// Generate an ID of 8 numbers
|
||||
const id = Math.random().toString().substring(2, 10)
|
||||
let metadata = await getMetadata()
|
||||
@@ -128,6 +130,8 @@ export const app = new Elysia()
|
||||
metadata.push(newEntry)
|
||||
await saveMetadata(metadata)
|
||||
|
||||
console.log(`[+] Upload complete for photo ${newEntry.id}`)
|
||||
|
||||
done(201, { success: true, id: newEntry.id })
|
||||
}, {
|
||||
// --- Validation Schema ---
|
||||
|
||||
Reference in New Issue
Block a user