33 lines
822 B
Zig
33 lines
822 B
Zig
const api = @import("api");
|
|
const controller_utils = @import("../../controllers.zig").helpers;
|
|
|
|
const QueryArgs = api.CommunityQueryArgs;
|
|
|
|
pub const create = struct {
|
|
pub const method = .POST;
|
|
pub const path = "/communities";
|
|
|
|
pub const Body = struct {
|
|
origin: []const u8,
|
|
};
|
|
|
|
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
|
|
const invite = try srv.createCommunity(req.body.origin);
|
|
|
|
try res.json(.created, invite);
|
|
}
|
|
};
|
|
|
|
pub const query = struct {
|
|
pub const method = .GET;
|
|
pub const path = "/communities";
|
|
|
|
pub const Query = QueryArgs;
|
|
|
|
pub fn handler(req: anytype, res: anytype, srv: anytype) !void {
|
|
const results = try srv.queryCommunities(req.query);
|
|
|
|
try controller_utils.paginate(results, res, req.allocator);
|
|
}
|
|
};
|