Skip to content

feat(scan): scaffold Scan Service - #44

Merged
NirmalKBandara merged 3 commits into
mainfrom
feat/11-scan-foundation
Aug 11, 2026
Merged

feat(scan): scaffold Scan Service#44
NirmalKBandara merged 3 commits into
mainfrom
feat/11-scan-foundation

Conversation

@NirmalKBandara

Copy link
Copy Markdown
Contributor

Closes #11

What

Adds the initial Scan Service foundation.

  • SQLite scan storage
  • POST /scan
  • GET /scan/{id}
  • GET /scans
  • GET /healthz
  • GET /readyz
  • structured JSON logging
  • unit tests

How I verified

  • go fmt ./...
  • go vet ./...
  • go test ./...
  • manually tested endpoints using curl

Copilot AI lite review requested due to automatic review settings August 11, 2026 17:51
@NirmalKBandara
NirmalKBandara merged commit 05f4dc3 into main Aug 11, 2026
1 check passed
@NirmalKBandara
NirmalKBandara deleted the feat/11-scan-foundation branch August 11, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR scaffolds a new Scan Service within services/scan, providing an HTTP API backed by a SQLite persistence layer and basic unit tests, aligning with Issue #11’s scaffold + storage acceptance criteria.

Changes:

  • Added a SQLite-backed store with Scan / Finding models and CRUD-style operations (create, get by id, list).
  • Implemented HTTP handlers + routing for /healthz, /readyz, POST /scan, GET /scan/{id}, and GET /scans, with structured JSON logging.
  • Added unit tests covering the store and handler endpoints, plus service startup wiring in cmd/server.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
services/scan/internal/store/store.go SQLite schema + store methods for creating, fetching, and listing scans
services/scan/internal/store/store_test.go Unit tests for store create/get/list behaviors
services/scan/internal/store/model.go Scan, Finding, and ScanStatus model definitions
services/scan/internal/handler/handler.go HTTP routes, handlers, JSON helpers, and request logging middleware
services/scan/internal/handler/handler_test.go Handler tests for health endpoints, scan lifecycle, and invalid request rejection
services/scan/go.mod New Go module for the scan service and its direct/indirect dependencies
services/scan/go.sum Dependency checksum entries for the scan service module
services/scan/cmd/server/main.go Service entrypoint wiring logger, store, router, and graceful shutdown
services/scan/.env.example Example environment variables for port and DB path

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +106 to +107
scan.CreatedAt.Format(time.RFC3339Nano),
scan.UpdatedAt.Format(time.RFC3339Nano),
Comment on lines +115 to +132
type statusRecorder struct {
http.ResponseWriter
status int
}

func (r *statusRecorder) WriteHeader(status int) {
r.status = status
r.ResponseWriter.WriteHeader(status)
}

func (h *Handler) requestLogger(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
recorder := &statusRecorder{ResponseWriter: w, status: http.StatusOK}
next.ServeHTTP(recorder, r)
h.logger.Info("http request", "method", r.Method, "path", r.URL.Path, "status", recorder.status, "duration_ms", time.Since(start).Milliseconds())
})
}
Comment on lines +57 to +62
func (h *Handler) createScan(w http.ResponseWriter, r *http.Request) {
var request createScanRequest
decoder := json.NewDecoder(r.Body)
decoder.DisallowUnknownFields()
if err := decoder.Decode(&request); err != nil {
writeError(w, http.StatusBadRequest, "invalid JSON request")
Comment on lines +61 to +65
if err := decoder.Decode(&request); err != nil {
writeError(w, http.StatusBadRequest, "invalid JSON request")
return
}
request.Target = strings.TrimSpace(request.Target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scan Service: scaffold + storage

2 participants