14 Commits

Author SHA1 Message Date
Emrik Östling
b28977ffe2 Merge pull request #136 from C4illin/release-please--branches--main--components--convertx-frontend 2024-09-21 14:33:34 +02:00
deepsource-io[bot]
a47bb682a5 ci: add .deepsource.toml 2024-09-20 14:28:59 +00:00
C4illin
a17eca0a09 chore: format 2024-09-20 13:27:54 +02:00
Emrik Östling
ea9250543e chore(main): release 0.5.0 2024-09-20 13:24:55 +02:00
C4illin
317c932c2a feat: add option to customize how often files are automatically deleted 2024-09-20 13:24:18 +02:00
C4illin
5b1703db68 chore: add safe attribute to input element 2024-09-20 12:55:00 +02:00
C4illin
60ba7c93fb fix: improve file name replacement logic 2024-09-20 12:49:19 +02:00
C4illin
22227130dd chore: add screenshot, fixes #110 2024-09-20 12:42:58 +02:00
Emrik Östling
5daf66f5d0 Merge pull request #135 from C4illin/renovate/oven-bun-1.x 2024-09-20 12:30:55 +02:00
renovate[bot]
aee1962607 chore(deps): update oven/bun docker tag to v1.1.29 2024-09-20 09:09:55 +00:00
Emrik Östling
0d42762b36 Merge pull request #134 from C4illin/renovate/biomejs-biome-1.x 2024-09-19 17:51:12 +02:00
renovate[bot]
b97b12b449 chore(deps): update dependency @biomejs/biome to v1.9.2 2024-09-19 14:43:48 +00:00
Emrik Östling
bdf651df82 Merge pull request #133 from C4illin/renovate/oven-bun-1.x
chore(deps): update oven/bun docker tag to v1.1.28
2024-09-19 09:35:06 +02:00
renovate[bot]
267ef14789 chore(deps): update oven/bun docker tag to v1.1.28 2024-09-18 20:12:09 +00:00
10 changed files with 59 additions and 18 deletions

7
.deepsource.toml Normal file
View File

@@ -0,0 +1,7 @@
version = 1
[[analyzers]]
name = "javascript"
[analyzers.meta]
environment = ["nodejs"]

View File

