kff 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
..
.vscode 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
assets 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
src 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
submodule 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
test 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
.dockerignore 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
.eslintrc.js 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
.gitignore 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
.prettierrc 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
Dockerfile 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
README.md 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
nest-cli.json 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
package-lock.json 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
package.json 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
tsconfig.build.json 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago
tsconfig.json 22214bd0c3 12-11初始化代码,截止双语版本 2 days ago

README.md

This is Email Factory

  1. There provide all about email service such as:
  • POST request to send email to target receivers
  • Receive argument of multiple target receivers
  • Select sender when request
  • Receive argument of contents
  • Select template when request
  • Template store as assets in ./assets/template/*

How to use

  1. Template:

    • Template save in ./assets/template/ and use ejs.
    • If you want to add template, please use the directory.
    • About argument:
      a. "locals" can include all argument , it is a json.

    b. When you use the template, you will call mailerService.sendMail(sendMailOptions),and in 'sendMailOptions' have a attribute "content", that is "locals":

          const sendMailOptions: ISendMailOptions = {
               to: data.receiver,
               subject: data.subject || '用户邮箱验证',
               template: 'test.ejs',
               context: {
                   date, //日期
                   text:data.text,
               }
    
           };
    

    c. This is use "locals" example:

     <p style="color: #dde2e2;padding-left: 14px;">
       <strong style="color: #3acbff;font-size: 24px;">
           <%= locals.text %>
       </strong>
       <span>(If the text same as your input, then i am health)</span>
     </p>
    

    Tips:   ❌ locals.context.text   ✅ locals.text More : https://ejs.bootcss.com/#docs

  2. Config

    • Sender account in ./assets/sender.ts
  3. API

    • Controller in /src/app.controller.ts, because this is a simple email service, so just three api to use. If the function to be more, may be will to rebuild file structure
    • Service in /src/app.service.ts, and just have one send email service.
    • The microsServer will not have anything about database.
    • Still don't have any api for microsServer use, because gateway still is a baby.I will create microsServer api after gateway done. > Tips: > > In ./src/email.module.ts you can open the preview email config, it really useful but
      > remember close it when you finish the email style adjust.Because it will prevent send email
      > active.

Todo

  • Transform be microservice
  • Turn the transport from http to tcp
  • Register in gateway

Current API

Tips: it no real use in project, just listing the service should to do.

Base URLs: https://localhost:12500

Email

POST /email/test

POST /email/test

Body 请求参数

{
  "content": "string",
  "subject": "string",
  "template": "string",
  "receiver": "string"
}

请求参数

名称 位置 类型 必选 说明
body body SingleEmailBody none

返回示例

201 Response

{}

返回结果

状态码 状态码含义 说明 数据模型
201 Created 成功 Inline

返回数据结构

POST /email/single

POST /email/single

Body 请求参数

{
  "content": "string",
  "subject": "string",
  "template": "string",
  "receiver": "string"
}

请求参数

名称 位置 类型 必选 说明
body body SingleEmailBody none

返回示例

201 Response

{}

返回结果

状态码 状态码含义 说明 数据模型
201 Created 成功 Inline

返回数据结构

POST /email/multiple

POST /email/multiple

Body 请求参数

{
  "content": "string",
  "subject": "string",
  "template": "string",
  "receiver": ["string"]
}

请求参数

名称 位置 类型 必选 说明
body body MultipleEmailBody none

返回示例

201 Response

{}

返回结果

状态码 状态码含义 说明 数据模型
201 Created 成功 Inline

返回数据结构

GET /email

GET /email

返回示例

200 Response

{}

返回结果

状态码 状态码含义 说明 数据模型
200 OK 成功 Inline

返回数据结构

GET /email/hi

GET /email/hi

返回示例

200 Response

{}

返回结果

状态码 状态码含义 说明 数据模型
200 OK 成功 Inline

返回数据结构

数据模型

MultipleEmailBody

{
  "content": "string",
  "subject": "string",
  "template": "string",
  "receiver": ["string"]
}

属性

名称 类型 必选 约束 中文名 说明
content string true none none
subject string true none none
template string true none none
receiver [string] true none none

SingleEmailBody

{
  "content": "string",
  "subject": "string",
  "template": "string",
  "receiver": "string"
}

属性

名称 类型 必选 约束 中文名 说明
content string true none none
subject string true none none
template string true none none
receiver string true none none