Jump to content

Help:Toolforge/Deno

From Wikitech

Deno is not natively installed in Toolforge. However, it can still be used fairly well through user level installations. In this tutorial, we will use the Node.js image.

Installation

To install Deno, login to a the Toolforge bastion, become your tool, and run:[1]

curl -fsSL https://deno.land/install.sh | sh

It is recommended to examine the script before executing it.

Add the following to your .profile or .bashrc, to put deno in the PATH variable:

export PATH=~/.deno/bin:$PATH

Setting up Deno application

As with the conventions for Toolforge node.js applications, place your app code in $HOME/www/js directory. Running npm start must launch the service. So, add a package.json file that includes:

  "scripts": {
    "start": "~/.deno/bin/deno run -A src/main.ts"
  }

Note that we have to specify the full path to deno executable even though we added deno to PATH above. This is because your .profile is not executed when Kubernetes starts the deployment.

In src/main.ts, implement your app. A basic example to get you started:[2]

Deno.serve((_req) => {
  return new Response("Hello, World!");
});

Run webservice node18 start. By default, deno listens to connections on port 8000, the same port used in the Kubernetes image.

Navigate to <TOOLNAME>.toolforge.org. If all went well, you should see "Hello, World!" in your browser. If not, use kubectl logs deploy/<TOOLNAME> to see what went wrong.

Libraries

  • oak – HTTP server library for requirements not fulfilled by Deno standard library.
  • mwn – MediaWiki API client for node.js that works fine on Deno as well.

Starting with version 2, Deno is compatible with npm packages written for Node.js.[3] You may find these useful as well:

Communication and support

Support and administration of the WMCS resources is provided by the Wikimedia Foundation Cloud Services team and Wikimedia movement volunteers. Please reach out with questions and join the conversation:

Discuss and receive general support
Stay aware of critical changes and plans
Track work tasks and report bugs

Use a subproject of the #Cloud-Services Phabricator project to track confirmed bug reports and feature requests about the Cloud Services infrastructure itself

Read stories and WMCS blog posts

Read the Cloud Services Blog (for the broader Wikimedia movement, see the Wikimedia Technical Blog)

See also

References

  1. https://docs.deno.com/runtime/getting_started/installation/
  2. https://docs.deno.com/runtime/fundamentals/http_server
  3. https://docs.deno.com/runtime/fundamentals/node/