Compare commits

..

No commits in common. "main" and "v1.1.1" have entirely different histories.
main ... v1.1.1

11 changed files with 240 additions and 570 deletions

View File

@ -1,8 +1,4 @@
name: Build image name: Build image
permissions:
contents: write
packages: write
on: on:
pull_request: pull_request:
paths: paths:
@ -13,24 +9,33 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest container:
image: docker:dind
volumes:
- /data/.cache/act:/data/.cache/act
- /var/lib/docker/image:/var/lib/docker/image
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
steps: steps:
- name: Starting docker daemon
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
- name: Installing necessary packages
run: apk add nodejs git curl bash
- name: Checkout - name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5 uses: https://github.com/docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
with: with:
# list of Docker images to use as base name for tags # list of Docker images to use as base name for tags
images: | images: |
git.fai.st/${{ github.repository }} git.fai.st/fedi-image-bot/moderation-fe
# generate Docker tags based on the following events/attributes # generate Docker tags based on the following events/attributes
tags: | tags: |
type=raw,value=latest type=raw,value=latest
type=ref,event=branch type=ref,event=branch
type=semver,pattern={{raw}} type=semver,pattern={{raw}}
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3 uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2
- name: Login to fai.st docker registry - name: Login to fai.st docker registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with: with:
@ -38,7 +43,7 @@ jobs:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@0adf9959216b96bec444f325f1e493d4aa344497 # v6 uses: docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9 # v4
with: with:
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
context: . context: .

View File

@ -1,26 +0,0 @@
name: renovate
on:
push:
branches:
- main
schedule:
- cron: "@daily"
jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Self-hosted Renovate
uses: https://github.com/renovatebot/github-action@e084b5ac6fd201023db6dd7743aec023babb02c8 # v41.0.13
with:
token: ${{ secrets.RENOVATE_TOKEN }}
env-regex: "^(?:RENOVATE_\\w+|GITHUB_COM_TOKEN)$"
env:
RENOVATE_ENDPOINT: ${{ github.server_url }}
RENOVATE_PLATFORM: "gitea"
RENOVATE_GIT_AUTHOR: "Renovate Bot <contact@siesta.cat>"
RENOVATE_REPOSITORIES: ${{ github.repository }}
GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GHPAT }}

View File

@ -1 +0,0 @@
nodejs 23.8.0

View File

@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM node:23.8.0-alpine AS install FROM --platform=$BUILDPLATFORM node:23.5.0-alpine AS install
RUN mkdir -p /temp/prod RUN mkdir -p /temp/prod
COPY package*.json /temp/prod/ COPY package*.json /temp/prod/
RUN cd /temp/prod && npm install --frozen-lockfile RUN cd /temp/prod && npm install --frozen-lockfile

View File