@@ -1,5 +1,17 @@
# Changelog
## [0.5.0](https://github.com/C4illin/ConvertX/compare/v0.4.1...v0.5.0) (2024-09-20)
### Features
* add option to customize how often files are automatically deleted ([317c932](https://github.com/C4illin/ConvertX/commit/317c932c2a26280bf37ed3d3bf9b879413590f5a))
### Bug Fixes
* improve file name replacement logic ([60ba7c9](https://github.com/C4illin/ConvertX/commit/60ba7c93fbdc961f3569882fade7cc13dee7a7a5))
## [0.4.1](https://github.com/C4illin/ConvertX/compare/v0.4.0...v0.4.1) (2024-09-15)

View File

@@ -1,4 +1,4 @@
FROM oven/bun:1.1.27-alpine AS base
FROM oven/bun:1.1.29-alpine AS base
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
WORKDIR /app

View File

@@ -47,6 +47,7 @@ services:
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
- HTTP_ALLOWED=false # setting this to true is unsafe, only set this to true locally
- ALLOW_UNAUTHENTICATED=false # allows anyone to use the service without logging in, only set this to true locally
- AUTO_DELETE_EVERY_N_HOURS=24 # checks every n hours for files older then n hours and deletes them, set to 0 to disable
volumes:
- convertx:/app/data
```
@@ -65,6 +66,10 @@ If you get unable to open database file run `chown -R $USER:$USER path` on the p
Tutorial in french: https://belginux.com/installer-convertx-avec-docker/
## Screenshots
![ConvertX Preview](images/preview.png)
## Development
0. Install [Bun](https://bun.sh/) and Git

View File

@@ -10,7 +10,7 @@
"attributePosition": "auto"
},
"files": {
"ignore": ["**/node_modules/**"]
"ignore": ["**/node_modules/**", "**/pico.lime.min.css"]
},
"organizeImports": { "enabled": true },
"linter": {

BIN
bun.lockb

Binary file not shown.

BIN
images/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -1,6 +1,6 @@
{
"name": "convertx-frontend",
"version": "0.4.1",
"version": "0.5.0",
"scripts": {
"dev": "bun run --watch src/index.tsx",
"hot": "bun run --hot src/index.tsx",
@@ -24,7 +24,7 @@
"start": "bun run src/index.tsx"
},
"devDependencies": {
"@biomejs/biome": "1.9.1",
"@biomejs/biome": "1.9.2",
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.9.1",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",

View File

@@ -33,6 +33,9 @@ const HTTP_ALLOWED =
process.env.HTTP_ALLOWED?.toLowerCase() === "true" || false;
const ALLOW_UNAUTHENTICATED =
process.env.ALLOW_UNAUTHENTICATED?.toLowerCase() === "true" || false;
const AUTO_DELETE_EVERY_N_HOURS = process.env.AUTO_DELETE_EVERY_N_HOURS
? Number(process.env.AUTO_DELETE_EVERY_N_HOURS)
: 24;
// fileNames: fileNames,
// filesToConvert: fileNames.length,
@@ -543,9 +546,11 @@ const app = new Elysia({
style={{
borderColor: "gray",
padding: "2px",
}}>
}}
>
<header
style={{ fontSize: "20px", fontWeight: "bold" }}>
style={{ fontSize: "20px", fontWeight: "bold" }}
safe>
{converter}
</header>
@@ -567,7 +572,9 @@ const app = new Elysia({
data-target={target}
data-converter={converter}
style={{ fontSize: "15px", padding: "5px" }}
type="button">
type="button"
safe
>
{target}
</button>
))}
@@ -638,8 +645,9 @@ const app = new Elysia({
style={{
borderColor: "gray",
padding: "2px",
}}>
<header style={{ fontSize: "20px", fontWeight: "bold" }}>
}}
>
<header style={{ fontSize: "20px", fontWeight: "bold" }} safe>
{converter}
</header>
@@ -661,7 +669,9 @@ const app = new Elysia({
data-target={target}
data-converter={converter}
style={{ fontSize: "15px", padding: "5px" }}
type="button">
type="button"
safe
>
{target}
</button>
))}
@@ -828,7 +838,10 @@ const app = new Elysia({
const fileTypeOrig = fileName.split(".").pop() ?? "";
const fileType = normalizeFiletype(fileTypeOrig);
const newFileExt = normalizeOutputFiletype(convertTo);
const newFileName = fileName.replace(fileTypeOrig, newFileExt);
const newFileName = fileName.replace(
new RegExp(`${fileTypeOrig}(?!.*${fileTypeOrig})`),
newFileExt,
);
const targetPath = `${userOutputDir}${newFileName}`;
const result = await mainConverter(
@@ -1253,12 +1266,14 @@ console.log(
);
const clearJobs = () => {
// clear all jobs older than 24 hours
// get all files older than 24 hours
const jobs = db
.query("SELECT * FROM jobs WHERE date_created < ?")
.as(Jobs)
.all(new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString());
.all(
new Date(
Date.now() - AUTO_DELETE_EVERY_N_HOURS * 60 * 60 * 1000,
).toISOString(),
);
for (const job of jobs) {
// delete the directories
@@ -1269,7 +1284,9 @@ const clearJobs = () => {
db.query("DELETE FROM jobs WHERE id = ?").run(job.id);
}
// run every 24 hours
setTimeout(clearJobs, 24 * 60 * 60 * 1000);
setTimeout(clearJobs, AUTO_DELETE_EVERY_N_HOURS * 60 * 60 * 1000);
};
clearJobs();
if (AUTO_DELETE_EVERY_N_HOURS > 0) {
clearJobs();
}

View File

@@ -4,7 +4,7 @@ div.icon {
}
button[type="submit"] {
width: 50%
width: 50%;
}
div.center {