AGENTS.md
internal/api/AGENTS.mdAGENTS.md
Quality
62/100
Scores the file, not the repository.Length
290 words
4 headings · 0 code blocksRepository
40k
— · pushed 0 days agoLast changed
2 days ago
First indexed 2 days ago.1# API Guidelines23**Last Updated:** April 9, 202645## Handler Conventions67- Reuse limiter stacks such as `limiter.Auth` and `limiter.Login`, and use `limiter.AbortJSON` for `429` responses.8- Lean on `api.ClientIP`, `header.BearerToken`, and the shared `Abort*` helpers instead of duplicating request parsing.9- Compare secrets in constant time and set `Cache-Control: no-store` on sensitive responses.10- Register routes in `internal/server/routes.go`.11- New list endpoints should default to `count=100`, cap at `1000`, require `offset >= 0`, and document their parameters explicitly.12- When a test or fixture needs portal mode, set `PHOTOPRISM_NODE_ROLE=portal` together with `PHOTOPRISM_JOIN_TOKEN`.1314## Roles, Scopes & Sessions1516- Map user roles through `acl.ParseRole(s)` and `acl.UserRoles[...]`; map client roles through `acl.ClientRoles[...]`.17- Treat `RoleAliasNone` (`none`) and the empty string as `RoleNone`; default unknown client roles to `RoleClient`.18- When checking JWT or client scopes, use `acl.ScopePermits` and `acl.ScopeAttrPermits` instead of handwritten parsing.19- Use `AuthenticateAdmin`, `AuthenticateUser`, or `OAuthToken` helpers in tests rather than building auth flows manually.20- Build client-session requests with `entity.AddClientSession(..., authn.GrantClientCredentials, nil)` and `AuthenticatedRequest(...)`.21- Admin sessions may see `AdvertiseUrl` and `Database`; client and user sessions must not. `SiteUrl` and the client `storageNamespace` derived from it are safe to expose.2223## Swagger & API Tests2425- Annotate only routed handlers in `internal/api/*.go`; use full `/api/v1/...` paths and skip helper functions.26- Regenerate API docs with `make fmt-go swag-fmt swag` or `make swag-json`; `make swag` may fetch modules, so confirm network access first.27- While iterating, prefer focused runs such as `go test ./internal/api -run Cluster -count=1`.28- Isolate config paths with `t.TempDir()` and reuse `NewConfig`, `CliTestContext`, and `NewApiTest()` helpers.29- For negative permission checks, prefer OAuth client tokens over non-admin user fixtures.30- Register `CreateSession(router)` only once per test router; a second registration panics on duplicate routes.3132
Also in photoprism/photoprism
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| photoprism/photoprisminternal/config/AGENTS.md · 40k | AGENTS.md | databasedo-not | 46/100 | 2 days ago | |
| photoprism/photoprisminternal/entity/migrate/AGENTS.md · 40k | AGENTS.md | testtesting-strategydatabase | 63/100 | 2 days ago | |
| photoprism/photoprisminternal/photoprism/AGENTS.md · 40k | AGENTS.md | no sections | 39/100 | 2 days ago | |
| photoprism/photoprisminternal/service/cluster/AGENTS.md · 40k | AGENTS.md | buildtestapi | 76/100 | 2 days ago | |
| photoprism/photoprismpkg/AGENTS.md · 40k | AGENTS.md | teststylesecurity | 55/100 | 2 days ago | |
| photoprism/photoprisminternal/commands/AGENTS.md · 40k | AGENTS.md | teststyle | 66/100 | 2 days ago | |
| photoprism/photoprism.claude/CLAUDE.md · 40k | CLAUDE.md | buildtestlint-formatstyle+7 | 96/100 | 2 days ago | |
| photoprism/photoprism.github/copilot-instructions.md · 40k | Copilot instructions | buildtestlint-formatstyle+5 | 90/100 | 2 days ago | |
| photoprism/photoprism.github/instructions/backend.instructions.md · 40k | Copilot instructions | testlint-formatstyletypes+4 | 83/100 | 2 days ago | |
| photoprism/photoprism.github/instructions/frontend.instructions.md · 40k | Copilot instructions | testlint-formatstyleagent-behaviour | 76/100 | 2 days ago | |
| photoprism/photoprismAGENTS.md · 40k | AGENTS.md | setupbuildtestlint-format+8 | 82/100 | 2 days ago | |
| photoprism/photoprismfrontend/AGENTS.md · 40k | AGENTS.md | setupteststyletesting-strategy+1 | 76/100 | 2 days ago | |
| photoprism/photoprisminternal/AGENTS.md · 40k | AGENTS.md | teststyletesting-strategy | 71/100 | 2 days ago |
Diff against internal/config/AGENTS.md Diff against internal/entity/migrate/AGENTS.md Diff against internal/photoprism/AGENTS.md Diff against internal/service/cluster/AGENTS.md Diff against pkg/AGENTS.md Diff against internal/commands/AGENTS.md Diff against .claude/CLAUDE.md Diff against .github/copilot-instructions.md Diff against .github/instructions/backend.instructions.md Diff against .github/instructions/frontend.instructions.md Diff against AGENTS.md Diff against frontend/AGENTS.md Diff against internal/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| trick77/agents-md-syncAGENTS.md · 2 | AGENTS.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| ethereum/go-ethereumAGENTS.md · 51k | AGENTS.md | buildtestlint-formatgit+1 | 100/100 | 3 days ago |
