Extract service/store layer from API handlers #13
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
#14 Add structured JSON error responses
austin/vektor
#16 Add
GET /api/projects/{key} endpoint
austin/vektor
#1 Fix nil pointer panic in local auth mode
austin/vektor
Reference
austin/vektor#13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
All SQL queries are currently inline in the HTTP handlers (
internal/api/projects.go,internal/api/issues.go). This makes the code hard to test and the handlers too thick.What needs to happen
Create
internal/store/with aStorestruct wrapping*sql.DB. Methods like:ListProjects(ctx context.Context) ([]models.Project, error)CreateProject(ctx context.Context, input CreateProjectInput) (*models.Project, error)ListIssues(ctx context.Context, projectKey string, filters IssueFilters) ([]models.Issue, error)CreateIssue(ctx context.Context, projectKey string, input CreateIssueInput) (*models.Issue, error)Handlers become thin: parse request → call store → write response. This is the repository pattern, very standard in Go.
Keep it as a concrete struct with concrete methods. Do not create an interface yet — interfaces come later when you actually need to mock for tests.
Key files
internal/api/issues.go— SQL to extractinternal/api/projects.go— SQL to extractinternal/store/— new packageGET /api/projects/{key}endpoint