Skip to content

Commit 816c5a3

Browse files
committed
feat: resize images to 2 sizes and upload them to R2
refactor: lots of refactoring to backend and client WIP: ``` // TODO read rustwasm/wasm-bindgen#111 and use some workaround to send ImagesBytes to server. ```
1 parent 97cb29c commit 816c5a3

29 files changed

+4295
-2947
lines changed

backend/.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,9 @@ dist
171171
.dev.vars
172172

173173
# python
174-
venv
174+
venv
175+
rust/target
176+
.idea
177+
178+
# Generated files
179+
src/wasm

backend/README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,38 @@
66

77
## Useful commands:
88

9+
### Prerequisites
10+
- Optional: [install wrangler globally](https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler-globally) by running `npm install --global wrangler`
11+
912
### For backend
10-
- Run backend locally: `npx wrangler dev`
11-
- Deploy backend application: `npx wrangler publish`
12-
- Read logs in realtime: `npx wrangler tail`
13+
- Install dependencies: `pnpm i`
14+
- Run backend locally: `wrangler dev`
15+
- Deploy backend application: `wrangler publish`
16+
- Read logs in realtime: `wrangler tail`
17+
- Warning: if you use the wrong imports (unoptimised), the worker can be quite large.
18+
- The maximum it can be is 5MB. Currently, it is `Total Upload: 1722.06 KiB / gzip: 570.04 KiB`.
1319
- Reset database to `schema.sql`:
14-
- Reset preview database: `npx wrangler d1 execute banananator_preview --file schemas/schema.sql`
15-
- Reset production database: `npx wrangler d1 execute banananator --file schemas/schema.sql`
20+
- Reset preview database: `wrangler d1 execute banananator_preview --file schemas/schema.sql`
21+
- Reset production database: `wrangler d1 execute banananator --file schemas/schema.sql`
22+
23+
## Rust worker compilation
24+
- Set up `.env` file containing token for accessing worker. Create one in https://dash.cloudflare.com/profile/api-tokens
25+
- Build image and start container: `docker-compose up -d --build`
26+
- Enter container: `docker exec -it backend-development-1 bash`
27+
- Install wasm-pack: run `curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh`
28+
- Ensure it is the latest version from . Check your current version by running `wasm-pack -V`. Install using another method if necessary. I found reinstalling it with the same command fixed it.
29+
- Install worker-build, run `cargo install -q worker-build`
30+
- Install wasm-bindegen: `cargo install wasm-bindgen-cli`
31+
- Install rust using [rust-up](https://rustup.rs/): run `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
32+
- Launch the backend dev server: run `wrangler dev`
1633

1734
### For client
1835
- Deploy web application:
1936
- `cd ../client/`
2037
- `flutter build web`
2138
- `cd -`
22-
- `npx wrangler pages publish ../client/build/web --project-name=banananator`
23-
- To deploy fragile version, run: `npx wrangler pages publish ../client/build/web --project-name=banananator-fragile`
39+
- `wrangler pages publish ../client/build/web --project-name=banananator`
40+
- To deploy fragile version, run: `wrangler pages publish ../client/build/web --project-name=banananator-fragile`
2441
- See https://developers.cloudflare.com/pages/platform/direct-upload/#wrangler-cli
2542

2643

0 commit comments

Comments
 (0)