Laravel Forge JavaScript SDK

Site Commands

Site Commands

Execute a command

Method

forge.commands.execute(server_id, site_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.commands.execute(server_id, site_id, payload);

Payload

1{
2 command: 'ls -la';
3}

Payload Parameters

KeyDescription
commandCommand to be run.

List command history

Method

forge.commands.list(server_id, site_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.commands.list(server_id, site_id);

Example Response

1{
2 "commands": [
3 {
4 "id": 68,
5 "server_id": 34,
6 "site_id": 48,
7 "user_id": 1,
8 "event_id": 730,
9 "command": "ls -lah",
10 "status": "finished",
11 "created_at": "2021-04-16 14:46:55",
12 "updated_at": "2021-04-16 14:47:00",
13 "profile_photo_url": "https://unavatar.vercel.app/james%40brooks.page?fallback=https%3A%2F%2Fui-avatars.com%2Fapi%3Fname%3DJames%2BBrooks%26color%3D7F9CF4%26background%3DEBF4FF",
14 "user_name": "James Brooks"
15 },
16 {
17 "id": 69,
18 "server_id": 34,
19 "site_id": 48,
20 "user_id": 1,
21 "event_id": 731,
22 "command": "echo 'Hello!'",
23 "status": "finished",
24 "created_at": "2021-04-16 14:48:01",
25 "updated_at": "2021-04-16 14:48:07",
26 "profile_photo_url": "https://unavatar.vercel.app/james%40brooks.page?fallback=https%3A%2F%2Fui-avatars.com%2Fapi%3Fname%3DJames%2BBrooks%26color%3D7F9CF4%26background%3DEBF4FF",
27 "user_name": "James Brooks"
28 }
29 ]
30}

Get a command by id

Method

forge.commands.get(server_id, site_id, command_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.commands.get(server_id, site_id, command_id);

Example Response

1{
2 "command": {
3 "id": 69,
4 "server_id": 34,
5 "site_id": 48,
6 "user_id": 1,
7 "event_id": 731,
8 "command": "echo 'Hello!'",
9 "status": "finished",
10 "created_at": "2021-04-16 14:48:01",
11 "updated_at": "2021-04-16 14:48:07",
12 "profile_photo_url": "https://unavatar.vercel.app/james%40brooks.page?fallback=https%3A%2F%2Fui-avatars.com%2Fapi%3Fname%3DJames%2BBrooks%26color%3D7F9CF4%26background%3DEBF4FF",
13 "user_name": "James Brooks"
14 },
15 "output": "Hello!"
16}

Edit this page on GitHub