writetainer-lib 25.12.27-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +29 -0
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/package.json +34 -0
package/.env
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# MongoDB
|
|
2
|
+
MONGODB_URI="mongodb://192.168.1.141:27017/mcserver"
|
|
3
|
+
JWT_SECRET="a7f3b9c2d8e4f6a1b0c5d7e9f2a3b8c4d6e1f0a9b7c3d5e8f4a2b6c9d0e7f1"
|
|
4
|
+
|
|
5
|
+
# Local server path
|
|
6
|
+
FOLDER_PATH="/mnt/nvme/minecraft/velocity-test"
|
|
7
|
+
|
|
8
|
+
# Portainer
|
|
9
|
+
PORTAINER_URL="https://192.168.1.141:2995"
|
|
10
|
+
PORTAINER_API_KEY="ptr_f6aqnnlc7ytZV43nKhfyVnPJgtH6EJ62ljpWh1CokWs="
|
|
11
|
+
|
|
12
|
+
# WebDAV Configuration (for file uploads)
|
|
13
|
+
WEBDAV_URL="https://192.168.1.141:30001"
|
|
14
|
+
WEBDAV_USERNAME=""
|
|
15
|
+
WEBDAV_PASSWORD=""
|
|
16
|
+
WEBDAV_SERVER_BASE_PATH="/minecraft/velocity-test"
|
|
17
|
+
|
|
18
|
+
# Minecraft Server Path
|
|
19
|
+
MINECRAFT_PATH="/mnt/nvme/minecraft/velocity-test"
|
|
20
|
+
|
|
21
|
+
# Enable/disable REST API request logging
|
|
22
|
+
LOG_API_REQUESTS=true
|
|
23
|
+
|
|
24
|
+
# Global console logging control
|
|
25
|
+
ENABLE_CONSOLE_LOGS=true
|
|
26
|
+
DISABLE_CONSOLE_COLORS=false
|
|
27
|
+
|
|
28
|
+
# Delete server folders
|
|
29
|
+
DELETE_SERVER_FOLDERS=true # If false, server folders will be renamed instead of deleted
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Erick Tran
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Writetainer-Lib
|
|
2
|
+
|
|
3
|
+
A Portainer API accessibility library for Node.js, written in TypeScript. This library provides a convenient wrapper around the Portainer API, allowing you to easily interact with your Portainer instance to manage environments, stacks, and containers.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Authentication**: Easy authentication using Portainer API tokens.
|
|
8
|
+
- **Environment Management**: Fetch details about your Portainer environments (endpoints).
|
|
9
|
+
- **Stack Management**: Retrieve information about your stacks.
|
|
10
|
+
- **Container Management**: List containers within an environment (proxies the Docker API).
|
|
11
|
+
- **TypeScript Support**: Fully typed interfaces for better development experience.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install writetainer-lib
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Initialization
|
|
22
|
+
|
|
23
|
+
First, import the `PortainerApiClient` and initialize it with your Portainer URL and API Token.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { PortainerApiClient } from 'writetainer-lib';
|
|
27
|
+
|
|
28
|
+
const portainerUrl = 'https://your-portainer-instance.com';
|
|
29
|
+
const apiToken = 'your-api-token';
|
|
30
|
+
|
|
31
|
+
const client = new PortainerApiClient(portainerUrl, apiToken);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You can also specify a default environment ID during initialization:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const client = new PortainerApiClient(portainerUrl, apiToken, 1);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If no environment ID is provided, the client will attempt to fetch the first available environment ID automatically.
|
|
41
|
+
|
|
42
|
+
### Examples
|
|
43
|
+
|
|
44
|
+
#### Get All Environments
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const environments = await client.getEnvironments();
|
|
48
|
+
console.log(environments);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### Get Stacks
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const stacks = await client.getStacks();
|
|
55
|
+
console.log(stacks);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Get Containers
|
|
59
|
+
|
|
60
|
+
Fetch all containers (running and stopped) for the default environment.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const containers = await client.getContainers(true);
|
|
64
|
+
console.log(containers);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Test Connection
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const isConnected = await client.testConnection();
|
|
71
|
+
if (isConnected) {
|
|
72
|
+
console.log('Connected to Portainer!');
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API Reference
|
|
77
|
+
|
|
78
|
+
### `PortainerApiClient`
|
|
79
|
+
|
|
80
|
+
#### Constructor
|
|
81
|
+
`new PortainerApiClient(portainerUrl: string, apiToken: string, environmentId?: number | null)`
|
|
82
|
+
|
|
83
|
+
#### Methods
|
|
84
|
+
|
|
85
|
+
- `getEnvironments(): Promise<PortainerEnvironment[]>`
|
|
86
|
+
- Fetches a list of all Portainer environments.
|
|
87
|
+
|
|
88
|
+
- `getEnvironment(environmentId: number): Promise<PortainerEnvironment>`
|
|
89
|
+
- Fetches details of a specific environment.
|
|
90
|
+
|
|
91
|
+
- `getStacks(): Promise<PortainerStack[]>`
|
|
92
|
+
- Fetches a list of all stacks.
|
|
93
|
+
|
|
94
|
+
- `getContainers(includeAll: boolean): Promise<PortainerContainer[] | undefined>`
|
|
95
|
+
- Fetches a list of containers for the current environment.
|
|
96
|
+
- `includeAll`: Set to `true` to include stopped containers.
|
|
97
|
+
|
|
98
|
+
- `testConnection(): Promise<boolean>`
|
|
99
|
+
- Tests the connection to the Portainer API.
|
|
100
|
+
|
|
101
|
+
- `DefaultEnvironmentId` (Getter/Setter)
|
|
102
|
+
- Get or set the default environment ID used for container operations.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "writetainer-lib",
|
|
3
|
+
"version": "25.12.27-dev.7",
|
|
4
|
+
"description": "a portainer api accessibility library",
|
|
5
|
+
"homepage": "https://github.com/enVId-tech/Writetainer-Lib#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/enVId-tech/Writetainer-Lib/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enVId-tech/Writetainer-Lib.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "envid-tech",
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "vitest",
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"ncu": "npx npm-check-updates -u && npm install"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"axios": "^1.13.2",
|
|
23
|
+
"debug": "^4.4.3",
|
|
24
|
+
"dotenv": "^17.2.3",
|
|
25
|
+
"typescript": "^5.9.3"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
29
|
+
"@types/debug": "^4.1.12",
|
|
30
|
+
"@types/node": "^25.0.3",
|
|
31
|
+
"vitest": "^4.0.16"
|
|
32
|
+
},
|
|
33
|
+
"type": "module"
|
|
34
|
+
}
|