From e95cf5c7b6a08eb560763d5167fbddc1c2117bcc Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Mon, 17 Nov 2025 09:57:09 +0100 Subject: add file uploading and multi-threading --- src/routes/api/image/list.zig | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/routes/api/image/list.zig (limited to 'src/routes/api/image/list.zig') diff --git a/src/routes/api/image/list.zig b/src/routes/api/image/list.zig new file mode 100644 index 0000000..ee7a648 --- /dev/null +++ b/src/routes/api/image/list.zig @@ -0,0 +1,30 @@ +const std = @import("std"); +const Context = @import("../../context.zig"); +const Storage = @import("../../../storage/root.zig"); + +pub const access = .users; + +const ImageInfo = struct { + id: []const u8, +}; + +const Result = struct { + images: []ImageInfo, +}; + +pub fn get(ctx: *Context) !Result { + var images: std.ArrayList(ImageInfo) = .empty; + + const images_list = ctx.storage.images.list(); + defer images_list.deinit(); + + for (images_list.images) |*image| { + try images.append(ctx.allocator, .{ + .id = image.id + }); + } + + return .{ + .images = try images.toOwnedSlice(ctx.allocator), + }; +} -- cgit v1.2.3-70-g09d2