Skip to content

Commit 0b0118c

Browse files
committed
[add] Lark Email API based on Node-Mailer 8
[optimize] update Upstream packages
1 parent fef93c5 commit 0b0118c

5 files changed

Lines changed: 555 additions & 482 deletions

File tree

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ NEXT_PUBLIC_PROJECT_TABLE_ID = tblGnY6Hm0nTSBR9
1212
NEXT_PUBLIC_AWARD_TABLE_ID = tblmYd5V5BMngAp2
1313

1414
NEXT_PUBLIC_STRAPI_API_HOST = https://china-ngo-db.onrender.com/api/
15+
16+
SMTP_HOST = smtp.feishu.cn
17+
SMTP_PORT = 465
18+
SMTP_USER = bot@fcc-cd.dev

models/configuration.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ export const Name = process.env.NEXT_PUBLIC_SITE_NAME,
66
Summary = process.env.NEXT_PUBLIC_SITE_SUMMARY,
77
DefaultImage = process.env.NEXT_PUBLIC_LOGO!;
88

9-
export const { VERCEL, VERCEL_URL, STRAPI_API_TOKEN } = process.env;
9+
export const {
10+
SMTP_HOST,
11+
SMTP_PORT = 465,
12+
SMTP_USER,
13+
SMTP_PASSWORD,
14+
VERCEL,
15+
VERCEL_URL,
16+
STRAPI_API_TOKEN,
17+
} = process.env;
1018

1119
export const API_Host = isServer()
1220
? VERCEL_URL

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
"koa-jwt": "^4.0.4",
2929
"koajax": "^3.1.2",
3030
"license-filter": "^0.2.5",
31-
"marked": "^17.0.2",
31+
"marked": "^17.0.3",
3232
"mime": "^4.1.0",
3333
"mobx": "^6.15.0",
3434
"mobx-github": "^0.6.2",
3535
"mobx-i18n": "^0.7.2",
36-
"mobx-lark": "^2.6.5",
36+
"mobx-lark": "^2.7.0",
3737
"mobx-react": "^9.2.1",
3838
"mobx-react-helper": "^0.5.1",
3939
"mobx-restful": "^2.1.4",
@@ -42,6 +42,7 @@
4242
"next": "^16.1.6",
4343
"next-pwa": "^5.6.0",
4444
"next-ssr-middleware": "^1.1.0",
45+
"nodemailer": "^8.0.1",
4546
"open-react-map": "^0.9.1",
4647
"react": "^19.2.4",
4748
"react-bootstrap": "^2.10.10",
@@ -56,20 +57,21 @@
5657
"@babel/plugin-proposal-decorators": "^7.29.0",
5758
"@babel/plugin-transform-typescript": "^7.28.6",
5859
"@babel/preset-react": "^7.28.5",
59-
"@cspell/eslint-plugin": "^9.6.4",
60+
"@cspell/eslint-plugin": "^9.7.0",
6061
"@eslint/js": "^10.0.1",
6162
"@next/eslint-plugin-next": "^16.1.6",
6263
"@open-source-bazaar/china-ngo-database": "^0.6.0",
6364
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
64-
"@stylistic/eslint-plugin": "^5.8.0",
65+
"@stylistic/eslint-plugin": "^5.9.0",
6566
"@types/eslint-config-prettier": "^6.11.3",
6667
"@types/jsonwebtoken": "^9.0.10",
6768
"@types/koa": "^3.0.1",
6869
"@types/next-pwa": "^5.6.9",
6970
"@types/node": "^24.10.13",
71+
"@types/nodemailer": "^7.0.11",
7072
"@types/react": "^19.2.14",
7173
"@types/react-dom": "^19.2.3",
72-
"eslint": "^10.0.0",
74+
"eslint": "^10.0.2",
7375
"eslint-config-next": "^16.1.6",
7476
"eslint-config-prettier": "^10.1.8",
7577
"eslint-plugin-react": "^7.37.5",
@@ -85,7 +87,7 @@
8587
"prettier-plugin-css-order": "^2.2.0",
8688
"sass": "^1.97.3",
8789
"typescript": "~5.9.3",
88-
"typescript-eslint": "^8.55.0"
90+
"typescript-eslint": "^8.56.1"
8991
},
9092
"resolutions": {
9193
"mobx-react-helper": "$mobx-react-helper",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware';
2+
import { createTransport } from 'nodemailer';
3+
import Mail from 'nodemailer/lib/mailer';
4+
5+
import {
6+
SMTP_HOST,
7+
SMTP_PASSWORD,
8+
SMTP_PORT,
9+
SMTP_USER,
10+
} from '../../../../../models/configuration';
11+
12+
export const config = { api: { bodyParser: false } };
13+
14+
const router = createKoaRouter(import.meta.url),
15+
transporter = createTransport({
16+
host: SMTP_HOST,
17+
port: +SMTP_PORT,
18+
secure: +SMTP_PORT === 465,
19+
auth: { user: SMTP_USER, pass: SMTP_PASSWORD },
20+
});
21+
22+
router.post('/bot/message', async context => {
23+
const input = Reflect.get(context.request, 'body') as Mail.Options;
24+
25+
context.body = await transporter.sendMail({ ...input, from: SMTP_USER });
26+
});
27+
28+
export default withKoaRouter(router);

0 commit comments

Comments
 (0)