mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
feat: add new API for recording executed commands
- Add the `jsonwebtoken` dependency to the server's `package.json` - Add a new file `commandController.js` to the server's API controllers - Add a new route `/commands` to the server's API routes - Add a new file `commands.js` to the server's API routes - Modify the `index.js` file in the server's API routes to import and use the `commands.js` route - Add a `newCommand` function to the `commandController.js` file - Add a `Command` model to the `command.js` file in the server's models - Add the `genSessionJWT` and `verifySessionJWT` functions to the `auth.js` file in the server's utils - Modify the `attachContainer` function in the `docker.js` file in the server's utils to include a `token` parameter - Modify the `swagger.yaml` file to include a new route `/commands` for recording executed commands in a session Signed-off-by: wancat <wancat@wancat.cc>
This commit is contained in:
1 parent
fe3f4ddc73
commit
3cea54ce71
11 files changed
+194
-6
No files matched your search
@@ -291,6 +291,24 @@ paths:
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
|
||||
/commands:
|
||||
post:
|
||||
summary: Record a command that was executed in a session
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Command'
|
||||
responses:
|
||||
'201':
|
||||
description: Command recorded successfully
|
||||
'400':
|
||||
description: Invalid request body
|
||||
'401':
|
||||
description: Unauthorized
|
||||
|
||||
components:
|
||||
schemas:
|
||||
User:
|
||||
@@ -422,6 +440,28 @@ components:
|
||||
source:
|
||||
type: string
|
||||
|
||||
Command:
|
||||
type: object
|
||||
required:
|
||||
- token
|
||||
- pwd
|
||||
- command
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: The JWT token of the session
|
||||
pwd:
|
||||
type: string
|
||||
example: '/root'
|
||||
description: The current working directory
|
||||
command:
|
||||
type: string
|
||||
example: 'ls -al /'
|
||||
description: The command that was executed
|
||||
output:
|
||||
type: string
|
||||
description: The output of the command
|
||||
|
||||
securitySchemes:
|
||||
BearerAuth:
|
||||
type: http
|
||||
|
||||
Reference in new issue
Block a user