-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize Deno implementation and prepare for JSR #425
Conversation
Updates everything to be compatible with Deno v2 and prepares for publishing the packages to the [JSR](https://jsr.io) instead of the HTTPS based imports common before the JSR. The JSR doesn't allow for complex inferred types.[^1] Therefore, prior `z.infer<Schema>` types have been replaced with explicit interfaces. Instead of the pattern of having all dependencies defined in a `deps.ts`, it is now common practice (and requirement for the JSR) to have a `deno.json`, which acts in a similar way to the `package.json` in NodeJS. It also serves as an import map for dependencies, pinning their versions. Note that while it's possible to omit the `jsr:@scope/package` and just write `@scope/package` with this, to keep samples copy-pasteable without having to copy the import map, imports in the samples still use the "fully qualified" import, even though the respective versions are then pinned down using the `deno.json` file. In the `Dockerfile`s for the samples as well as the `docker-compose.yml` for development in the root `backend-deno` folder, the Deno base image was upgraded to Deno v2. The new NATS version doesn't use (or provide) the codec functions anymore.[^2] Therefore, the version upgrade also means that we no longer provide these as re-exported functions. Now, any publishing method also allows to pass a `string`, meaning one can just use something like: ```ts nc.publish(JSON.stringify({})); ``` Also, the `Msg` interface (any message received by NATS) now offers convenience methods for retrieving the payload as either `json()` or a `string()`. - JetStream is no longer included and has to be installed as `jsr:@nats-io/jetstream`; - KV (a key-value-storage) is no longer included, but available as `jsr:@nats-io/kv`. See <https://github.com/nats-io/nats.js/blob/e8520523a9b5316f436c44ef05ba2e50c4f6e60a/migration.md> for a full list of changes / migration guide. In `ensureMinimalConfig()` (which gets called by `startService()`), the function now throws an error instead of just printing it to the console and running `Deno.exit(1)`. This fixes various tests that failed with the upgraded Deno version. Note that I was unable to find the change that introduced the inabilities of tests to handle `Deno.exit(1)`. I just know that it worked previously, didn't anymore, and will now, with this change, work once again. [^1]: Cf. <https://jsr.io/docs/about-slow-types> [^2]: Cf. <https://github.com/nats-io/nats.js/blob/e8520523a9b5316f436c44ef05ba2e50c4f6e60a/migration.md#changes-in-nats-base-client>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 24 out of 24 changed files in this pull request and generated no suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for porting Telestion to JSR. 👍
I've found some small issues, the rest LGTM. 🌴
Suggested changes
In the docs main index.md
change the link to Deno from deno.land
to deno.com
.
See:
Line 26 in da1b36f
* [Deno](https://deno.land/) -- The runtime used by Telestion for TypeScript and JavaScript based services |
Thinks to to do once published
- update API reference link in
docs/docs/Backend Development/typescript/.pages
once package is on JSR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎆
I've seen, you've updated the Github Action modules on another PR.
It's okay from my side to merge this PR with its broken action runs. 😉
Updates everything to be compatible with Deno v2 and prepares for
publishing the packages to the JSR instead of
the HTTPS based imports common before the JSR.
The JSR doesn't allow for complex inferred types.1
Therefore, prior
z.infer<Schema>
types have been replaced withexplicit interfaces.
Instead of the pattern of having all dependencies defined in a
deps.ts
,it is now common practice (and requirement for the JSR) to have a
deno.json
,which acts in a similar way to the
package.json
in NodeJS. It also servesas an import map for dependencies, pinning their versions.
Note that while it's possible to omit the
jsr:@scope/package
and just write@scope/package
with this, to keep samples copy-pasteable without having tocopy the import map, imports in the samples still use the "fully qualified"
import, even though the respective versions are then pinned down using the
deno.json
file.In the
Dockerfile
s for the samples as well as thedocker-compose.yml
fordevelopment in the root
backend-deno
folder, the Deno base image was upgradedto Deno v2.
The new NATS version doesn't use (or provide) the codec functions anymore.2
Therefore, the version upgrade also means that we no longer provide these as
re-exported functions.
Now, any publishing method also allows to pass a
string
, meaning one can justuse something like:
Also, the
Msg
interface (any message received by NATS) now offers conveniencemethods for retrieving the payload as either
json()
or astring()
.jsr:@nats-io/jetstream
;jsr:@nats-io/kv
.See https://github.com/nats-io/nats.js/blob/e8520523a9b5316f436c44ef05ba2e50c4f6e60a/migration.md
for a full list of changes / migration guide.
In
ensureMinimalConfig()
(which gets called bystartService()
), the functionnow throws an error instead of just printing it to the console and running
Deno.exit(1)
. This fixes various tests that failed with the upgraded Deno version.Note that I was unable to find the change that introduced the inabilities of tests to
handle
Deno.exit(1)
. I just know that it worked previously, didn't anymore, and willnow, with this change, work once again.
Summary
n/a
Details
n/a
Additional information
n/a
Related links
CLA
Footnotes
Cf. https://jsr.io/docs/about-slow-types ↩
Cf. https://github.com/nats-io/nats.js/blob/e8520523a9b5316f436c44ef05ba2e50c4f6e60a/migration.md#changes-in-nats-base-client ↩