Script Management API Documentation

Base Path

/scripts

Endpoints

Get Scripts List

GET /

Query Parameters

{
  path?: string  // Script path
}

Notes

  • Excludes blacklisted folders (node_modules, .git, etc.)
  • Directories are sorted first

Get Script Details

GET /detail

Query Parameters

{
  path?: string,  // Script path
  file: string    // File name
}

Upload/Create Script

POST /

Request Body (multipart/form-data)

{
  file?: File,           // Uploaded file
  filename: string,      // File name
  path?: string,         // File path
  content?: string,      // File content
  originFilename?: string, // Original file name
  directory?: string     // Directory name (for creating directories)
}

Update Script Content

PUT /

Request Body

{
  filename: string,  // File name
  path?: string,    // File path
  content: string   // File content
}

Delete Script

DELETE /

Request Body

{
  filename: string,  // File name
  path?: string,    // File path
  type?: string     // Type
}

Download Script

POST /download

Request Body

{
  filename: string  // File name
}

Run Script

PUT /run

Request Body

{
  filename: string,  // File name
  content?: string, // File content
  path?: string    // File path
}

Stop Script

PUT /stop

Request Body

{
  filename: string,  // File name
  path?: string,    // File path
  pid?: number      // Process ID
}

Rename Script

PUT /rename

Request Body

{
  filename: string,    // Original file name
  path?: string,      // File path
  newFilename: string // New file name
}

Error Handling

  • All endpoints follow unified error handling mechanism
  • Successful responses return { code: 200, data: ... }
  • Error logging is handled by Winston logger

Notes

  • File uploads handled by multer
  • File path security checks
  • Supports file backup
  • Automatic temporary file cleanup