chore: initialize qiming workspace repository
This commit is contained in:
58
qiming-file-server/src/config/swagger.js
Normal file
58
qiming-file-server/src/config/swagger.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import swaggerJsdoc from "swagger-jsdoc";
|
||||
import config from "../appConfig/index.js";
|
||||
|
||||
const options = {
|
||||
definition: {
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
title: "Application Builder API",
|
||||
version: "1.0.0",
|
||||
description: "Application builder API documentation",
|
||||
contact: {
|
||||
name: "API Support",
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: `http://localhost:${config.PORT}`,
|
||||
description: `${config.NODE_ENV} environment`,
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
{ name: "Build", description: "Build related interfaces" },
|
||||
{ name: "Project", description: "Project management interfaces" },
|
||||
{ name: "Code", description: "Code submission interfaces" },
|
||||
],
|
||||
components: {
|
||||
schemas: {
|
||||
Error: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: false },
|
||||
error: {
|
||||
type: "object",
|
||||
properties: {
|
||||
type: { type: "string", example: "VALIDATION_ERROR" },
|
||||
message: { type: "string", example: "Project ID cannot be empty" },
|
||||
timestamp: { type: "string", format: "date-time" },
|
||||
requestId: { type: "string" },
|
||||
details: { type: "object" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Success: {
|
||||
type: "object",
|
||||
properties: {
|
||||
success: { type: "boolean", example: true },
|
||||
message: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
apis: ["./src/config/swagger/*.js"],
|
||||
};
|
||||
|
||||
const specs = swaggerJsdoc(options);
|
||||
export default specs;
|
||||
222
qiming-file-server/src/config/swagger/buildDocs.js
Normal file
222
qiming-file-server/src/config/swagger/buildDocs.js
Normal file
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Build
|
||||
* description: Build and dev server management APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/build/start-dev:
|
||||
* get:
|
||||
* summary: Start the dev server
|
||||
* tags: [Build]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* - in: query
|
||||
* name: basePath
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Base path (Vite projects only)
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Dev server started
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectId:
|
||||
* type: string
|
||||
* pid:
|
||||
* type: number
|
||||
* port:
|
||||
* type: number
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/build/build:
|
||||
* get:
|
||||
* summary: Build the project
|
||||
* tags: [Build]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* - in: query
|
||||
* name: basePath
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Base path (Vite projects only)
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Build successful
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectId:
|
||||
* type: string
|
||||
* 400:
|
||||
* description: Invalid parameters or max concurrency reached
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/build/stop-dev:
|
||||
* get:
|
||||
* summary: Stop the dev server
|
||||
* tags: [Build]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* - in: query
|
||||
* name: pid
|
||||
* required: true
|
||||
* schema:
|
||||
* type: number
|
||||
* description: Process ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Dev server stopped
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectId:
|
||||
* type: string
|
||||
* pid:
|
||||
* type: number
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/build/restart-dev:
|
||||
* get:
|
||||
* summary: Restart the dev server
|
||||
* tags: [Build]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* - in: query
|
||||
* name: pid
|
||||
* schema:
|
||||
* type: number
|
||||
* description: Process ID (optional)
|
||||
* - in: query
|
||||
* name: basePath
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Base path (Vite projects only)
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Dev server restarted
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/build/list-dev:
|
||||
* get:
|
||||
* summary: List running dev servers
|
||||
* tags: [Build]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: List retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* list:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* pid:
|
||||
* type: number
|
||||
* port:
|
||||
* type: number
|
||||
* startedAt:
|
||||
* type: number
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/build/parse-build-error:
|
||||
* post:
|
||||
* summary: Parse build error output
|
||||
* tags: [Build]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - projectId
|
||||
* - errorMessage
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* errorMessage:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Parsed successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
*/
|
||||
|
||||
export default {};
|
||||
134
qiming-file-server/src/config/swagger/codeDocs.js
Normal file
134
qiming-file-server/src/config/swagger/codeDocs.js
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Code
|
||||
* description: Code file management APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/submit-files-update:
|
||||
* post:
|
||||
* summary: Submit file updates and restart the dev server
|
||||
* tags: [Code]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - projectId
|
||||
* - codeVersion
|
||||
* - files
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* codeVersion:
|
||||
* type: string
|
||||
* description: Code version
|
||||
* files:
|
||||
* type: array
|
||||
* description: Files to update
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* contents:
|
||||
* type: string
|
||||
* binary:
|
||||
* type: boolean
|
||||
* sizeExceeded:
|
||||
* type: boolean
|
||||
* basePath:
|
||||
* type: string
|
||||
* description: Base path (optional)
|
||||
* pid:
|
||||
* type: number
|
||||
* description: Process ID (optional)
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Submitted successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectId:
|
||||
* type: string
|
||||
* pid:
|
||||
* type: number
|
||||
* port:
|
||||
* type: number
|
||||
* restarted:
|
||||
* type: boolean
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/upload-single-file:
|
||||
* post:
|
||||
* summary: Upload a single file
|
||||
* tags: [Code]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* multipart/form-data:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - projectId
|
||||
* - codeVersion
|
||||
* - file
|
||||
* - filePath
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* codeVersion:
|
||||
* type: string
|
||||
* description: Code version
|
||||
* filePath:
|
||||
* type: string
|
||||
* description: Relative path of the file inside the project
|
||||
* file:
|
||||
* type: string
|
||||
* format: binary
|
||||
* description: File contents
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Upload successful
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectId:
|
||||
* type: string
|
||||
* restarted:
|
||||
* type: boolean
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
export default {};
|
||||
267
qiming-file-server/src/config/swagger/projectDocs.js
Normal file
267
qiming-file-server/src/config/swagger/projectDocs.js
Normal file
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Project
|
||||
* description: Project management APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/create-project:
|
||||
* post:
|
||||
* summary: Create a new project
|
||||
* tags: [Project]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - projectId
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Project created successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectPath:
|
||||
* type: string
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/upload-start-dev:
|
||||
* post:
|
||||
* summary: Upload project archive and start the dev server
|
||||
* tags: [Project]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* multipart/form-data:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - projectId
|
||||
* - file
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* file:
|
||||
* type: string
|
||||
* format: binary
|
||||
* description: Project archive (.zip)
|
||||
* basePath:
|
||||
* type: string
|
||||
* description: Base path (Vite projects only)
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Uploaded and dev server started
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* projectId:
|
||||
* type: string
|
||||
* pid:
|
||||
* type: number
|
||||
* port:
|
||||
* type: number
|
||||
* 400:
|
||||
* description: Invalid parameters or file format
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/get-project-content:
|
||||
* get:
|
||||
* summary: Get project content
|
||||
* tags: [Project]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Project content retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* files:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* contents:
|
||||
* type: string
|
||||
* binary:
|
||||
* type: boolean
|
||||
* sizeExceeded:
|
||||
* type: boolean
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/backup-current-version:
|
||||
* post:
|
||||
* summary: Backup the current version
|
||||
* tags: [Project]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - projectId
|
||||
* - codeVersion
|
||||
* properties:
|
||||
* projectId:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* codeVersion:
|
||||
* type: string
|
||||
* description: Code version
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Backup successful
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* zipPath:
|
||||
* type: string
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/export-project:
|
||||
* get:
|
||||
* summary: Export project as a ZIP archive
|
||||
* tags: [Project]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Project ZIP file download
|
||||
* content:
|
||||
* application/zip:
|
||||
* schema:
|
||||
* type: string
|
||||
* format: binary
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/project/get-project-content-by-version:
|
||||
* get:
|
||||
* summary: Get project content for a specific version
|
||||
* tags: [Project]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: projectId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Project ID
|
||||
* - in: query
|
||||
* name: codeVersion
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Code version
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Project content retrieved successfully
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* files:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* contents:
|
||||
* type: string
|
||||
* binary:
|
||||
* type: boolean
|
||||
* sizeExceeded:
|
||||
* type: boolean
|
||||
* 400:
|
||||
* description: Invalid parameters
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
export default {};
|
||||
Reference in New Issue
Block a user