Skip to content

Commit

Permalink
Bundle dashboard with worker assets
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Dec 14, 2024
1 parent 5d12c10 commit 465f5f5
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 374 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ my-r2-explorer
packages/worker/bin
packages/worker/README.md
packages/worker/LICENSE
packages/worker/dist
packages/worker/dashboard

packages/worker/dev/.wrangler

Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run lint
10 changes: 6 additions & 4 deletions packages/dashboard/src/stores/main-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export const useMainStore = defineStore("main", {
state: () => ({
// Config
apiReadonly: true,
username: "",
authentication_type: "",
authentication_username: "",
version: "",
dashboardUrl: "",
showHiddenFiles: false,

// Frontend data
Expand Down Expand Up @@ -37,9 +37,11 @@ export const useMainStore = defineStore("main", {
});

this.apiReadonly = response.data.config.readonly;
this.username = response.data.config.user?.username;
this.authentication_type =
response.data.config.auth?.authentication_type;
this.authentication_username =
response.data.config.auth?.authentication_username;
this.version = response.data.config.version;
this.dashboardUrl = response.data.config.dashboardUrl;
this.showHiddenFiles = response.data.config.showHiddenFiles;
} catch (error) {
console.log(error);
Expand Down
4 changes: 1 addition & 3 deletions packages/worker/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { R2Explorer } from "../src";
const baseConfig = {
readonly: false,
cors: true,
showHiddenFiles: true,
dashboardUrl: "https://dev.r2-explorer-dashboard.pages.dev/",
cacheAssets: false,
showHiddenFiles: true
};

export default {
Expand Down
3 changes: 2 additions & 1 deletion packages/worker/dev/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name = "my-r2-explorer"
compatibility_date = "2023-05-12"
compatibility_date = "2024-11-06"
main = "index.ts"
workers_dev = true
assets = { directory = "../../dashboard/dist/spa", binding = "ASSETS", html_handling = "auto-trailing-slash", not_found_handling = "single-page-application" }

[[r2_buckets]]
binding = 'teste'
Expand Down
25 changes: 15 additions & 10 deletions packages/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"name": "r2-explorer",
"version": "0.0.1",
"version": "1.1.0",
"description": "A Google Drive Interface for your Cloudflare R2 Buckets",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": ["dist", "LICENSE", "README.md"],
"main": "./index.js",
"module": "./index.mjs",
"types": "./index.d.ts",
"files": [
"dashboard",
"dist",
"LICENSE",
"README.md"
],
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"build": "tsup src/index.ts --format cjs,esm --dts && cp -R ../dashboard/dist/spa/ dashboard/ && cp ../../README.md . && cp ../../LICENSE .",
"lint": "npx @biomejs/biome check src/ tests/ || (npx @biomejs/biome check --write src/ tests/; exit 1)",
"test": "vitest run --root tests",
"prepare": "husky",
"package": "npm run build && npm pack"
},
"publishConfig": {
Expand Down Expand Up @@ -54,9 +58,10 @@
"wrangler": "^3.91.0"
},
"dependencies": {
"chanfana": "^2.4.2",
"hono": "^4.6.12",
"@hono/cloudflare-access": "^0.1.0",
"chanfana": "^2.5.1",
"hono": "^4.6.14",
"postal-mime": "^2.3.2",
"zod": "^3.23.8"
"zod": "^3.24.1"
}
}
55 changes: 0 additions & 55 deletions packages/worker/src/foundation/dashbord.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/worker/src/foundation/dates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export function getCurrentTimestampSeconds(): number {
return Math.floor(Date.now() / 1000);
}

export function getCurrentTimestampMilliseconds(): number {
return Math.floor(Date.now());
}
Loading

0 comments on commit 465f5f5

Please sign in to comment.