Skip to content

code push api modifications#14

Merged
ankitpunchh merged 1 commit into
mainfrom
CX-3011
May 13, 2026
Merged

code push api modifications#14
ankitpunchh merged 1 commit into
mainfrom
CX-3011

Conversation

@kshitij-partech
Copy link
Copy Markdown
Collaborator

@kshitij-partech kshitij-partech commented Apr 27, 2026

This pull request introduces several important improvements to the bundle management and deployment APIs, focusing on enhanced bundle upload validation, new endpoints for listing bundles, and improved API responses. The most significant changes are grouped below by theme:

Bundle Upload Improvements:

  • Enforced a maximum bundle upload size of 50 MB in the UploadBundle handler, with appropriate error responses for oversized files. The upload logic now reads only up to the allowed limit and responds with clear messages if exceeded. (request/app.go) [1] [2]
  • Improved file handling and download URL generation for uploaded bundles, supporting local, AWS S3, and FTP storage backends. The response now includes the file name and a direct download URL. (request/app.go)

API Enhancements:

  • Added a new lsBundle endpoint (and corresponding handler) to list the three most recent deployment versions (bundles) for a given app and deployment, including their metadata and current package details. (main.go, request/app.go, model/deploymentVersion.go) [1] [2] [3]
  • The CreateBundle API now accepts an optional mandatory field and returns it in the response, allowing clients to specify and receive information about mandatory updates. (request/app.go) [1] [2]

General API Response Improvements:

  • The LsApp endpoint now returns structured app information (including AppName and OS) instead of just app names. (request/app.go)
  • The CreateDeployment API now allows an optional custom deployment key and returns the actual key used, improving flexibility and clarity for clients. (request/app.go) [1] [2] [3]

These changes collectively enhance the robustness, usability, and clarity of the codepush server's bundle and deployment management APIs.

@kvlad-par
Copy link
Copy Markdown

kvlad-par commented Apr 27, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@ankitpunchh ankitpunchh merged commit 81904b4 into main May 13, 2026
7 checks passed
@ankitpunchh ankitpunchh deleted the CX-3011 branch May 13, 2026 04:58
Copy link
Copy Markdown

Copilot AI left a comment

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 modifies the CodePush server API to expand bundle/deployment management functionality and to improve bundle upload responses and validation.

Changes:

  • Add /lsBundle endpoint to list recent deployment versions (with current package details when present).
  • Enhance /uploadBundle with size limiting and returning fileName + a derived downloadUrl.
  • Allow optional caller-supplied deployment keys in /createDeployment, and adjust /lsApp response shape.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
request/app.go Adds bundle listing endpoint, changes upload bundle behavior/response, allows optional deployment key, adjusts app listing payload
model/deploymentVersion.go Adds query helper to list latest deployment versions
main.go Registers new authenticated route /lsBundle

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread request/app.go
Comment on lines +242 to 244
if err := os.WriteFile(path.Clean(cfg.CodePush.Local.SavePath+"/"+key), data, 0777); err != nil {
log.Panic(err.Error())
}
Comment thread request/app.go
Comment on lines +289 to +301
downloadURL := ""
if ru := strings.TrimSpace(cfg.ResourceUrl); ru != "" {
downloadURL = strings.TrimSuffix(ru, "/") + "/" + url.PathEscape(fileName)
} else {
switch cfg.CodePush.FileLocal {
case "aws":
a := cfg.CodePush.Aws
ep := strings.TrimSuffix(strings.TrimSpace(a.Endpoint), "/")
if a.S3ForcePathStyle || strings.HasPrefix(ep, "http://") || strings.HasPrefix(ep, "https://") {
downloadURL = fmt.Sprintf("%s/%s/%s", ep, a.Bucket, url.PathEscape(fileName))
} else {
downloadURL = fmt.Sprintf("https://%s.s3.%s.amazonaws.com/%s", a.Bucket, a.Region, url.PathEscape(fileName))
}
Comment thread request/app.go
Comment on lines +170 to +178
if createDeploymentInfo.Key == nil || *createDeploymentInfo.Key == "" {
uuid, _ := uuid.NewUUID()
uuidStr := uuid.String()
createDeploymentInfo.Key = &uuidStr
}
newDeployment := model.Deployment{
AppId: app.Id,
Name: createDeploymentInfo.DeploymentName,
Key: &key,
Key: createDeploymentInfo.Key,
Limit(limit).
Find(&rows).Error
if err != nil {
return []DeploymentVersion{}
Comment thread request/app.go
Comment on lines +83 to +86
mandatory := false
if createBundleReq.Mandatory != nil {
mandatory = *createBundleReq.Mandatory
}
Comment thread request/app.go
Comment on lines 194 to 195
_, headers, err := ctx.Request.FormFile("file")
if err != nil {
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.

4 participants