@ -1,7 +1,7 @@
services: services:
mongodb: mongodb:
image: mongo:bionic image: mongo:bionic
container_name: fe-mongodb container_name: mongodb-fe
ports: ports:
- "27017:27017" - "27017:27017"
environment: environment:
@ -10,34 +10,32 @@ services:
MONGO_INITDB_DATABASE: bot MONGO_INITDB_DATABASE: bot
volumes: volumes:
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro - ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
- mongodb_data:/data/db
bot-api: bot-api:
image: ghcr.io/siesta-cat/2chi-api:v1.1.0 image: git.fai.st/fedi-image-bot/bot-api:latest
container_name: fe-2chi-api container_name: bot-api-fe
restart: on-failure
ports: ports:
- 8080:8080 - 8080:8080
depends_on: depends_on:
- mongodb - mongodb
environment: environment:
PORT: 8080 PORT: 8080
DB_HOST: "mongodb" MONGODB_URI: "mongodb://mongodb:27017/bot"
DB_NAME: "bot" MONGODB_USER: "root"
DB_USER: "root" MONGODB_PASS: "password"
DB_PASS: "password" JWTSECRET: "cooljwtsecret"
fe-middleware: fe-middleware:
image: ghcr.io/siesta-cat/2chi-verifier-be:v2.1.3 image: git.fai.st/fedi-image-bot/fe-middleware:latest
container_name: fe-2chi-verifier-be container_name: fe-middleware-fe
stop_signal: sigkill
ports: ports:
- 8081:8081 - 8081:8081
depends_on: depends_on:
- bot-api - bot-api
environment: environment:
PORT: 8081 PORT: 8081
BOT_API_BASE_URL: "http://bot-api:8080" BOT_API_URI: "http://bot-api:8080"
TOKEN_SECRET: Y2hpY2FzZWNyZXQK
GELBOORU_IMAGES_PER_REQUEST: 100 # Number of images per request, maximum 100 GELBOORU_IMAGES_PER_REQUEST: 100 # Number of images per request, maximum 100
GELBOORU_TAGS: "2girls sleeping" # Tags of the images. The images will have all of these tags GELBOORU_TAGS: "2girls sleeping" # Tags of the images. The images will have all of these tags
@ -46,11 +44,12 @@ services:
container_name: bot-image-moderation-fe container_name: bot-image-moderation-fe
ports: ports:
- 80:80 - 80:80
environment:
VITE_BACKEND_URL: "http://localhost:8081"
develop: develop:
watch: watch:
- action: rebuild - action: rebuild
path: . path: .
ignore: ignore:
- node_modules/ - node_modules/
volumes:
mongodb_data:

482
package-lock.json generated
View File

