Skip to content
A Cloudflare wrangler template for a AssemblyScript worker
WebAssembly TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assembly
build
src
test
.cargo-ok
.gitignore
.prettierrc
README.md
package-lock.json
package.json
tsconfig.json
webpack.config.js
wrangler.toml

README.md

worker-assemblyscript-template

A batteries included template for kick starting a AssemblyScript Cloudflare worker project. The template is based on the TypeScript template, so uses TypeScript for the request handler.

AssemblyScript compiles a strict subset of TypeScript (a typed superset of JavaScript) to WebAssembly using Binaryen.

🔋 Getting Started

This template is meant to be used with wrangler. If you are not already familiar with the tool, we recommend that you install the tool and configure it to work with your Cloudflare account.

To generate using wrangler, run this command:

wrangler generate my-asc-project https://github.com/JamesLMilner/worker-assemblyscript-template

👩 💻 Developing

src/index.js calls the request handler in src/handler.ts, and will return the request method for the given request.

For your AssemblyScript code you can edit assembly/index.ts and call npm run asbuild to see your changes. To build the whole worker you can do npm run build, which will build your TypeScript and AssemblyScript.

🧪 Testing

This template comes with mocha tests which simply test that the request handler can handle each request method. npm test will run your tests.

✏️ Formatting

This template uses prettier to format the project. To invoke, run npm run format.

👀 Previewing and Publishing

For information on how to preview and publish your worker, please see the wrangler README.

🤢 Issues

If you run into issues with this specific project, please feel free to file an issue here. If the problem is with wrangler, please file an issue here.

⚠️ Caveats

The service-worker-mock used by the tests is not a perfect representation of the Cloudflare Workers runtime. It is a general approximation. We recommend that you test with wrangler preview and in a staging environment to test things before deploying.

Acknowledgements

This template is in turn based off of the Cloudflare TypeScript template available here.

You can’t perform that action at this time.