Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ NEXT_PUBLIC_PROJECT_TABLE_ID = tblGnY6Hm0nTSBR9
NEXT_PUBLIC_AWARD_TABLE_ID = tblmYd5V5BMngAp2

NEXT_PUBLIC_STRAPI_API_HOST = https://china-ngo-db.onrender.com/api/

SMTP_HOST = smtp.feishu.cn
SMTP_PORT = 465
SMTP_USER = bot@fcc-cd.dev
10 changes: 9 additions & 1 deletion models/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ export const Name = process.env.NEXT_PUBLIC_SITE_NAME,
Summary = process.env.NEXT_PUBLIC_SITE_SUMMARY,
DefaultImage = process.env.NEXT_PUBLIC_LOGO!;

export const { VERCEL, VERCEL_URL, STRAPI_API_TOKEN } = process.env;
export const {
SMTP_HOST,
SMTP_PORT = 465,
SMTP_USER,
SMTP_PASSWORD,
VERCEL,
VERCEL_URL,
STRAPI_API_TOKEN,
} = process.env;

export const API_Host = isServer()
? VERCEL_URL
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"koa-jwt": "^4.0.4",
"koajax": "^3.1.2",
"license-filter": "^0.2.5",
"marked": "^17.0.2",
"marked": "^17.0.3",
"mime": "^4.1.0",
"mobx": "^6.15.0",
"mobx-github": "^0.6.2",
"mobx-i18n": "^0.7.2",
"mobx-lark": "^2.6.5",
"mobx-lark": "^2.7.0",
"mobx-react": "^9.2.1",
"mobx-react-helper": "^0.5.1",
"mobx-restful": "^2.1.4",
Expand All @@ -42,6 +42,7 @@
"next": "^16.1.6",
"next-pwa": "^5.6.0",
"next-ssr-middleware": "^1.1.0",
"nodemailer": "^8.0.1",
"open-react-map": "^0.9.1",
"react": "^19.2.4",
"react-bootstrap": "^2.10.10",
Expand All @@ -56,20 +57,21 @@
"@babel/plugin-proposal-decorators": "^7.29.0",
"@babel/plugin-transform-typescript": "^7.28.6",
"@babel/preset-react": "^7.28.5",
"@cspell/eslint-plugin": "^9.6.4",
"@cspell/eslint-plugin": "^9.7.0",
"@eslint/js": "^10.0.1",
"@next/eslint-plugin-next": "^16.1.6",
"@open-source-bazaar/china-ngo-database": "^0.6.0",
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
"@stylistic/eslint-plugin": "^5.8.0",
"@stylistic/eslint-plugin": "^5.9.0",
"@types/eslint-config-prettier": "^6.11.3",
"@types/jsonwebtoken": "^9.0.10",
"@types/koa": "^3.0.1",
"@types/next-pwa": "^5.6.9",
"@types/node": "^24.10.13",
"@types/nodemailer": "^7.0.11",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"eslint": "^10.0.0",
"eslint": "^10.0.2",
"eslint-config-next": "^16.1.6",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-react": "^7.37.5",
Expand All @@ -85,7 +87,7 @@
"prettier-plugin-css-order": "^2.2.0",
"sass": "^1.97.3",
"typescript": "~5.9.3",
"typescript-eslint": "^8.55.0"
"typescript-eslint": "^8.56.1"
},
"resolutions": {
"mobx-react-helper": "$mobx-react-helper",
Expand Down
28 changes: 28 additions & 0 deletions pages/api/Lark/mail/[address]/message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware';
import { createTransport } from 'nodemailer';
import Mail from 'nodemailer/lib/mailer';

import {
SMTP_HOST,
SMTP_PASSWORD,
SMTP_PORT,
SMTP_USER,
} from '../../../../../models/configuration';

export const config = { api: { bodyParser: false } };

const router = createKoaRouter(import.meta.url),
transporter = createTransport({
host: SMTP_HOST,
port: +SMTP_PORT,
secure: +SMTP_PORT === 465,
auth: { user: SMTP_USER, pass: SMTP_PASSWORD },
});

router.post('/bot/message', async context => {
const input = Reflect.get(context.request, 'body') as Mail.Options;

context.body = await transporter.sendMail({ ...input, from: SMTP_USER });
Comment thread
TechQuery marked this conversation as resolved.
});
Comment thread
TechQuery marked this conversation as resolved.
Outdated

export default withKoaRouter(router);
Loading
Loading