Update server.mjs
Browse files- server.mjs +10 -0
server.mjs
CHANGED
|
@@ -138,6 +138,16 @@ app.post("/api/folders", async (c) => {
|
|
| 138 |
return c.json(await repository.createFolder(body), 201);
|
| 139 |
});
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
app.delete("/api/folders/:id", async (c) => {
|
| 142 |
const authError = await getAuthError(c);
|
| 143 |
if (authError) return authError;
|
|
|
|
| 138 |
return c.json(await repository.createFolder(body), 201);
|
| 139 |
});
|
| 140 |
|
| 141 |
+
app.patch("/api/folders/:id", async (c) => {
|
| 142 |
+
const authError = await getAuthError(c);
|
| 143 |
+
if (authError) return authError;
|
| 144 |
+
const body = await c.req.json();
|
| 145 |
+
const result = await repository.updateFolder(c.req.param("id"), body);
|
| 146 |
+
if (result.status === "missing") return c.json({ ok: false, error: "not_found" }, 404);
|
| 147 |
+
if (result.status === "conflict") return c.json({ ok: false, error: "conflict", folder: result.folder }, 409);
|
| 148 |
+
return c.json(result.folder);
|
| 149 |
+
});
|
| 150 |
+
|
| 151 |
app.delete("/api/folders/:id", async (c) => {
|
| 152 |
const authError = await getAuthError(c);
|
| 153 |
if (authError) return authError;
|