An open API service indexing awesome lists of open source software.

https://github.com/yoav-lavi/deno-deploy-rust-template

A template for creating Deno Deploy projects in Rust
https://github.com/yoav-lavi/deno-deploy-rust-template

deno deno-deploy rust template

Last synced: about 1 year ago
JSON representation

A template for creating Deno Deploy projects in Rust

Awesome Lists containing this project

README

          



deno-deploy-rust-template



A template for creating Deno Deploy projects in Rust

## Prerequisites

- [`cargo-generate`](https://github.com/cargo-generate/cargo-generate)
- [`cargo-make`](https://github.com/sagiegurari/cargo-make#installation)

Prerequisites for usage without cargo-make


## Usage

> **Note**
>
> If using `cargo make`, any commands requiring `deno` will attempt to install `deno` via `cargo`, if it is not already installed and in your `$PATH`.
> If you want to install `deno` via other means and haven't already, do so before running any `cargo make` commands.

### Using this template

```sh
cargo generate gh:yoav-lavi/deno-deploy-rust-template
```

### Building your project

```sh
cargo make build-wasm
```

Manual command


rustup target add wasm32-unknown-unknown
&& cargo build --release --target wasm32-unknown-unknown
&& wasm-bindgen target/wasm32-unknown-unknown/release/{{crate_name}}.wasm --target deno --out-dir build/

### Deploying to Deno Deploy

> **Note**
>
> Create a new token in the Deno Deploy (under "Access Tokens") and use it in place of `...` in `DENO_DEPLOY_TOKEN=...`
>
> If `~/.deno/bin` is not in your `$PATH`, you will need to add it for this command to work

```sh
DENO_DEPLOY_TOKEN=... cargo make deploy
```

Manual command


deployctl deploy --token=... --project={{deno-deploy-project-name}} src/index.ts --exclude "target/"

### Running your project with Deno

```sh
cargo make run
```

Manual command


deno run --allow-read --allow-net --allow-env src/index.ts

### Running tests

```sh
cargo make test-rust
cargo make test-integration
```

Manual command


cargo test --target wasm32-unknown-unknown
deno test --allow-read --allow-net --allow-env tests/integration.ts