- Select latest successful workflow run from here .
- Then scroll to bottom and download artifact . A zip will be downloaded to your system
- Extract the zip .
- You will have two binaries
arakoo
(this is runtime) andarakoo-compiler
(this is our extended javy compiler) - Copy these two binaries to
~/.local/bin
or/usr/bin
(if you want all users to access the binaries ) - Open terminal and grant executable permission to copied binaries by running
chmod +x "<path of copied arakoo-compiler>"
andchmod +x "<path of copied arakoo>"
You are now good to go ! Have look at below section which describe how you can create apis in hono and compile them to wasm
- Open Terminal
- Create a new directory
helloworld
by runningmkdir helloworld && cd helloworld
- Initialize it
npm init -y
- Add
"type":"module"
in package.json to use es6 syntax. - Install hono
npm install hono@^3.9
(as of now only this hono version is supported) - Create a
index.js
file and open it with your favourite editor. - Paste below code in it
import {Hono} from "hono";
const app = new Hono();
app.get("/hello", async (c)=>{
return c.json({message : "hello world"})
})
app.fire();
- Now since javy doesn't have capability to require or import module . So we will bundle the index.js with esbuild.
- To do so , install esbuild as developer dependency
npm install esbuild --save-dev
- Create a build file
build.js
- Paste below code in it
import {build} from "esbuild";
build({
entryPoints: ["index.js"], // specify input file ( in this case this the index.js file we created earlier)
bundle: true, // this allows esbuild to find all dependencies and bundle them together in one file
outfile: "dist.js", // the name of the output bundle file you desire ( in this case we named it dist.js
platform:"node",
}).catch((error)=>{
console.log("Error ",error);
process.exit(1);
})
- Now compile bundled file with javy
arakoo-compiler dist.js
- You should see a new file
index.wasm
in the directory
You can execute the compiled wasm with installed arakoo
runtime.
To do so simple run
arakoo index.wasm
You should see output as -
Send get request to http://localhost:8080/hello to test the api. You should get response as shown below -