{"id":46913749,"url":"https://github.com/easegress-io/easegress-assemblyscript-sdk","last_synced_at":"2026-03-11T02:26:27.642Z","repository":{"id":46659194,"uuid":"386582476","full_name":"easegress-io/easegress-assemblyscript-sdk","owner":"easegress-io","description":"AssemblyScript SDK for Easegress","archived":false,"fork":false,"pushed_at":"2024-01-16T09:38:02.000Z","size":35,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-01-16T15:58:50.163Z","etag":null,"topics":["assemblyscript","easegress","webassembly"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/easegress-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-07-16T09:29:42.000Z","updated_at":"2024-01-16T15:58:54.767Z","dependencies_parsed_at":"2024-01-16T15:58:53.175Z","dependency_job_id":"1fc09e5f-7941-4947-9bd5-427e44feb70b","html_url":"https://github.com/easegress-io/easegress-assemblyscript-sdk","commit_stats":null,"previous_names":["easegress-io/easegress-assemblyscript-sdk"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/easegress-io/easegress-assemblyscript-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easegress-io%2Feasegress-assemblyscript-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easegress-io%2Feasegress-assemblyscript-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easegress-io%2Feasegress-assemblyscript-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easegress-io%2Feasegress-assemblyscript-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/easegress-io","download_url":"https://codeload.github.com/easegress-io/easegress-assemblyscript-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easegress-io%2Feasegress-assemblyscript-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30367814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assemblyscript","easegress","webassembly"],"created_at":"2026-03-11T02:26:27.082Z","updated_at":"2026-03-11T02:26:27.630Z","avatar_url":"https://github.com/easegress-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easegress AssemblyScript SDK\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feasegress-io%2Feasegress-assemblyscript-sdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Feasegress-io%2Feasegress-assemblyscript-sdk?ref=badge_shield)\n\n\n- [Easegress AssemblyScript SDK](#easegress-assemblyscript-sdk)\n\t- [Prerequisites](#prerequisites)\n\t- [Local Development](#local-development)\n\t- [Deploy and execute](#deploy-and-execute)\n\nThis is the [AssemblyScript](https://www.assemblyscript.org/) SDK for [Easegress](https://github.com/megaease/easegress), it can be used to extend the ability of Easegress.\n\n## Prerequisites\n\nThe following assumes that a recent version of [Git](https://git-scm.com/), [Node.js](https://nodejs.org/) and its package manager [npm](https://www.npmjs.com/) are installed. Basic knowledge about writing and working with TypeScript modules, which is very similar, is a plus.\n\n## Local Development\n\n1. Clone this repo to somewhere on disk.\n\n2. Switch to a new directory and initialize a new node module:\n\n```bash\nnpm init\n```\n\n3. Install the AssemblyScript compiler using npm, assume that the compiler is not required in production and make it a development dependency:\n\n```bash\nnpm install --save-dev assemblyscript\n```\n\n4. Once installed, the compiler provides a handy scaffolding utility to quickly set up a new AssemblyScript project, for example in the directory of the just initialized node module:\n\n```bash\nnpx asinit .\n```\n\n5. Add `--use abort=` to the end `asc assembly/index.ts ...` command in `package.json`, for example,\n\nBefore add `--use abort=`:\n```json\n...\n    \"scripts\": {\n        \"test\": \"node tests\",\n        \"asbuild:debug\": \"asc assembly/index.ts --target debug\",\n        \"asbuild:release\": \"asc assembly/index.ts --target release\",\n        \"asbuild\": \"npm run asbuild:debug \u0026\u0026 npm run asbuild:release\",\n        \"start\": \"npx serve .\"\n    },\n...\n```\nAfter add `--use abort=`:\n```json\n...\n    \"scripts\": {\n        \"test\": \"node tests\",\n        \"asbuild:debug\": \"asc assembly/index.ts --target debug --use abort=\",\n        \"asbuild:release\": \"asc assembly/index.ts --target release --use abort=\",\n        \"asbuild\": \"npm run asbuild:debug \u0026\u0026 npm run asbuild:release\",\n        \"start\": \"npx serve .\"\n    },\n...\n```\n\n6. Copy this into assembly/index.ts, note to replace `PATH_TO_SDK_REPO` with the path in the first step:\n\n```typescript\n// As required by Easegress, these functions must be exported\n// Use relative path here, like ../../easegress-assemblyscript-sdk/easegress/proxy\nexport * from 'PATH_TO_SDK_REPO/easegress/proxy'\n\n// Use relative path here, like ../../easegress-assemblyscript-sdk/easegress\nimport { Program, request, LogLevel, log, registerProgramFactory } from 'PATH_TO_SDK_REPO/easegress'\n\nclass AddHeaderAndSetBody extends Program {\n    constructor(params: Map\u003cstring, string\u003e) {\n        super(params)\n    }\n\n    run(): i32 {\n        super.run()\n        let v = request.getHeader( \"Foo\" )\n        if( v.length \u003e 10 ) {\n            log( LogLevel.Warning, \"The length of Foo is greater than 10\" )\n        }\n        if( v.length \u003e 0 ) {\n            request.addHeader( \"Wasm-Added\", v )\n        }\n        request.setBody( String.UTF8.encode(\"I have a new body now\") )\n        return 0\n    }\n}\n\nregisterProgramFactory((params: Map\u003cstring, string\u003e) =\u003e {\n    return new AddHeaderAndSetBody(params)\n}\n```\n\n7. Build with this command\n\n```bash\nnpm run asbuild\n```\n\nIf everything is right, `debug.wasm` (the debug version) and `release.wasm` (the release version) will be generated at the `build` folder.\n\n## Deploy and execute\n\nPlease refer [the documentation of `WasmHost`](https://github.com/megaease/easegress/blob/main/doc/reference/wasmhost.md) for deploying and executing the compiled Wasm code.\n\n\n## License\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Feasegress-io%2Feasegress-assemblyscript-sdk.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Feasegress-io%2Feasegress-assemblyscript-sdk?ref=badge_large)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasegress-io%2Feasegress-assemblyscript-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasegress-io%2Feasegress-assemblyscript-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasegress-io%2Feasegress-assemblyscript-sdk/lists"}