Cloudflare
Environment
Access Cloudflare Worker environment bindings directly.
The @Env() parameter decorator gives you direct access to the Worker environment bindings (c.env) inside any controller method.
Full Environment Object
Omit the argument to receive the entire c.env object:
import { Controller, Get } from '@velajs/vela';
import { Env } from '@velajs/cloudflare';
@Controller('config')
class ConfigController {
@Get()
handler(@Env() env: Record<string, unknown>) {
return { keys: Object.keys(env) };
}
}Specific Binding
Pass a binding name to retrieve a single value:
import { Controller, Get } from '@velajs/vela';
import { Env } from '@velajs/cloudflare';
@Controller('secret')
class SecretController {
@Get()
handler(@Env('MY_SECRET') secret: string) {
return { secret };
}
}@Env() can be used in any controller method alongside other parameter decorators like @Body(), @Param(), and @Query().
Overview
First-class Cloudflare Workers integration for Vela applications.
KV
Use Cloudflare KV namespaces in your Vela application.
Edit on GitHub
Last updated on