Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
204d4bf
Chore: Pre release workflow
Its4Nik Jan 3, 2025
b27369f
Fix: removed negation from if in workflow
Its4Nik Jan 3, 2025
fe37f2d
Feat: Added new image => See next commit
Its4Nik Jan 5, 2025
0298053
Feat: Stack creation
Its4Nik Jan 12, 2025
4ec10e2
Feat: Stack creation + starting and stopping
Its4Nik Jan 14, 2025
78203f4
Fix: Project root instead of path
Its4Nik Jan 14, 2025
1808318
Fix: Logging adustment
Its4Nik Jan 14, 2025
b32535d
Fix: Allow undescores and dashes in stack name
Its4Nik Jan 14, 2025
f54b829
Merge branch 'Feat-Stacks' of github.com:Its4Nik/dockstatapi into Fea…
Its4Nik Jan 14, 2025
647368c
Fix: Propagate error
Its4Nik Jan 14, 2025
905ad05
Fix: Inline variable that is immediately returned
Its4Nik Jan 14, 2025
e446ba5
Merge branch 'Feat-Stacks' of github.com:Its4Nik/dockstatapi into Fea…
Its4Nik Jan 14, 2025
120bd0f
Fix: move some things around
Its4Nik Jan 14, 2025
a260974
Fix: Minor adjustments
Its4Nik Jan 14, 2025
dc00c5c
Feat: Get a stack's docker-compose
Its4Nik Jan 14, 2025
caf49b6
Feat: automatic Stack environmental file management
Its4Nik Jan 15, 2025
4e30804
Fix: sample-varaible.json adjustment
Its4Nik Jan 15, 2025
2620a23
Fix: Potential fix for code scanning alert no. 102: Log injection
Its4Nik Jan 16, 2025
c295e55
Fix: fix for code scanning alert no. 94: Uncontrolled data used in pa…
Its4Nik Jan 16, 2025
0bda443
Fix: fix for code scanning alert no. 92: Uncontrolled data used in pa…
Its4Nik Jan 16, 2025
58a8b02
FiX: fix for code scanning alert no. 106: Log injection
Its4Nik Jan 17, 2025
65bcec8
Fix: Logger vulnerability and CI graph generation
Its4Nik Jan 17, 2025
92bfd8b
Feat: change logger verbosity and spelling fix
Its4Nik Jan 17, 2025
e99a274
Feat: ToDo comments to GH issue
Its4Nik Jan 24, 2025
fa8ec50
Fix: Add checkout
Its4Nik Jan 24, 2025
7ecdd48
Fix: May fix the ToDo workflow
Its4Nik Jan 29, 2025
ee09afd
Fix: Remove todo
Its4Nik Jan 29, 2025
c191fe4
Merge branch 'Feat-Stacks' of github.com:Its4Nik/dockstatapi into Fea…
Its4Nik Jan 29, 2025
366fd9e
Fix: Re-Add commit
Its4Nik Jan 29, 2025
9a432e9
Fix: Remove TODO
Its4Nik Jan 29, 2025
018eb20
Fix: Re-add TODO
Its4Nik Jan 29, 2025
836f13e
Fix: Where tf did my package lock go :sob:
Its4Nik Jan 29, 2025
5d4ef40
CI/CD: Remove ToDo
Its4Nik Jan 29, 2025
ac98338
CI/CD: Add ToDo
Its4Nik Jan 29, 2025
67d3195
CI/CD: Fix command
Its4Nik Jan 29, 2025
a82d021
Fix: Add checkout
Its4Nik Jan 29, 2025
a8eacbd
CI/CD: Add checkout
Its4Nik Jan 29, 2025
c2396ef
Fix: CPU value was a percentage the whole time?
Its4Nik Jan 29, 2025
9a4999c
Merge branch 'Feat-Stacks' of github.com:Its4Nik/DockStatAPI into Fea…
Feb 7, 2025
a068cba
Feat: Websocket endpoints for logs and container metrics
Feb 9, 2025
42d354e
Fix: Make linter happy
Feb 9, 2025
8235a73
Fix: Fix import
Feb 9, 2025
de5dac7
Fix: Fix tsc build
Feb 9, 2025
477dfe9
Jest: Fix tests
Feb 9, 2025
26ed976
Jest: Fix Tests
Feb 9, 2025
5cfe48c
Fix: Typo in src/config/swagger.yaml
Its4Nik Feb 9, 2025
2c8a4fe
Fix: Typo in src/config/swagger.yaml
Its4Nik Feb 9, 2025
d44cf51
Fix: Tyypo in src/config/swagger.yaml
Its4Nik Feb 9, 2025
429fcc6
(code-quality): Inline variable that is immediately returned
Its4Nik Feb 9, 2025
045c0c4
(code-quality): Prefer object destructuring when accessing and using …
Its4Nik Feb 9, 2025
3ec1a7e
(code-quality): Prefer object destructuring when accessing and using …
Its4Nik Feb 9, 2025
483fad5
(code-quality): Prefer object destructuring when accessing and using …
Its4Nik Feb 9, 2025
3a572f9
Fix: Update extractHostData.ts
Its4Nik Feb 9, 2025
b0c2980
Update TODO.md
Its4Nik Feb 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/DockStat-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 21 additions & 6 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Build dockstatapi:latest"
name: "Build and Push Docker Image"

