mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-05 23:47:50 +08:00
feat: |worker| health_check add JWT_SECRET and DOMAINS (#573)
This commit is contained in:
+15
-8
@@ -12,7 +12,7 @@ import { api as telegramApi } from './telegram_api'
|
|||||||
|
|
||||||
import { email } from './email';
|
import { email } from './email';
|
||||||
import { scheduled } from './scheduled';
|
import { scheduled } from './scheduled';
|
||||||
import { getAdminPasswords, getPasswords, getBooleanValue } from './utils';
|
import { getAdminPasswords, getPasswords, getBooleanValue, getStringArray } from './utils';
|
||||||
import { HonoCustomType, UserPayload } from './types';
|
import { HonoCustomType, UserPayload } from './types';
|
||||||
|
|
||||||
const app = new Hono<HonoCustomType>()
|
const app = new Hono<HonoCustomType>()
|
||||||
@@ -210,14 +210,21 @@ app.route('/', adminApi)
|
|||||||
app.route('/', apiSendMail)
|
app.route('/', apiSendMail)
|
||||||
app.route('/', telegramApi)
|
app.route('/', telegramApi)
|
||||||
|
|
||||||
app.get('/', async c => {
|
const health_check = async (c: Context<HonoCustomType>) => {
|
||||||
if (!c.env.DB) { return c.text("DB is not available", 400); }
|
if (!c.env.DB) {
|
||||||
|
return c.text("DB is not available", 400);
|
||||||
|
}
|
||||||
|
if (!c.env.JWT_SECRET) {
|
||||||
|
return c.text("JWT_SECRET is not set", 400);
|
||||||
|
}
|
||||||
|
if (getStringArray(c.env.DOMAINS).length === 0) {
|
||||||
|
return c.text("DOMAINS is not set", 400);
|
||||||
|
}
|
||||||
return c.text("OK");
|
return c.text("OK");
|
||||||
})
|
}
|
||||||
app.get('/health_check', async c => {
|
|
||||||
if (!c.env.DB) { return c.text("DB is not available", 400); }
|
app.get('/', health_check)
|
||||||
return c.text("OK");
|
app.get('/health_check', health_check)
|
||||||
})
|
|
||||||
app.all('/*', async c => c.text("Not Found", 404))
|
app.all('/*', async c => c.text("Not Found", 404))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user