[+] Upload
This commit is contained in:
+5
-2
@@ -72,7 +72,7 @@ async function getExifData(file: File): Promise<any> {
|
||||
const INSTANT_KEY = process.env.INSTANT_KEY!
|
||||
if (!await exists(FOLDER_PHOTOS)) await mkdir(FOLDER_PHOTOS, { recursive: true })
|
||||
|
||||
console.log("Server starting with valid 'secrets.json'.")
|
||||
console.log("Server started.")
|
||||
|
||||
function checkHeaderKey(headers: Record<string, string | undefined>, expectList: string[] = [INSTANT_KEY]) {
|
||||
const key = headers["x-instant-key"]
|
||||
@@ -80,13 +80,16 @@ function checkHeaderKey(headers: Record<string, string | undefined>, expectList:
|
||||
}
|
||||
|
||||
export const app = new Elysia()
|
||||
.get("/", () => "Running!")
|
||||
|
||||
// Error handling: Return status code and message
|
||||
.onError(({ error, status }) => {
|
||||
if (error instanceof HttpError) {
|
||||
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 return status(500, { error: "Internal Server Error" })
|
||||
else throw error
|
||||
})
|
||||
|
||||
.post("/upload", async ({ body, headers, status }) => {
|
||||
|
||||
Reference in New Issue
Block a user