memos/web
Claude 133695da24
refactor(api): standardize API structure per Google AIP
This commit addresses API design inconsistencies identified during
standardization review against Google AIP (API Improvement Proposals)
and REST API best practices.

## Changes Made

### 1. WorkspaceSetting Resource Namespace (proto)
- Fixed: `api.memos.dev/WorkspaceSetting` → `memos.api.v1/WorkspaceSetting`
- Location: proto/api/v1/workspace_service.proto (lines 57, 181)
- Impact: Aligns with consistent namespace pattern used across all other resources

### 2. Identity Provider HTTP Paths (proto)
- Changed: `/api/v1/identityProviders` → `/api/v1/identity-providers`
- Changed: `identityProviders/{idp}` → `identity-providers/{idp}`
- Location: proto/api/v1/idp_service.proto (all HTTP annotations and resource pattern)
- Rationale: REST conventions prefer lowercase with hyphens (kebab-case) over camelCase
- Follows: GitHub API standards and industry best practices

### 3. Backend Resource Name Constants (Go)
- Updated: `IdentityProviderNamePrefix = "identity-providers/"`
- Location: server/router/api/v1/resource_name.go:19
- Impact: Ensures resource name parsing matches new proto pattern

### 4. Backend Tests (Go)
- Updated all hardcoded identity provider resource names
- Location: server/router/api/v1/test/idp_service_test.go
- Changed: `identityProviders/*` → `identity-providers/*` (4 occurrences)

### 5. Frontend Constants (TypeScript)
- Updated: `identityProviderNamePrefix = "identity-providers/"`
- Location: web/src/store/common.ts:4
- Impact: Frontend resource name handling aligns with backend

## Breaking Changes

⚠️ **IMPORTANT**: This is a breaking change for Identity Provider API consumers.

**Before:**
```
GET /api/v1/identityProviders
GET /api/v1/identityProviders/123
```

**After:**
```
GET /api/v1/identity-providers
GET /api/v1/identity-providers/123
```

**Migration:** API clients must update URLs from `identityProviders` to `identity-providers`.

## Next Steps Required

1. **Regenerate proto code** (requires buf CLI):
   ```bash
   cd proto
   buf generate
   ```
   This will update:
   - proto/gen/api/v1/*.pb.go (Go generated code)
   - proto/gen/api/v1/*.pb.gw.go (gRPC-Gateway code)
   - web/src/types/proto/api/v1/*.ts (TypeScript definitions)
   - proto/gen/openapi.yaml (OpenAPI spec)

2. **Test thoroughly:**
   - Backend tests: `go test ./server/router/api/v1/test/...`
   - Frontend integration tests
   - Manual API testing with new paths

3. **Update documentation:**
   - API documentation mentioning identity provider endpoints
   - Migration guides for existing API consumers

## References
- Google AIP-122: Resource names
- Google AIP-132: Standard List methods
- REST API naming conventions (lowercase with hyphens)
- GitHub API design standards

## Binary Endpoint Design (No Changes)
After research, confirmed that the current `/file/*` path for binary content
is correct and follows best practices:
- Separates binary content delivery from structured API responses
- Enables easier CDN integration and caching
- Follows Google's pattern of using google.api.HttpBody with distinct paths
2025-11-05 08:33:00 +00:00
..
public chore: enhance site.webmanifest in firefox (#4828) 2025-07-08 19:56:46 +08:00
src refactor(api): standardize API structure per Google AIP 2025-11-05 08:33:00 +00:00
.gitignore chore: update gitignore 2025-04-17 23:11:36 +08:00
.prettierrc.js chore: fix linter 2025-03-02 15:40:16 +08:00
MARKDOWN_STYLE_GUIDE.md chore: remove unused syntax 2025-10-27 08:31:57 +08:00
README.md chore: tweak readme 2024-02-23 08:25:54 +08:00
components.json feat: themes (#4824) 2025-07-07 20:13:22 +08:00
eslint.config.mjs refactor: migrate eslint 2025-04-01 00:04:43 +08:00
index.html chore: remove fixed theme color 2025-07-15 23:26:07 +08:00
package.json chore: remove unused syntax 2025-10-27 08:31:57 +08:00
pnpm-lock.yaml chore: remove unused syntax 2025-10-27 08:31:57 +08:00
tsconfig.json refactor: update import prefix with alias (#1433) 2023-04-01 16:03:14 +08:00
vite.config.mts refactor: update markdown parser 2025-10-26 11:28:40 +08:00

README.md

The frontend of Memos