on:
release:
Expand All @@ -12,28 +12,43 @@ jobs:
build-release:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Generate Docker tags
- name: Extract version and create tag
id: get-tag
run: |
# Remove 'v' prefix from release tag if present
VERSION="${GITHUB_REF#refs/tags/v}"
# Check if pre-release and append '-pre'
if ${{ github.event.release.prerelease }}; then
TAG="$VERSION-pre"
else
TAG="$VERSION"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Generate Docker metadata
uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=sha,format=long,prefix=
flavor: |
latest=true
type=raw,value=${{ steps.get-tag.outputs.tag }}
type=raw,value=latest,enable=${{ !github.event.release.prerelease }}

- name: Build and push
uses: docker/build-push-action@v6
Expand Down
93 changes: 89 additions & 4 deletions .github/workflows/validation.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: "Run all tests"

on: [push]
on:
push:
release:
types:
- published

jobs:
validation:
Expand Down Expand Up @@ -42,8 +46,40 @@ jobs:
- name: Jests
run: npm run test:silent

CodeQL:
ToDo:
needs: validation
runs-on: ubuntu-20.04
name: "ToDo comment to issue"
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v5"
with:
INSERT_ISSUE_URLS: "true"

- name: Set Git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Commit and Push Changes
run: |
git add -A
if [[ `git status --porcelain` ]]; then
git commit -m "Automatically added GitHub issue links to TODOs"
git push
else
echo "No changes to commit"
fi

CodeQL:
needs: [ToDo]
runs-on: ubuntu-24.04
name: "Analyze TypeScript"
permissions:
Expand Down Expand Up @@ -78,7 +114,7 @@ jobs:
category: "/language:javascript-typescript"

Anchore:
needs: validation
needs: [ToDo]
runs-on: ubuntu-24.04
name: "Anchore"
permissions:
Expand Down Expand Up @@ -113,7 +149,7 @@ jobs:
sarif_file: ./results.sarif

test-building:
needs: [validation]
needs: [ToDo]
runs-on: ubuntu-24.04
name: "Test building"
permissions:
Expand Down Expand Up @@ -216,3 +252,52 @@ jobs:
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

build-pre-release:
name: "Pre-Release-build"
permissions:
security-events: read
packages: write
actions: read
contents: read
runs-on: ubuntu-24.04
if: "github.event.release.prerelease"
needs: [test-building, Anchore, CodeQL]
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Generate Docker tags
uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,enable=true,priority=200,prefix=,suffix=,value=pre
flavor: |
latest=false

