Skip to main content
GET
/
api
/
projects
/
:id
/
settings
Project Settings
curl --request GET \
  --url https://api.example.com/api/projects/:id/settings \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "repoBranchName": "<string>",
  "folder": {
    "enabled": true,
    "name": "<string>"
  },
  "buildCommand": "<string>",
  "publishDir": "<string>",
  "startCommand": "<string>",
  "port": 123,
  "env": {}
}
'
{
  "success": true,
  "project": {
    "_id": "<string>",
    "name": "<string>",
    "projectType": "<string>",
    "settings": {
      "repoBranchName": "<string>",
      "folder": {
        "enabled": true,
        "name": "<string>"
      }
    },
    "buildCommand": {},
    "publishDir": {},
    "startCommand": {},
    "port": {},
    "env": {},
    "createdAt": "<string>"
  }
}

Get Project Settings

id
string
required
The unique identifier of the project (MongoDB ObjectId)

Authentication

Requires JWT authentication via the verifyJWT middleware.

Response

success
boolean
required
Indicates whether the request was successful
project
object
required
Project settings data

Example Request

curl -X GET "https://api.deployhub.online/api/projects/65f3a2b1c4d5e6f7g8h9i0j1/settings" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "success": true,
  "project": {
    "_id": "65f3a2b1c4d5e6f7g8h9i0j1",
    "name": "my-react-app",
    "projectType": "static",
    "settings": {
      "repoBranchName": "main",
      "folder": {
        "enabled": false,
        "name": ""
      }
    },
    "buildCommand": "npm run build",
    "publishDir": "dist",
    "env": {
      "VITE_API_URL": "https://api.example.com",
      "VITE_ENV": "production"
    },
    "createdAt": "2024-03-15T10:30:00.000Z"
  }
}

Update General Settings

Update project name, branch, and folder settings.

Path Parameters

id
string
required
The unique identifier of the project

Request Body

name
string
New project name (will be trimmed)
repoBranchName
string
Git branch to deploy from (will be trimmed)
folder
object
Subfolder configuration

Validation Rules

  • name must not be empty after trimming
  • repoBranchName will be trimmed if provided
  • If folder.enabled is true, folder.name is required and validated by the model
  • If folder.enabled is false, folder.name is set to empty string

Example Request

curl -X PATCH "https://api.deployhub.online/api/projects/65f3a2b1c4d5e6f7g8h9i0j1/settings/general" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-updated-app",
    "repoBranchName": "production",
    "folder": {
      "enabled": true,
      "name": "client"
    }
  }'

Example Response

{
  "success": true,
  "project": {
    "_id": "65f3a2b1c4d5e6f7g8h9i0j1",
    "name": "my-updated-app",
    "settings": {
      "repoBranchName": "production",
      "folder": {
        "enabled": true,
        "name": "client"
      }
    }
  }
}

Update Build Settings

Update build and deployment configuration.

Path Parameters

id
string
required
The unique identifier of the project

Request Body

buildCommand
string
Command to build the project. Can be empty string to clear.
publishDir
string
Output directory for static sites. Can be empty string to clear.
startCommand
string
Start command for Node.js projects. Can be empty string to clear.
port
number
Port number for Node.js projects. Set to null/undefined to clear.

Example Request (Static Site)

curl -X PATCH "https://api.deployhub.online/api/projects/65f3a2b1c4d5e6f7g8h9i0j1/settings/build" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "buildCommand": "npm run build",
    "publishDir": "dist"
  }'

Example Request (Node.js App)

curl -X PATCH "https://api.deployhub.online/api/projects/65f3a2b1c4d5e6f7g8h9i0j1/settings/build" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "buildCommand": "npm install",
    "startCommand": "node server.js",
    "port": 3000
  }'

Example Response

{
  "success": true,
  "project": {
    "_id": "65f3a2b1c4d5e6f7g8h9i0j1",
    "buildCommand": "npm install",
    "publishDir": null,
    "startCommand": "node server.js",
    "port": 3000
  }
}

Update Environment Variables

Update project environment variables. This replaces all existing environment variables.

Path Parameters

id
string
required
The unique identifier of the project

Request Body

env
object
required
Key-value pairs of environment variables. All values must be strings.

Validation Rules

  • env must be a plain object (not an array)
  • Environment variable keys cannot be empty or whitespace-only
  • All keys are trimmed and validated
  • Passing an empty object {} will clear all environment variables

Example Request

curl -X PATCH "https://api.deployhub.online/api/projects/65f3a2b1c4d5e6f7g8h9i0j1/settings/env" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "env": {
      "NODE_ENV": "production",
      "API_URL": "https://api.example.com",
      "DATABASE_URL": "postgresql://...",
      "SECRET_KEY": "your-secret-key"
    }
  }'

Example Response

{
  "success": true
}

Error Response (Invalid Key)

{
  "success": false,
  "message": "Empty env key not allowed"
}

Error Response (Invalid Type)

{
  "success": false,
  "message": "env must be a key-value object"
}

Common Error Responses

404 Not Found
Returned when:
  • Project with the specified ID doesn’t exist
  • Project doesn’t belong to the authenticated user
  • Project has been deleted
{
  "success": false,
  "message": "Project not found"
}
500 Internal Server Error
Returned when a server error occurs
{
  "success": false,
  "message": "Server error"
}

Implementation Notes

General Settings Update

  • Uses findOneAndUpdate with runValidators: true and context: 'query'
  • Only updates fields that are provided in the request body
  • Folder name validation is enforced by the Mongoose schema
  • Returns updated name and settings fields only

Build Settings Update

  • Accepts undefined to skip updating a field
  • Port is parsed as integer if provided
  • Returns only the updated build-related fields

Environment Variables Update

  • Stores environment variables as a MongoDB Map internally
  • Completely replaces existing environment variables
  • Keys are validated to prevent empty strings
  • Does not return the environment variables in the response (for security)

Source Reference

  • GET: backend/src/controllers/slices/Project/settings.js:4
  • PATCH general: backend/src/controllers/slices/Project/settings.js:36
  • PATCH build: backend/src/controllers/slices/Project/settings.js:70
  • PATCH env: backend/src/controllers/slices/Project/settings.js:96