Skip to content

Commit

Permalink
fix: add durable object types
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Feb 2, 2022
1 parent c0b2c3e commit fafcad3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.1.1",
"@cloudflare/workers-types": "^3.3.1",
"@sentry/cli": "^1.71.0",
"@sentry/webpack-plugin": "^1.16.0",
"@types/debug": "^4.1.5",
Expand Down
1 change: 1 addition & 0 deletions packages/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"toucan-js": "^2.5.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.3.1",
"@sentry/cli": "^1.71.0",
"ava": "^3.15.0",
"delay": "^5.0.0",
Expand Down
30 changes: 26 additions & 4 deletions packages/gateway/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Toucan from 'toucan-js'
import pkg from '../package.json'
import { Logging } from './logs.js'

// TODO: Get Durable object typedef
/**
* @typedef {Object} EnvInput
* @property {string} IPFS_GATEWAYS
Expand All @@ -20,9 +19,9 @@ import { Logging } from './logs.js'
*
* @typedef {Object} EnvTransformed
* @property {Array<string>} ipfsGateways
* @property {Object} gatewayMetricsDurable
* @property {Object} summaryMetricsDurable
* @property {Object} cidsTrackerDurable
* @property {DurableObjectNamespace} gatewayMetricsDurable
* @property {DurableObjectNamespace} summaryMetricsDurable
* @property {DurableObjectNamespace} cidsTrackerDurable
* @property {number} REQUEST_TIMEOUT
* @property {Toucan} [sentry]
* @property {Logging} [log]
Expand Down Expand Up @@ -72,3 +71,26 @@ function getSentry(request, env) {
pkg,
})
}

/**
* From: https://github.com/cloudflare/workers-types
*
* @typedef {{
* toString(): string
* equals(other: DurableObjectId): boolean
* readonly name?: string
* }} DurableObjectId
*
* @typedef {{
* newUniqueId(options?: { jurisdiction?: string }): DurableObjectId
* idFromName(name: string): DurableObjectId
* idFromString(id: string): DurableObjectId
* get(id: DurableObjectId): DurableObjectStub
* }} DurableObjectNamespace
*
* @typedef {{
* readonly id: DurableObjectId
* readonly name?: string
* fetch(requestOrUrl: Request | string, requestInit?: RequestInit | Request): Promise<Response>
* }} DurableObjectStub
*/
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@
resolved "https://registry.yarnpkg.com/@cfworker/json-schema/-/json-schema-1.12.1.tgz#8b151da771678d37bf77c5eda87b1137b2b009c8"
integrity sha512-ZVhk1DKw19sBJgO7OHBsvNAzDfHMzpFI0DCkOLTZHb0dccmS+EM8rwwAYh5eaNmD5t8/nCbZ2ZeGzbDQdOzokQ==

"@cloudflare/workers-types@^3.1.1":
"@cloudflare/workers-types@^3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@cloudflare/workers-types/-/workers-types-3.3.1.tgz#8847543bda320472252708c29aaf7bac3374e814"
integrity sha512-GJFDgWd8ZHlr/m+Q2mp4xUl0/FIPpR6kf0Ix2C78E9HeJyUCW0c0w2EKCvgEDFFKB2rkzIX3eBqZCnLsbsw8zQ==
Expand Down

0 comments on commit fafcad3

Please sign in to comment.