Skip to content

Commit 803c475

Browse files
committed
Update dependencies in tldraw-sync-worker, removing outdated Cloudflare types and adding workers-types. Refactor TldrawDurableObject to specify type for schedulePersistToR2. Adjust router type definitions in worker.ts for improved clarity.
1 parent 03f8ac7 commit 803c475

4 files changed

Lines changed: 15 additions & 61 deletions

File tree

apps/tldraw-sync-worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"check-types": "tsc --noEmit -p tsconfig.json"
1111
},
1212
"dependencies": {
13-
"@cloudflare/types": "^6.29.0",
1413
"@tldraw/sync-core": "2.4.6",
1514
"@tldraw/tlschema": "2.4.6",
1615
"cloudflare-workers-unfurl": "^0.0.7",
1716
"itty-router": "^5.0.17",
1817
"lodash.throttle": "^4.1.1"
1918
},
2019
"devDependencies": {
20+
"@cloudflare/workers-types": "^4.20240208.0",
2121
"@types/lodash.throttle": "^4",
2222
"typescript": "^5.0.2",
2323
"wrangler": "^3.64.0"

apps/tldraw-sync-worker/worker/TldrawDurableObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class TldrawDurableObject {
191191
}
192192

193193
// we throttle persistance so it only happens every 10 seconds
194-
schedulePersistToR2 = throttle(async () => {
194+
schedulePersistToR2: () => void = throttle(async () => {
195195
if (!this.roomPromise || !this.roomId) return
196196
const room = await this.getRoom()
197197

apps/tldraw-sync-worker/worker/worker.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ export { TldrawDurableObject } from "./TldrawDurableObject";
88
// we use itty-router (https://itty.dev/) to handle routing. in this example we turn on CORS because
99
// we're hosting the worker separately to the client. you should restrict this to your own domain.
1010
const { preflight, corsify } = cors({ origin: "*" });
11-
const router = AutoRouter<
12-
IRequest,
13-
[env: Environment, ctx: unknown /* ExecutionContext */]
14-
>({
11+
const router = AutoRouter<IRequest, [env: Environment, ctx: ExecutionContext]>({
1512
before: [preflight],
1613
finally: [corsify],
1714
catch: (e) => {
18-
console.error(e); // eslint-disable-line no-console ?
15+
console.error(e);
1916
return error(e);
2017
},
2118
})
@@ -29,13 +26,6 @@ const router = AutoRouter<
2926
});
3027
})
3128

32-
// We store assest in native apps
33-
// assets can be uploaded to the bucket under /uploads:
34-
// .post("/uploads/:uploadId", handleAssetUpload)
35-
36-
// they can be retrieved from the bucket too:
37-
// .get("/uploads/:uploadId", handleAssetDownload)
38-
3929
// bookmarks need to extract metadata from pasted URLs:
4030
.get("/unfurl", handleUnfurlRequest);
4131

pnpm-lock.yaml

Lines changed: 11 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)