@haftahave/serverless-ses-template

中文文档
6.2.0发布于 2025/04/30MITTypeScriptES Module近 30 天下载 1.1万

Amazon 简单电子邮件服务的无服务器模板同步插件

中文使用文档
文档目录9 节
  1. 模板配置文件
  2. 插件按以下顺序解决区域 :
  3. 插件按以下顺序解决模板配置文件路径 :
  4. 使用和命令行选项
  5. 部署
  6. 列表模板
  7. 删除模板
  8. 链接
  9. 许可证

NPM npm Build Status slack Made in Ukraine

Stand With Ukraine

亚马逊简易电子邮件服务模板同步插件

允许自动创建、更新和删除的无服务器插件 AWS SES 模板使用配置文件并保存您的 AWS SES 模板 与您的配置文件同步 .

需求 节点20+


: zap: 特性

  • 允许宣布在部署前阶段同步的电子邮件模板
  • 允许您在同步时在模板名称中选择添加舞台
  • 允许您按指定名称列出和删除 SES 模板

实例


🚨 重要通知数字 :

从 6.x (单位:千美元) 版本,插件已切换到 纯无害环境管理 并需要无服务器 页:1 或更新.

如果你需要的话 CJS 软件包 使用情况 5.x 电话 插件序列

如果您需要兼容性 serverless<3.0.0标记 页:1。 。 。 .


安装

npm install @haftahave/serverless-ses-template

配置

  • 全体 @haftahave/ serverless-ses-template (英语) 配置参数为可选
# add to your serverless.yml

plugins:
  - '@haftahave/serverless-ses-template'

custom:
  sesTemplates:
    addStage: true                             # Specifies whether to add stage to template name (default false)
    configFile: './custom-config-file/path.js' # Config file path (default './ses-email-templates/index.js')
    deployHook: 'after:deploy:deploy'          # Specifies serverless lifecycle event plugin use to deploy templates (default 'before:deploy:deploy')
    disableAutoDeploy: true                    # Specifies whether to sync templates while sls deploy and remove (default false)
    region: 'us-west-2'                        # Specifies AWS region for SES templates (not required)
    removeMissed: false                        # Set this flag in order to remove templates those are not present in your configuration file. (not required, default false)

模板配置文件

模板配置文件应该是返回对象数组(需要所有密钥)的async函数:

/**
 * @param {Object} serverless - Serverless instance
 * @param {Object} options - runtime options
 * @returns {Promise<{name: string, subject: string, html: string, text: string}[]>}
 */
const templateConfiguration = async (serverless, options) => [{
    name: 'example_name',
    subject: 'Your subject',
    html: '<h1>Hello world!</h1>',
    text: 'Hello world!',
}];

export default templateConfiguration

真实世界的例子 这里。 。 。 .

插件按以下顺序解决区域 :

  • 名为 CLI 的参数 sesTemplatesRegion - 最高优先级
  • serverless.yml 已命名的插件配置参数 region
  • 名为 CLI 的参数 region
  • 回落到默认区域解析( 在无服务器. yml 中定义的第一阶段的第一个区域)

插件按以下顺序解决模板配置文件路径 :

  • 名为 CLI 的参数 sesTemplateConfig - 最高优先级
  • serverless.yml 已命名的插件配置参数 configFile
  • 倒向默认 ./ses-email-templates/index.js

使用和命令行选项

部署

运行 sls ses-template deploy 以同步您的电子邮件模板.

可选 CLI 选项 :

--sesTemplatesRegion The region used to populate your templates. Default: see "Region fallback sequence" in readme.md. [OPTIONAL]
--sesTemplateConfig  Template configuration file path. Default: see "Template configuration file sequence" in readme.md. [OPTIONAL]
--stage        The stage used to populate your templates. Default: the first stage found in your project. [OPTIONAL]
--removeMissed Set this flag in order to remove templates those are not present in your configuration file. [OPTIONAL]

列表模板

运行 sls ses-template list 以列出您的电子邮件模板.

CLI 选项 :

--sesTemplatesRegion The region used to list your templates. Default: see "Region fallback sequence" in readme.md. [OPTIONAL]
--filter <string>    Display templates that contain <string>. [OPTIONAL]

删除模板

运行 sls ses-template delete --template template_name_goes_here 删除您的电子邮件模板.

CLI 选项 :

--template    The template name you are going to delete [REQUIRED]
--sesTemplatesRegion The region used to populate your templates. Default: see "Region fallback sequence" in readme.md. [OPTIONAL]
--stage       The stage used to populate your templates. Default: the first stage found in your project. [OPTIONAL]

许可证

麻省理工学院

版本与发布记录

@haftahave/serverless-ses-template 共发布 40 个版本,首次发布于 2018/09/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
6.2.0latest2025/04/301.5 年前
6.1.02024/01/112 年前
5.1.02024/01/112 年前
6.0.02023/09/263 年前
5.0.22023/09/263 年前
5.0.12023/09/263 年前

关于 @haftahave/serverless-ses-template 的常见问题

@haftahave/serverless-ses-template 是什么?

Amazon 简单电子邮件服务的无服务器模板同步插件

如何安装 @haftahave/serverless-ses-template?

在项目目录运行 npm install @haftahave/serverless-ses-template,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:serverless(>=3.2.0 || >=4.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@haftahave/serverless-ses-template 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@haftahave/serverless-ses-template 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@haftahave/serverless-ses-template 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.18.1。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@haftahave/serverless-ses-template 可以商用吗?

@haftahave/serverless-ses-template 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@haftahave/serverless-ses-template 的下载量有多少?

根据 npm 官方下载统计,@haftahave/serverless-ses-template 在 2026/10/17 – 2026/11/15 这 30 天内被下载 10,742 次,日均约 358 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@haftahave/serverless-ses-template 还在维护吗?

最新版本 6.2.0 发布于 2025/04/30(1.5 年前);至今共发布 40 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/09/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。