@ -9,12 +9,12 @@
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"react-dom": "19.0.0", "react-dom": "19.0.0",
"typescript": "5.7.3", "typescript": "5.7.2",
"vite": "6.1.1" "vite": "6.0.7"
}, },
"devDependencies": { "devDependencies": {
"@types/react-dom": "19.0.4", "@types/react-dom": "19.0.2",
"@vitejs/plugin-react-swc": "3.8.0" "@vitejs/plugin-react-swc": "3.7.2"
} }
}, },
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
@ -417,192 +417,8 @@
"node": ">=18" "node": ">=18"
} }
}, },
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.3.tgz",
"integrity": "sha512-8kq/NjMKkMTGKMPldWihncOl62kgnLYk7cW+/4NCUWfS70/wz4+gQ7rMxMMpZ3dIOP/xw7wKNzIuUnN/H2GfUg==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"android"
]
},
"node_modules/@rollup/rollup-android-arm64": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.3.tgz",
"integrity": "sha512-1PqMHiuRochQ6++SDI7SaRDWJKr/NgAlezBi5nOne6Da6IWJo3hK0TdECBDwd92IUDPG4j/bZmWuwOnomNT8wA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
]
},
"node_modules/@rollup/rollup-darwin-arm64": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.3.tgz",
"integrity": "sha512-fqbrykX4mGV3DlCDXhF4OaMGcchd2tmLYxVt3On5oOZWVDFfdEoYAV2alzNChl8OzNaeMAGqm1f7gk7eIw/uDg==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@rollup/rollup-darwin-x64": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.3.tgz",
"integrity": "sha512-8Wxrx/KRvMsTyLTbdrMXcVKfpW51cCNW8x7iQD72xSEbjvhCY3b+w83Bea3nQfysTMR7K28esc+ZFITThXm+1w==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@rollup/rollup-freebsd-arm64": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.3.tgz",
"integrity": "sha512-lpBmV2qSiELh+ATQPTjQczt5hvbTLsE0c43Rx4bGxN2VpnAZWy77we7OO62LyOSZNY7CzjMoceRPc+Lt4e9J6A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/@rollup/rollup-freebsd-x64": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.3.tgz",
"integrity": "sha512-sNPvBIXpgaYcI6mAeH13GZMXFrrw5mdZVI1M9YQPRG2LpjwL8DSxSIflZoh/B5NEuOi53kxsR/S2GKozK1vDXA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.3.tgz",
"integrity": "sha512-MW6N3AoC61OfE1VgnN5O1OW0gt8VTbhx9s/ZEPLBM11wEdHjeilPzOxVmmsrx5YmejpGPvez8QwGGvMU+pGxpw==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.3.tgz",
"integrity": "sha512-2SQkhr5xvatYq0/+H6qyW0zvrQz9LM4lxGkpWURLoQX5+yP8MsERh4uWmxFohOvwCP6l/+wgiHZ1qVwLDc7Qmw==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-arm64-gnu": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.3.tgz",
"integrity": "sha512-R3JLYt8YoRwKI5shJsovLpcR6pwIMui/MGG/MmxZ1DYI3iRSKI4qcYrvYgDf4Ss2oCR3RL3F3dYK7uAGQgMIuQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-arm64-musl": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.3.tgz",
"integrity": "sha512-4XQhG8v/t3S7Rxs7rmFUuM6j09hVrTArzONS3fUZ6oBRSN/ps9IPQjVhp62P0W3KhqJdQADo/MRlYRMdgxr/3w==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-loongarch64-gnu": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.3.tgz",
"integrity": "sha512-QlW1jCUZ1LHUIYCAK2FciVw1ptHsxzApYVi05q7bz2A8oNE8QxQ85NhM4arLxkAlcnS42t4avJbSfzSQwbIaKg==",
"cpu": [
"loong64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.3.tgz",
"integrity": "sha512-kMbLToizVeCcN69+nnm20Dh0hrRIAjgaaL+Wh0gWZcNt8e542d2FUGtsyuNsHVNNF3gqTJrpzUGIdwMGLEUM7g==",
"cpu": [
"ppc64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.3.tgz",
"integrity": "sha512-YgD0DnZ3CHtvXRH8rzjVSxwI0kMTr0RQt3o1N92RwxGdx7YejzbBO0ELlSU48DP96u1gYYVWfUhDRyaGNqJqJg==",
"cpu": [
"riscv64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-s390x-gnu": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.3.tgz",
"integrity": "sha512-dIOoOz8altjp6UjAi3U9EW99s8nta4gzi52FeI45GlPyrUH4QixUoBMH9VsVjt+9A2RiZBWyjYNHlJ/HmJOBCQ==",
"cpu": [
"s390x"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@rollup/rollup-linux-x64-gnu": { "node_modules/@rollup/rollup-linux-x64-gnu": {
"version": "4.34.3", "version": "4.28.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.3.tgz",
"integrity": "sha512-lOyG3aF4FTKrhpzXfMmBXgeKUUXdAWmP2zSNf8HTAXPqZay6QYT26l64hVizBjq+hJx3pl0DTEyvPi9sTA6VGA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -613,9 +429,7 @@
] ]
}, },
"node_modules/@rollup/rollup-linux-x64-musl": { "node_modules/@rollup/rollup-linux-x64-musl": {
"version": "4.34.3", "version": "4.28.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.3.tgz",
"integrity": "sha512-usztyYLu2i+mYzzOjqHZTaRXbUOqw3P6laNUh1zcqxbPH1P2Tz/QdJJCQSnGxCtsRQeuU2bCyraGMtMumC46rw==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -625,49 +439,8 @@
"linux" "linux"
] ]
}, },
"node_modules/@rollup/rollup-win32-arm64-msvc": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.3.tgz",
"integrity": "sha512-ojFOKaz/ZyalIrizdBq2vyc2f0kFbJahEznfZlxdB6pF9Do6++i1zS5Gy6QLf8D7/S57MHrmBLur6AeRYeQXSA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@rollup/rollup-win32-ia32-msvc": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.3.tgz",
"integrity": "sha512-K/V97GMbNa+Da9mGcZqmSl+DlJmWfHXTuI9V8oB2evGsQUtszCl67+OxWjBKpeOnYwox9Jpmt/J6VhpeRCYqow==",
"cpu": [
"ia32"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@rollup/rollup-win32-x64-msvc": {
"version": "4.34.3",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.3.tgz",
"integrity": "sha512-CUypcYP31Q8O04myV6NKGzk9GVXslO5EJNfmARNSzLF2A+5rmZUlDJ4et6eoJaZgBT9wrC2p4JZH04Vkic8HdQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@swc/core": { "node_modules/@swc/core": {
"version": "1.10.15", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.10.15.tgz",
"integrity": "sha512-/iFeQuNaGdK7mfJbQcObhAhsMqLT7qgMYl7jX2GEIO+VDTejESpzAyKwaMeYXExN8D6e5BRHBCe7M5YlsuzjDA==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0", "license": "Apache-2.0",
@ -683,16 +456,16 @@
"url": "https://opencollective.com/swc" "url": "https://opencollective.com/swc"
}, },
"optionalDependencies": { "optionalDependencies": {
"@swc/core-darwin-arm64": "1.10.15", "@swc/core-darwin-arm64": "1.9.3",
"@swc/core-darwin-x64": "1.10.15", "@swc/core-darwin-x64": "1.9.3",
"@swc/core-linux-arm-gnueabihf": "1.10.15", "@swc/core-linux-arm-gnueabihf": "1.9.3",
"@swc/core-linux-arm64-gnu": "1.10.15", "@swc/core-linux-arm64-gnu": "1.9.3",
"@swc/core-linux-arm64-musl": "1.10.15", "@swc/core-linux-arm64-musl": "1.9.3",
"@swc/core-linux-x64-gnu": "1.10.15", "@swc/core-linux-x64-gnu": "1.9.3",
"@swc/core-linux-x64-musl": "1.10.15", "@swc/core-linux-x64-musl": "1.9.3",
"@swc/core-win32-arm64-msvc": "1.10.15", "@swc/core-win32-arm64-msvc": "1.9.3",
"@swc/core-win32-ia32-msvc": "1.10.15", "@swc/core-win32-ia32-msvc": "1.9.3",
"@swc/core-win32-x64-msvc": "1.10.15" "@swc/core-win32-x64-msvc": "1.9.3"
}, },
"peerDependencies": { "peerDependencies": {
"@swc/helpers": "*" "@swc/helpers": "*"
@ -703,95 +476,8 @@
} }
} }
}, },
"node_modules/@swc/core-darwin-arm64": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.10.15.tgz",
"integrity": "sha512-zFdZ6/yHqMCPk7OhLFqHy/MQ1EqJhcZMpNHd1gXYT7VRU3FaqvvKETrUlG3VYl65McPC7AhMRfXPyJ0JO/jARQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-darwin-x64": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.10.15.tgz",
"integrity": "sha512-8g4yiQwbr8fxOOjKXdot0dEkE5zgE8uNZudLy/ZyAhiwiZ8pbJ8/wVrDOu6dqbX7FBXAoDnvZ7fwN1jk4C8jdA==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.10.15.tgz",
"integrity": "sha512-rl+eVOltl2+7WXOnvmWBpMgh6aO13G5x0U0g8hjwlmD6ku3Y9iRcThpOhm7IytMEarUp5pQxItNoPq+VUGjVHg==",
"cpu": [
"arm"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.10.15.tgz",
"integrity": "sha512-qxWEQeyAJMWJqjaN4hi58WMpPdt3Tn0biSK9CYRegQtvZWCbewr6v2agtSu5AZ2rudeH6OfCWAMDQQeSgn6PJQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm64-musl": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.10.15.tgz",
"integrity": "sha512-QcELd9/+HjZx0WCxRrKcyKGWTiQ0485kFb5w8waxcSNd0d9Lgk4EFfWWVyvIb5gIHpDQmhrgzI/yRaWQX4YSZQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-x64-gnu": { "node_modules/@swc/core-linux-x64-gnu": {
"version": "1.10.15", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.10.15.tgz",
"integrity": "sha512-S1+ZEEn3+a/MiMeQqQypbwTGoBG8/sPoCvpNbk+uValyygT+jSn3U0xVr45FbukpmMB+NhBMqfedMLqKA0QnJA==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -806,9 +492,7 @@
} }
}, },
"node_modules/@swc/core-linux-x64-musl": { "node_modules/@swc/core-linux-x64-musl": {
"version": "1.10.15", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.10.15.tgz",
"integrity": "sha512-qW+H9g/2zTJ4jP7NDw4VAALY0ZlNEKzYsEoSj/HKi7k3tYEHjMzsxjfsY9I8WZCft23bBdV3RTCPoxCshaj1CQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@ -822,57 +506,6 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.10.15.tgz",
"integrity": "sha512-AhRB11aA6LxjIqut+mg7qsu/7soQDmbK6MKR9nP3hgBszpqtXbRba58lr24xIbBCMr+dpo6kgEapWt+t5Po6Zg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.10.15.tgz",
"integrity": "sha512-UGdh430TQwbDn6KjgvRTg1fO022sbQ4yCCHUev0+5B8uoBwi9a89qAz3emy2m56C8TXxUoihW9Y9OMfaRwPXUw==",
"cpu": [
"ia32"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-x64-msvc": {
"version": "1.10.15",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.10.15.tgz",
"integrity": "sha512-XJzBCqO1m929qbJsOG7FZXQWX26TnEoMctS3QjuCoyBmkHxxQmZsy78KjMes1aomTcKHCyFYgrRGWgVmk7tT4Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 AND MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/counter": { "node_modules/@swc/counter": {
"version": "0.1.3", "version": "0.1.3",
"dev": true, "dev": true,
@ -911,9 +544,9 @@
} }
}, },
"node_modules/@types/react-dom": { "node_modules/@types/react-dom": {
"version": "19.0.4", "version": "19.0.2",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.0.4.tgz", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.0.2.tgz",
"integrity": "sha512-4fSQ8vWFkg+TGhePfUzVmat3eC14TXYSsiiDSLI0dVLsrm9gZFABjPy/Qu6TKgl1tq1Bu1yDsuQgY3A3DOjCcg==", "integrity": "sha512-c1s+7TKFaDRRxr1TxccIX2u7sfCnc3RxkVyBIUA2lCpyqCF+QoAwQ/CBg7bsMdVwP120HEH143VQezKtef5nCg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
@ -921,13 +554,13 @@
} }
}, },
"node_modules/@vitejs/plugin-react-swc": { "node_modules/@vitejs/plugin-react-swc": {
"version": "3.8.0", "version": "3.7.2",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.8.0.tgz", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.7.2.tgz",
"integrity": "sha512-T4sHPvS+DIqDP51ifPqa9XIRAz/kIvIi8oXcnOZZgHmMotgmmdxe/DD5tMFlt5nuIRzT0/QuiwmKlH0503Aapw==", "integrity": "sha512-y0byko2b2tSVVf5Gpng1eEhX1OvPC7x8yns1Fx8jDzlJp4LS6CMkCPfLw47cjyoMrshQDoQw4qcgjsU9VvlCew==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@swc/core": "^1.10.15" "@swc/core": "^1.7.26"
}, },
"peerDependencies": { "peerDependencies": {
"vite": "^4 || ^5 || ^6" "vite": "^4 || ^5 || ^6"
@ -1014,9 +647,7 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.5.2", "version": "8.4.49",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.2.tgz",
"integrity": "sha512-MjOadfU3Ys9KYoX0AdkBlFEF1Vx37uCCeN4ZHnmwm9FfpbsGWMZeBLMmmpY+6Ocqod7mkdZ0DT31OlbsFrLlkA==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -1033,7 +664,7 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"nanoid": "^3.3.8", "nanoid": "^3.3.7",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
"source-map-js": "^1.2.1" "source-map-js": "^1.2.1"
}, },
@ -1064,9 +695,7 @@
} }
}, },
"node_modules/rollup": { "node_modules/rollup": {
"version": "4.34.3", "version": "4.28.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.3.tgz",
"integrity": "sha512-ORCtU0UBJyiAIn9m0llUXJXAswG/68pZptCrqxHG7//Z2DDzAUeyyY5hqf4XrsGlUxscMr9GkQ2QI7KTLqeyPw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/estree": "1.0.6" "@types/estree": "1.0.6"
@ -1079,25 +708,24 @@
"npm": ">=8.0.0" "npm": ">=8.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"@rollup/rollup-android-arm-eabi": "4.34.3", "@rollup/rollup-android-arm-eabi": "4.28.0",
"@rollup/rollup-android-arm64": "4.34.3", "@rollup/rollup-android-arm64": "4.28.0",
"@rollup/rollup-darwin-arm64": "4.34.3", "@rollup/rollup-darwin-arm64": "4.28.0",
"@rollup/rollup-darwin-x64": "4.34.3", "@rollup/rollup-darwin-x64": "4.28.0",
"@rollup/rollup-freebsd-arm64": "4.34.3", "@rollup/rollup-freebsd-arm64": "4.28.0",
"@rollup/rollup-freebsd-x64": "4.34.3", "@rollup/rollup-freebsd-x64": "4.28.0",
"@rollup/rollup-linux-arm-gnueabihf": "4.34.3", "@rollup/rollup-linux-arm-gnueabihf": "4.28.0",
"@rollup/rollup-linux-arm-musleabihf": "4.34.3", "@rollup/rollup-linux-arm-musleabihf": "4.28.0",
"@rollup/rollup-linux-arm64-gnu": "4.34.3", "@rollup/rollup-linux-arm64-gnu": "4.28.0",
"@rollup/rollup-linux-arm64-musl": "4.34.3", "@rollup/rollup-linux-arm64-musl": "4.28.0",
"@rollup/rollup-linux-loongarch64-gnu": "4.34.3", "@rollup/rollup-linux-powerpc64le-gnu": "4.28.0",
"@rollup/rollup-linux-powerpc64le-gnu": "4.34.3", "@rollup/rollup-linux-riscv64-gnu": "4.28.0",
"@rollup/rollup-linux-riscv64-gnu": "4.34.3", "@rollup/rollup-linux-s390x-gnu": "4.28.0",
"@rollup/rollup-linux-s390x-gnu": "4.34.3", "@rollup/rollup-linux-x64-gnu": "4.28.0",
"@rollup/rollup-linux-x64-gnu": "4.34.3", "@rollup/rollup-linux-x64-musl": "4.28.0",
"@rollup/rollup-linux-x64-musl": "4.34.3", "@rollup/rollup-win32-arm64-msvc": "4.28.0",
"@rollup/rollup-win32-arm64-msvc": "4.34.3", "@rollup/rollup-win32-ia32-msvc": "4.28.0",
"@rollup/rollup-win32-ia32-msvc": "4.34.3", "@rollup/rollup-win32-x64-msvc": "4.28.0",
"@rollup/rollup-win32-x64-msvc": "4.34.3",
"fsevents": "~2.3.2" "fsevents": "~2.3.2"
} }
}, },
@ -1115,9 +743,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.7.3", "version": "5.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
"license": "Apache-2.0", "license": "Apache-2.0",
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -1134,14 +762,14 @@
"peer": true "peer": true
}, },
"node_modules/vite": { "node_modules/vite": {
"version": "6.1.1", "version": "6.0.7",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.1.1.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.7.tgz",
"integrity": "sha512-4GgM54XrwRfrOp297aIYspIti66k56v16ZnqHvrIM7mG+HjDlAwS7p+Srr7J6fGvEdOJ5JcQ/D9T7HhtdXDTzA==", "integrity": "sha512-RDt8r/7qx9940f8FcOIAH9PTViRrghKaK2K1jY3RaAURrEUbm9Du1mJ72G+jlhtG3WwodnfzY8ORQZbBavZEAQ==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"esbuild": "^0.24.2", "esbuild": "^0.24.2",
"postcss": "^8.5.2", "postcss": "^8.4.49",
"rollup": "^4.30.1" "rollup": "^4.23.0"
}, },
"bin": { "bin": {
"vite": "bin/vite.js" "vite": "bin/vite.js"

View File

@ -9,11 +9,11 @@
}, },
"dependencies": { "dependencies": {
"react-dom": "19.0.0", "react-dom": "19.0.0",
"typescript": "5.7.3", "typescript": "5.7.2",
"vite": "6.1.1" "vite": "6.0.7"
}, },
"devDependencies": { "devDependencies": {
"@types/react-dom": "19.0.4", "@types/react-dom": "19.0.2",
"@vitejs/plugin-react-swc": "3.8.0" "@vitejs/plugin-react-swc": "3.7.2"
} }
} }

