@loghead/core 0.1.33 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -207,6 +207,15 @@ export async function startApiServer(db, auth) {
207
207
  await db.deleteProject(id);
208
208
  res.json({ success: true });
209
209
  });
210
+ app.patch("/api/projects/:id", async (req, res) => {
211
+ const { id } = req.params;
212
+ const { name } = req.body;
213
+ if (!name || !name.trim()) {
214
+ return res.status(400).send("Name required");
215
+ }
216
+ const project = await db.renameProject(id, name.trim());
217
+ res.json(project);
218
+ });
210
219
  app.get("/api/streams", async (req, res) => {
211
220
  const projectId = req.query.projectId;
212
221
  if (projectId) {
@@ -222,6 +231,15 @@ export async function startApiServer(db, auth) {
222
231
  await db.deleteStream(id);
223
232
  res.json({ success: true });
224
233
  });
234
+ app.patch("/api/streams/:id", async (req, res) => {
235
+ const { id } = req.params;
236
+ const { name } = req.body;
237
+ if (!name || !name.trim()) {
238
+ return res.status(400).send("Name required");
239
+ }
240
+ const stream = await db.renameStream(id, name.trim());
241
+ res.json(stream);
242
+ });
225
243
  app.get("/api/streams/:id/token", async (req, res) => {
226
244
  const { id } = req.params;
227
245
  try {
@@ -300,6 +318,50 @@ export async function startApiServer(db, auth) {
300
318
  }
301
319
  res.json(logs);
302
320
  });
321
+ app.get("/api/issues", async (req, res) => {
322
+ const projectId = req.query.projectId;
323
+ const status = req.query.status;
324
+ const limit = parseInt(req.query.limit || "50");
325
+ if (!projectId) {
326
+ return res.status(400).send("Missing projectId");
327
+ }
328
+ try {
329
+ const issues = await db.getIssues(projectId, status, limit);
330
+ res.json(issues);
331
+ }
332
+ catch (e) {
333
+ console.error("Error fetching issues:", e);
334
+ res.status(500).send(String(e));
335
+ }
336
+ });
337
+ app.get("/api/issues/:id", async (req, res) => {
338
+ const { id } = req.params;
339
+ try {
340
+ const data = await db.getIssue(id);
341
+ if (!data)
342
+ return res.status(404).send("Issue not found");
343
+ res.json(data);
344
+ }
345
+ catch (e) {
346
+ console.error("Error fetching issue details:", e);
347
+ res.status(500).send(String(e));
348
+ }
349
+ });
350
+ app.patch("/api/issues/:id", async (req, res) => {
351
+ const { id } = req.params;
352
+ const { status } = req.body;
353
+ if (status !== "open" && status !== "resolved") {
354
+ return res.status(400).send("Invalid status");
355
+ }
356
+ try {
357
+ await db.updateIssueStatus(id, status);
358
+ res.json({ success: true });
359
+ }
360
+ catch (e) {
361
+ console.error("Error updating issue:", e);
362
+ res.status(500).send(String(e));
363
+ }
364
+ });
303
365
  // SPA fallback
304
366
  app.get("*", (req, res) => {
305
367
  if (req.path.startsWith("/api")) {