- name: Build and Push Docker Images
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile-dev
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# custom paths:
src/data/*
src/data/frontendConfiguration.json

.tmp
docker/master
docker/slave
.test*
stacks
# Created by https://www.toptal.com/developers/gitignore/api/node
### Node ###
*-audit.json
Expand Down
30 changes: 30 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ This file shows all npm packages used in DockStatAPI (also Dev packages)
| ----------------- | -------------------------------------------- | -------------------- |
| spdx-ranges@2.1.1 | https://github.com/kemitchell/spdx-ranges.js | The Linux Foundation |

### License: Apache 2.0

| Name | Repository | Publisher |
| ---------------------- | ------------------------------------------ | --------- |
| qrcode-terminal@0.12.0 | https://github.com/gtanner/qrcode-terminal | N/A |

### License: Apache-2.0

| Name | Repository | Publisher |
Expand All @@ -25,6 +31,12 @@ This file shows all npm packages used in DockStatAPI (also Dev packages)
| @humanwhocodes/retry@0.4.1 | https://github.com/humanwhocodes/retry | Nicholas C. Zaks |
| @puppeteer/browsers@2.7.0 | https://github.com/puppeteer/puppeteer/tree/main/packages/browsers | The Chromium Authors |
| @scarf/scarf@1.4.0 | https://github.com/scarf-sh/scarf-js | Scarf Systems |
| @sigstore/bundle@3.0.0 | https://github.com/sigstore/sigstore-js | bdehamer@github.com |
| @sigstore/core@2.0.0 | https://github.com/sigstore/sigstore-js | bdehamer@github.com |
| @sigstore/protobuf-specs@0.3.2 | https://github.com/sigstore/protobuf-specs | bdehamer@github.com |
| @sigstore/sign@3.0.0 | https://github.com/sigstore/sigstore-js | bdehamer@github.com |
| @sigstore/tuf@3.0.0 | https://github.com/sigstore/sigstore-js | bdehamer@github.com |
| @sigstore/verify@2.0.0 | https://github.com/sigstore/sigstore-js | bdehamer@github.com |
| b4a@1.6.7 | https://github.com/holepunchto/b4a | Holepunch |
| bare-events@2.5.4 | https://github.com/holepunchto/bare-events | Holepunch |
| bare-fs@2.3.5 | https://github.com/holepunchto/bare-fs | Holepunch |
Expand All @@ -40,12 +52,14 @@ This file shows all npm packages used in DockStatAPI (also Dev packages)
| ejs@3.1.10 | https://github.com/mde/ejs | Matthew Eernisse |
| eslint-visitor-keys@3.4.3 | https://github.com/eslint/eslint-visitor-keys | Toru Nagashima |
| eslint-visitor-keys@4.2.0 | https://github.com/eslint/js | Toru Nagashima |
| exponential-backoff@3.1.1 | https://github.com/coveo/exponential-backoff | Sami Sayegh |
| fb-watchman@2.0.2 | https://github.com/facebook/watchman | Wez Furlong |
| filelist@1.0.4 | https://github.com/mde/filelist | Matthew Eernisse |
| human-signals@2.1.0 | https://github.com/ehmicky/human-signals | ehmicky |
| jake@10.9.2 | https://github.com/jakejs/jake | Matthew Eernisse |
| puppeteer-core@24.0.0 | https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer-core | The Chromium Authors |
| puppeteer@24.0.0 | https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer | The Chromium Authors |
| sigstore@3.0.0 | https://github.com/sigstore/sigstore-js | bdehamer@github.com |
| spdx-correct@3.2.0 | https://github.com/jslicense/spdx-correct.js | N/A |
| swagger-ui-dist@5.18.2 | https://github.com/swagger-api/swagger-ui | N/A |
| text-decoder@1.2.3 | https://github.com/holepunchto/text-decoder | Holepunch |
Expand All @@ -54,6 +68,22 @@ This file shows all npm packages used in DockStatAPI (also Dev packages)
| validate-npm-package-license@3.0.4 | https://github.com/kemitchell/validate-npm-package-license.js | Kyle E. Mitchell |
| walker@1.0.8 | https://github.com/daaku/nodejs-walker | Naitik Shah |

### License: Artistic-2.0

| Name | Repository | Publisher |
| ---------- | -------------------------- | ----------- |
| npm@11.0.0 | https://github.com/npm/cli | GitHub Inc. |

### License: BlueOak-1.0.0

| Name | Repository | Publisher |
| ---------------------------- | ------------------------------------------------ | ------------------ |
| chownr@3.0.0 | https://github.com/isaacs/chownr | Isaac Z. Schlueter |
| jackspeak@3.4.3 | https://github.com/isaacs/jackspeak | Isaac Z. Schlueter |
| package-json-from-dist@1.0.1 | https://github.com/isaacs/package-json-from-dist | Isaac Z. Schlueter |
| path-scurry@1.11.1 | https://github.com/isaacs/path-scurry | Isaac Z. Schlueter |
| yallist@5.0.0 | https://github.com/isaacs/yallist | Isaac Z. Schlueter |

### License: CC-BY-3.0

| Name | Repository | Publisher |
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
- [x] Structure code differently
- [x] Write new README and make the docs better
- [x] Update more files to correct TS syntax => remove "any"
- [ ] Websockets
- [X] Websockets
- [x] Better /api/status endpoint with connection status of each host
- [x] Update notification service
- [x] Adjust process.env variables since they don't really work as expected (See [commit](https://github.com/Its4Nik/dockstatapi/pull/21/commits/a03b58c7a17e269f46216df5492e18d008774961))
- [ ] Better project structure
- [x] Update logging => Better errors
- [x] Update json responses
- [ ] Swagger update
- [X] Swagger update
- [ ] Edge case testing
19 changes: 12 additions & 7 deletions __tests__/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
export const testPass: string = "123321";
export const testPass = "123456789";
import { Server } from 'http';
import supertest from "supertest";
import { startServer } from "../src/utils/startServer";
import app from "../src/server";
const server = supertest("http://localhost:13001");

startServer(app, 13001);
const port = 13001;
const server = new Server(app);

startServer(app, server, port);

const request = supertest(`http://localhost:${port}`);

describe("Authentication", () => {
it("Enable Authentication", async () => {
const res = await server.post(`/auth/enable?password=${testPass}`);
const res = await request.post(`/auth/enable?password=${testPass}`);
expect(res.status).toEqual(200);
expect(res.type).toEqual(expect.stringContaining("json"));
expect(res.body).toHaveProperty(
Expand All @@ -18,16 +23,16 @@ describe("Authentication", () => {
});

it("Test no password", async () => {
const res = await server.get("/api/status");
const res = await request.get("/api/status");
expect(res.status).toEqual(403);
expect(res.type).toEqual(expect.stringContaining("json"));
});

it("Disable authentication", async () => {
const res = await server
const res = await request
.post(`/auth/disable?password=${testPass}`)
.set("x-password", testPass);
expect(res.status).toEqual(200);
expect(res.type).toEqual(expect.stringContaining("json"));
});
});
});
23 changes: 14 additions & 9 deletions __tests__/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
import supertest from "supertest";
import { startServer } from "../src/utils/startServer";
import app from "../src/server";
const server = supertest("http://localhost:13002");
import { Server } from 'http';

startServer(app, 13002);
const port = 13002;
const server = new Server(app);

startServer(app, server, port);

const request = supertest(`http://localhost:${port}`);

const mockServerName: string = "mockstatapi";
const mockServerIP: string = "127.0.0.1";
const mockServerPort: number = 2375;

describe("Config endpoints", () => {
it("Add an host", async () => {
let res = await server.put(
let res = await request.put(
`/conf/addHost?name=${mockServerName}&url=${mockServerIP}&port=${mockServerPort}`,
);
expect(res.status).toEqual(200);

res = await server.get("/api/hosts");
res = await request.get("/api/hosts");
expect(res.status).toEqual(200);
expect(res.body).toContain("mockstatapi");
});

it("Adjust scheduler", async () => {
let res = await server.put("/conf/scheduler?interval=10m");
let res = await request.put("/conf/scheduler?interval=10m");
expect(res.status).toEqual(200);

res = await server.get("/api/current-schedule");
res = await request.get("/api/current-schedule");
expect(res.status).toEqual(200);

// Reset to standart 5m
res = await server.put("/conf/scheduler?interval=5m");
res = await request.put("/conf/scheduler?interval=5m");
expect(res.status).toEqual(200);
});

it("Remove Host from config", async () => {
let res = await server.delete(`/conf/removeHost?hostName=mockstatapi`);
let res = await request.delete(`/conf/removeHost?hostName=mockstatapi`);
expect(res.status).toEqual(200);

res = await server.get("/api/hosts");
res = await request.get("/api/hosts");
expect(res.status).toEqual(200);
expect(res.body).not.toHaveProperty("mockstatapi");
});
Expand Down
Loading
Loading