You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何编写含Dart运行时、执行权限及环境变量的appwrite.json?

带Dart运行时、执行权限与环境变量的appwrite.json示例

完整appwrite.json示例

{
  "projectId": "your-project-id",
  "projectName": "your-project-name",
  "functions": [
    {
      "$id": "dart-example-function",
      "name": "Dart Example Function",
      "runtime": "dart-3.0",
      "execute": ["users"],
      "events": [],
      "schedule": "",
      "timeout": 15,
      "entrypoint": "bin/main.dart",
      "commands": "dart pub get",
      "env": [
        {
          "key": "API_KEY",
          "value": "your-secret-api-key",
          "type": "secret"
        },
        {
          "key": "APP_ENV",
          "value": "production",
          "type": "plain"
        }
      ],
      "enabled": true,
      "logging": true
    }
  ]
}

关键配置说明

  • runtime: 指定为dart-3.0(可根据实际使用的Dart版本调整,比如dart-2.19)
  • execute: 数组内设置允许触发函数的角色,["users"]表示普通用户可执行,也可设为["*"]允许所有角色,或特定团队/用户ID
  • env: 数组包含环境变量,type可选secret(加密存储,控制台不显示明文)或plain(明文显示)

关于CLI创建环境变量未显示在appwrite.json的问题

用Appwrite CLI创建的环境变量属于远程服务器端配置,不会自动同步到本地appwrite.json。若要在本地文件中包含这些变量,可通过两种方式处理:

  1. 手动将环境变量添加到上述示例的env数组对应位置
  2. 使用CLI导出项目配置覆盖本地文件:
    appwrite projects get --json > appwrite.json
    
    注意:该命令会覆盖现有本地appwrite.json,执行前建议备份。另外导出的配置中,secret类型变量的值会被掩码替换(显示为***),需手动补全真实值。

内容的提问来源于stack exchange,提问作者Rafsan Uddin Beg Rizan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 15:45:31