TypeScript Plugins - WunderGraph

TypeScript (with Bun) Support for Router Plugins

TypeScript (with Bun) is one of the languages supported out of the box for developing router plugins. However, unlike Golang router plugins, it does not come with its own library. This means there is no automated tracing or out-of-the-box HTTP client at the moment.

TypeScript (with Bun) support is available in wgc@0.96.0 and above.

Generated TypeScript Plugin Folder Structure

The generated TypeScript plugin folder structure includes the following:

plugin
├── bin
│   └── grpc-health-check/proto/health/v1
│       └── health.proto
└── src
    └── plugin-server.ts

plugin-server.ts Functionality

plugin-server.ts provides similar minimal functionality to the router-plugin package for Go, which internally uses the official HashiCorp go-plugin plugin server helper functions. This provides the following out of the box:

Building a Plugin

When you build a plugin using wgc router plugin build <pluginName>, the binary is placed in the bin folder. In addition, the health.proto definition is copied into the correct directory structure under grpc-health-check. Ensure that both the binary and the grpc-health-check folder are copied over when deploying or running the plugin.