mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
feat: add DOMAIN_LABELS for chinese domain label (#322)
This commit is contained in:
+8
-8
@@ -11,20 +11,20 @@
|
||||
"build": "wrangler deploy --dry-run --outdir dist --minify"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20240605.0",
|
||||
"@cloudflare/workers-types": "^4.20240620.0",
|
||||
"@eslint/js": "8.56.0",
|
||||
"eslint": "8.56.0",
|
||||
"globals": "^15.4.0",
|
||||
"typescript-eslint": "^7.13.0",
|
||||
"wrangler": "^3.60.2"
|
||||
"globals": "^15.6.0",
|
||||
"typescript-eslint": "^7.14.1",
|
||||
"wrangler": "^3.62.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.592.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.592.0",
|
||||
"hono": "^4.4.5",
|
||||
"@aws-sdk/client-s3": "^3.600.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.600.0",
|
||||
"hono": "^4.4.9",
|
||||
"mimetext": "^3.0.24",
|
||||
"postal-mime": "^2.2.5",
|
||||
"resend": "^3.3.0",
|
||||
"resend": "^3.4.0",
|
||||
"telegraf": "4.16.3"
|
||||
},
|
||||
"pnpm": {
|
||||
|
||||
Generated
+846
-824
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
import { Hono } from 'hono'
|
||||
|
||||
import { getDomains, getPasswords, getBooleanValue, getIntValue } from './utils';
|
||||
import { getDomains, getPasswords, getBooleanValue, getIntValue, getStringArray } from './utils';
|
||||
import { CONSTANTS } from './constants';
|
||||
import { HonoCustomType } from './types';
|
||||
import { isS3Enabled } from './mails_api/s3_attachment';
|
||||
@@ -21,6 +21,7 @@ api.get('/open_api/settings', async (c) => {
|
||||
"minAddressLen": getIntValue(c.env.MIN_ADDRESS_LEN, 1),
|
||||
"maxAddressLen": getIntValue(c.env.MAX_ADDRESS_LEN, 30),
|
||||
"domains": getDomains(c),
|
||||
"domainLabels": getStringArray(c.env.DOMAIN_LABELS),
|
||||
"needAuth": needAuth,
|
||||
"adminContact": c.env.ADMIN_CONTACT,
|
||||
"enableUserCreateEmail": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const CONSTANTS = {
|
||||
VERSION: 'v0.5.2',
|
||||
VERSION: 'v0.5.3',
|
||||
|
||||
// DB settings
|
||||
ADDRESS_BLOCK_LIST_KEY: 'address_block_list',
|
||||
|
||||
Vendored
+1
@@ -11,6 +11,7 @@ export type Bindings = {
|
||||
MIN_ADDRESS_LEN: string | number | undefined
|
||||
MAX_ADDRESS_LEN: string | number | undefined
|
||||
DOMAINS: string | string[] | undefined
|
||||
DOMAIN_LABELS: string | string[] | undefined
|
||||
PASSWORDS: string | string[] | undefined
|
||||
ADMIN_PASSWORDS: string | string[] | undefined
|
||||
JWT_SECRET: string
|
||||
|
||||
@@ -79,6 +79,24 @@ export const getIntValue = (
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
export const getStringArray = (
|
||||
value: string | string[] | undefined | null
|
||||
): string[] => {
|
||||
if (!value) {
|
||||
return [];
|
||||
}
|
||||
// check if value is an array, if not use json.parse
|
||||
if (!Array.isArray(value)) {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse value", e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export const getDomains = (c: Context<HonoCustomType>): string[] => {
|
||||
if (!c.env.DOMAINS) {
|
||||
return [];
|
||||
|
||||
@@ -28,6 +28,8 @@ PREFIX = "tmp"
|
||||
# ADMIN CONTACT, CAN BE ANY STRING
|
||||
# ADMIN_CONTACT = "xx@xx.xxx"
|
||||
DOMAINS = ["xxx.xxx1" , "xxx.xxx2"]
|
||||
# For chinese domain name, you can use DOMAIN_LABELS to show chinese domain name
|
||||
# DOMAIN_LABELS = ["中文.xxx", "xxx.xxx2"]
|
||||
JWT_SECRET = "xxx"
|
||||
BLACK_LIST = ""
|
||||
# Allow users to create email addresses
|
||||
|
||||
Reference in New Issue
Block a user