View File

@ -1,14 +1,24 @@
import { useState } from "react"; import { useState } from "react";
import GetBackendUrl from "./components/ImageModerator/GetBackendUrl";
import ImageModerator from "./components/ImageModerator/ImageModerator"; import ImageModerator from "./components/ImageModerator/ImageModerator";
import Login from "./components/Login/Login";
function App() { function App() {
const [backendUrl, setBackendUrl] = useState(""); const [{ apiUrl, middlewareUrl, token }, setRemote] = useState({
apiUrl: "",
middlewareUrl: "",
token: "",
});
if (backendUrl) { if (token) {
return <ImageModerator backendUrl={backendUrl} />; return (
<ImageModerator
token={token}
apiUrl={apiUrl}
middlewareUrl={middlewareUrl}
/>
);
} else { } else {
return <GetBackendUrl setRemote={setBackendUrl} />; return <Login setRemote={setRemote} />;
} }
} }

View File

@ -1,64 +0,0 @@
import { useEffect, useState } from "react";
export default function GetBackendUrl({ setRemote }: { setRemote: Function }) {
const sendLabel = "Input Backend URL";
const [backendUrl, setBackendUrl] = useState("");
function sendAction() {
event?.preventDefault();
try {
if (backendUrl) {
localStorage.setItem("backendUrl", backendUrl);
}
} catch (error) {
console.error(error);
}
setRemote(backendUrl);
}
function handleChange(
e: {
target: { value: React.SetStateAction<string> };
},
setter: React.Dispatch<React.SetStateAction<string>>
): void {
setter(e.target.value);
}
useEffect(() => {
const savedRemote = localStorage.getItem("backendUrl");
if (savedRemote) {
setRemote(savedRemote);
}
}, []);
return (
<div
style={{
height: "100vh",
width: "100vw",
}}>
<form
style={{
height: "100%",
width: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
onSubmit={sendAction}>
<label>Backend URL: </label>
<input
type="url"
id="backend"
name="backend"
value={backendUrl}
onChange={(e) => handleChange(e, setBackendUrl)}
/>
<button type="submit">{sendLabel}</button>
</form>
</div>
);
}

View File

@ -2,45 +2,50 @@ import { useEffect, useState } from "react";
import Button from "../Button/Button"; import Button from "../Button/Button";
interface ImageModeratorProps { interface ImageModeratorProps {
backendUrl: string; token: string;
apiUrl: string;
middlewareUrl: string;
} }
export default function ImageModerator({ backendUrl }: ImageModeratorProps) { export default function ImageModerator({
token,
apiUrl,
middlewareUrl,
}: ImageModeratorProps) {
const acceptLabel = "Accept"; const acceptLabel = "Accept";
const discardLabel = "Discard"; const discardLabel = "Discard";
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [imageData, setImageData] = useState({ const [imageData, setImageData] = useState({ url: "", tags: [] });
url: "", const [imageAlt, setImageAlt] = useState("No image");
token: "",
alt: "No image",
});
function acceptAction() { function acceptAction() {
fetch(`${backendUrl}/image/review`, { fetch(`${apiUrl}/images`, {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
url: imageData.url, url: imageData.url,
token: imageData.token, status: "available",
is_accepted: true, tags: imageData.tags,
}), }),
headers: { headers: {
"Content-type": "application/json", "Content-type": "application/json",
Authorization: `Bearer ${token}`,
}, },
}); });
setIsLoading(true); setIsLoading(true);
} }
function discardAction() { function discardAction() {
fetch(`${backendUrl}/image/review`, { fetch(`${apiUrl}/images`, {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
url: imageData.url, url: imageData.url,
token: imageData.token, status: "unavailable",
is_accepted: false, tags: imageData.tags,
}), }),
headers: { headers: {
"Content-type": "application/json", "Content-type": "application/json",
Authorization: `Bearer ${token}`,
}, },
}); });
setIsLoading(true); setIsLoading(true);
@ -48,8 +53,8 @@ export default function ImageModerator({ backendUrl }: ImageModeratorProps) {
const getNewImage = () => { const getNewImage = () => {
if (isLoading) { if (isLoading) {
setImageData({ url: "", token: "", alt: "Loading..." }); setImageData({ url: "", tags: [] });
fetch(`${backendUrl}/image`, { fetch(`${middlewareUrl}/image`, {
method: "GET", method: "GET",
}) })
.then((response) => { .then((response) => {
@ -57,10 +62,13 @@ export default function ImageModerator({ backendUrl }: ImageModeratorProps) {
return response.json(); return response.json();
}) })
.then((data) => { .then((data) => {
setImageData({ url: data.url, token: data.token, alt: data.url }); const url = data.url;
const tags = data.tags;
setImageData({ url, tags });
setImageAlt(url);
}) })
.catch((error) => { .catch((error) => {
setImageData({ url: "", token: "", alt: "Error" }); setImageAlt("Error");
console.error(error); console.error(error);
}) })
.finally(() => { .finally(() => {
@ -86,7 +94,7 @@ export default function ImageModerator({ backendUrl }: ImageModeratorProps) {
) : ( ) : (
<img <img
src={imageData.url} src={imageData.url}
alt={imageData.alt} alt={imageAlt}
style={{ style={{
width: "100%", width: "100%",
height: "100%", height: "100%",

View File

@ -0,0 +1,111 @@
import { useEffect, useState } from "react";
export default function Login({ setRemote }: { setRemote: Function }) {
const sendLabel = "Login";
const [middlewareUrl, setMiddlewareUrl] = useState("");
const [apiUrl, setApiUrl] = useState("");
const [app, setApp] = useState("");
const [secret, setSecret] = useState("");
function sendAction() {
event?.preventDefault();
try {
if (apiUrl && middlewareUrl && app && secret) {
localStorage.setItem(
"credentials",
JSON.stringify({ apiUrl, middlewareUrl, app, secret })
);
}
} catch (error) {
console.error(error);
}
fetch(`${apiUrl}/login`, {
method: "POST",
body: JSON.stringify({ app, secret }),
headers: { "Content-type": "application/json" },
})
.then((response) => {
return response.json();
})
.then((body) => {
setRemote({ apiUrl, middlewareUrl, token: body.token });
});
}
function handleChange(
e: {
target: { value: React.SetStateAction<string> };
},
setter: React.Dispatch<React.SetStateAction<string>>
): void {
setter(e.target.value);
}
useEffect(() => {
const savedRemote = localStorage.getItem("credentials");
if (savedRemote) {
const savedData = JSON.parse(savedRemote);
setApiUrl(savedData.apiUrl);
setMiddlewareUrl(savedData.middlewareUrl);
setApp(savedData.app);
setSecret(savedData.secret);
}
}, []);
useEffect(() => {
if (secret) {
sendAction();
}
}, [secret]);
return (
<div
style={{
height: "100vh",
width: "100vw",
}}>
<form
style={{
height: "100%",
width: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
onSubmit={sendAction}>
<label>API URL: </label>
<input
type="url"
id="api"
name="api"
value={apiUrl}
onChange={(e) => handleChange(e, setApiUrl)}
/>
<label>Source URL: </label>
<input
type="url"
id="middleware"
name="middleware"
value={middlewareUrl}
onChange={(e) => handleChange(e, setMiddlewareUrl)}
/>
<label>App name: </label>
<input
type="text"
id="username"
name="username"
value={app}
onChange={(e) => handleChange(e, setApp)}
/>
<label>Secret: </label>
<input
type="password"
value={secret}
onChange={(e) => handleChange(e, setSecret)}
/>
<button type="submit">{sendLabel}</button>
</form>
</div>
);
}