Script Management API Documentation
Base Path
/scripts
Endpoints
Get Scripts List
Query Parameters
{
path?: string // Script path
}
Notes
- Excludes blacklisted folders (node_modules, .git, etc.)
- Directories are sorted first
Get Script Details
Query Parameters
{
path?: string, // Script path
file: string // File name
}
Upload/Create Script
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
Request Body
{
filename: string, // File name
path?: string, // File path
content: string // File content
}
Delete Script
Request Body
{
filename: string, // File name
path?: string, // File path
type?: string // Type
}
Download Script
Request Body
{
filename: string, // File name
path?: string, // File path
}
Run Script
Request Body
{
filename: string, // File name
content?: string, // File content
path?: string // File path
}
This endpoint debugs the supplied content by writing and executing a temporary file in the same directory (for example, demo.swap.js for demo.js). Omitting content writes an empty file; it does not read the original script. To run a saved cron task, use PUT /open/crons/run in the Crontab API.
Stop Script
Request Body
{
filename: string, // File name
path?: string, // File path
pid?: number // Process ID
}
Rename Script
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
Retired endpoint
GET /open/scripts/:file returns API code 410. Use GET /open/scripts/detail with file and optional path instead.