Skip to content

Conversation

@nonhana
Copy link
Owner

@nonhana nonhana commented Jan 23, 2026

Note

Upgrade API versioning and centralize platform concerns

  • Prisma schema: add APIVersion.revision (unique with apiId), make version nullable; regenerate client/types and queries accordingly
  • Version flow: drafts auto-increment revision; version set only on publish via new PublishVersionReqDto; rollback now creates a draft; VersionController requires api:publish
  • System config: introduce SystemConfigModule; enforce PROJECT_MAX_APIS and API_MAX_REVISIONS (cleanup oldest archived versions); register flow gated by REGISTER_ENABLED and optional email verification
  • Shared package: replace local enums/constants (roles/permissions/errors) with @apiplayer/shared; rework HanaException, global exception filter, guards, and interceptors to new {status, code, message} error shape
  • Auth & DTOs: registration supports email code, returns UserDetailInfoDto; login/DTOs updated; guards use IS_PUBLIC_KEY; user DTO fields adjusted
  • Seed & wiring: RBAC/system-config seed sources shared metadata; wire SystemConfigModule/EmailCodeModule; minor ESLint/package updates; backend version bump

Risk

  • High: DB migration required; breaking changes to error payloads, permissions (api:publish), and versioning semantics; ensure system config keys/seed data exist and publish/build flow still has tsdown available.

Written by Cursor Bugbot for commit c5e20b4. This will update automatically on new commits. Configure here.

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for apiplayer ready!

Name Link
🔨 Latest commit c5e20b4
🔍 Latest deploy log https://app.netlify.com/projects/apiplayer/deploys/69733fa371b8d900080721b3
😎 Deploy Preview https://deploy-preview-1--apiplayer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

{
"name": "@apiplayer/backend",
"version": "0.0.1",
"version": "0.0.2",
Copy link

Choose a reason for hiding this comment

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

Missing build dependency causes build failure

High Severity

The build script references tsdown on line 7, but the tsdown package was removed from devDependencies. Running npm run build will fail with a "command not found" error, breaking the build process entirely.

Additional Locations (1)

Fix in Cursor Fix in Web

await tx.aPIVersion.deleteMany({
where: { id: { in: oldestVersions.map(v => v.id) } },
})
}
Copy link

Choose a reason for hiding this comment

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

Old version not archived during API update

Medium Severity

When updating an API, the code switches currentVersionId to the new DRAFT version but never archives the previous version. This causes old versions to accumulate without proper status management, and the version cleanup logic only deletes ARCHIVED versions, leaving orphaned CURRENT/DRAFT versions.

Fix in Cursor Fix in Web

await tx.aPIVersion.deleteMany({
where: { id: { in: oldestVersions.map(v => v.id) } },
})
}
Copy link

Choose a reason for hiding this comment

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

Version cleanup fails to enforce revision limit

Medium Severity

The version cleanup logic counts all versions but only deletes ARCHIVED versions. When total versions exceed maxRevisions but insufficient ARCHIVED versions exist, the cleanup deletes fewer versions than needed, failing to enforce the limit. For example, with 15 total versions, limit of 10, but only 3 ARCHIVED, it deletes 3 leaving 12 versions still exceeding the limit.

Additional Locations (1)

Fix in Cursor Fix in Web

if (!targetVersion) {
throw new HanaException('目标版本不存在', ErrorCode.API_VERSION_NOT_FOUND, 404)
throw new HanaException('API_VERSION_NOT_FOUND')
}
Copy link

Choose a reason for hiding this comment

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

Missing snapshot validation in version publish

Medium Severity

The publishVersion method validates the version exists but doesn't check if its snapshot exists before using it. Unlike rollbackToVersion which explicitly validates snapshot presence and throws an error if missing, publishVersion proceeds without this check. If a version lacks a snapshot, publishing succeeds but leaves the API in an inconsistent state where snapshot data isn't synced to the main API table.

Fix in Cursor Fix in Web

@nonhana nonhana self-assigned this Jan 23, 2026
@nonhana nonhana merged commit dd2f56a into main Jan 23, 2026
12 checks passed
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.

2 participants