Added endpoint to modify or add tags via API#2
Open
ArturoAvendano wants to merge 3 commits into
Open
Conversation
…ed_tags_management
…gement Updated tags management via API [OBS-707]
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds administrative CRUD support for tags via the REST API and updates docs/UI examples plus smoke coverage to match.
Changes:
- Implemented
POST /api/v1/tags,PATCH /api/v1/tags/:id, andDELETE /api/v1/tags/:id(admin + write scope) with audit logging. - Added tag lookup helpers (
getTagListed,getTagByName) includingsite_countto support API responses. - Updated README, settings page examples, and smoke tests to document and verify the new endpoints.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| views/settings-api-tokens.ejs | Adds curl examples for creating monitors and tags via API tokens |
| src/routes/api.js | Adds tags create/update/delete endpoints and helpers in the API router |
| src/lib/tags.js | Adds DB helpers to fetch tags with site_count and by name |
| scripts/smoke-features.sh | Extends smoke script to exercise tags CRUD and scope enforcement |
| README.md | Documents tags API semantics and adds example commands |
| PLAN.md | Updates API endpoint plan list to include tag write endpoints |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+315
to
+317
| function isUniqueConstraintError(err) { | ||
| return String(err?.message || '').toLowerCase().includes('unique'); | ||
| } |
Comment on lines
+89
to
+101
| async function loadTag(req, res) { | ||
| const id = parseId(req.params.id); | ||
| if (id == null) { | ||
| res.status(404).json({ error: 'not found' }); | ||
| return null; | ||
| } | ||
| const row = await tagsLib.getTagListed(id); | ||
| if (!row) { | ||
| res.status(404).json({ error: 'not found' }); | ||
| return null; | ||
| } | ||
| return row; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, i would like to contribute the present PR to add tags via API, as the name says, it adds additional functionality to add tags, feel free to reach out to me to correct or expand the code, best wishes.