From c0214a4e6dd3025f745dbf13288abb28647dc2be Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Thu, 15 Aug 2024 01:03:31 -0400 Subject: [PATCH] get file list using jsony --- src/routes/download.nim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/routes/download.nim b/src/routes/download.nim index 49aaec0..0c1ff53 100644 --- a/src/routes/download.nim +++ b/src/routes/download.nim @@ -39,12 +39,15 @@ proc createDownloadRoutes*() = if not db.validToken(user, H"Authorization"): respErr "Invalid token.\n" - var listOfFiles = @[newFile()] + var seqOfFiles = @[newFile()] try: - db.select(listOfFiles, """"File".owner = $1""", user.id) + db.select(seqOfFiles, """"File".owner = $1""", user.id) except NotFoundError: respErr Http404, "No file exists.\n" - info "List user's file.\n" & reqInfo - resp200 listOfFiles.toJson() # TODO: create new type without unneeded members, read data to it then resp as json. if all else fails -> edit File type to not include owner json in it? Maybe make user.password private? + var seqOfFileInfo = @[getFileInfo()] + for file in seqOfFiles: + seqOfFileInfo.add(getFileInfo(file)) + info "List user's file.\n" & reqInfo + resp200 seqOfFileInfo.toJson()