Added authentication and shared notes endpoints
This commit is contained in:
+18
-10
@@ -6,9 +6,11 @@ const ztime = @import(".deps/time.zig");
|
||||
const utils = @import("utils.zig");
|
||||
|
||||
const budget = @import("routes/budget.zig");
|
||||
const auth = @import("routes/auth.zig");
|
||||
const user = @import("routes/user.zig");
|
||||
const trans = @import("routes/transactions.zig");
|
||||
const dash = @import("routes/dashboard.zig");
|
||||
const note = @import("routes/shared_note.zig");
|
||||
|
||||
const Db = @import("db/db.zig").Db;
|
||||
|
||||
@@ -35,22 +37,28 @@ pub fn startHttpServer() !void {
|
||||
|
||||
var router = server.router();
|
||||
|
||||
router.get("/user/:id", user.getUser);
|
||||
router.put("/user", user.putUser);
|
||||
router.delete("/user/:id", user.deleteUser);
|
||||
router.post("/auth/login", user.login);
|
||||
router.post("/auth/signup", user.signup);
|
||||
|
||||
router.get("/budget/:id", budget.getBudget);
|
||||
router.put("/budget", budget.putBudget);
|
||||
router.post("/budget", budget.postBudget);
|
||||
// router.get("/user/:id", user.getUser);
|
||||
router.put("/user", user.putUser);
|
||||
// router.delete("/user/:id", user.deleteUser);
|
||||
|
||||
router.get("/shared_notes/:limit", note.getSharedNotes);
|
||||
router.put("/shared_notes", note.putSharedNote);
|
||||
router.post("/shared_notes", note.postSharedNote);
|
||||
|
||||
// router.get("/budget/:id", budget.getBudget);
|
||||
// router.put("/budget", budget.putBudget);
|
||||
// router.post("/budget", budget.postBudget);
|
||||
|
||||
router.put("/budget_category", budget.putBudgetCategory);
|
||||
router.post("/budget_category", budget.postBudgetCategory);
|
||||
|
||||
router.get("/transactions/:budget_id", trans.getTransactions);
|
||||
router.post("/transactions", trans.postTransaction);
|
||||
router.put("/transactions", trans.putTransaction);
|
||||
|
||||
router.get("/dashboard/:family_id", dash.getDashboard);
|
||||
router.get("/dashboard", dash.getDashboard);
|
||||
|
||||
std.debug.print("Starting http server listening on port {}\n", .{8081});
|
||||
// start the server in the current thread, blocking.
|
||||
@@ -75,8 +83,8 @@ fn errorHandler(req: *httpz.Request, res: *httpz.Response, err: anyerror) void {
|
||||
|
||||
pub fn returnError(message: ?[]const u8, comptime statusCode: u16, res: *httpz.Response) void {
|
||||
comptime {
|
||||
if (statusCode < 300 or statusCode > 500) {
|
||||
@compileError("Failed responses must have status codes between 300 and 500");
|
||||
if (statusCode > 500 or statusCode < 200) {
|
||||
@compileError("Failed responses must have status codes between 200 and 500");
|
||||
}
|
||||
}
|
||||
res.status = statusCode;
|
||||
|
||||
Reference in New Issue
Block a user