refactor(admin): 重构评论管理界面样式和功能
feat(login): 添加API地址配置功能并支持本地存储 fix(api): 移除CWD_CONFIG_KV相关配置改用数据库存储 fix(cors): 修改跨域配置允许所有来源 perf(email): 添加邮件发送日志记录和调试信息 perf(comments): 优化评论提交和邮件通知逻辑 docs(backend): 更新后端配置文档移除CWD_CONFIG_KV相关说明 chore: 更新端口号和示例配置
This commit is contained in:
@@ -14,8 +14,24 @@ import { getAdminEmail } from './api/admin/getAdminEmail';
|
||||
import { setAdminEmail } from './api/admin/setAdminEmail';
|
||||
|
||||
const app = new Hono<{ Bindings: Bindings }>();
|
||||
const VERSION = 'v0.0.1';
|
||||
|
||||
app.use('*', async (c, next) => {
|
||||
console.log('Request:start', {
|
||||
method: c.req.method,
|
||||
path: c.req.path,
|
||||
url: c.req.url,
|
||||
hasDb: !!c.env.CWD_DB,
|
||||
hasAuthKv: !!c.env.CWD_AUTH_KV
|
||||
});
|
||||
const res = await next();
|
||||
console.log('Request:end', {
|
||||
method: c.req.method,
|
||||
path: c.req.path
|
||||
});
|
||||
return res;
|
||||
});
|
||||
|
||||
// 跨域
|
||||
app.use('/api/*', async (c, next) => {
|
||||
const corsMiddleware = customCors(c.env.ALLOW_ORIGIN);
|
||||
return corsMiddleware(c, next);
|
||||
@@ -25,7 +41,12 @@ app.use('/admin/*', async (c, next) => {
|
||||
return corsMiddleware(c, next);
|
||||
});
|
||||
|
||||
// API
|
||||
app.get('/', (c) => {
|
||||
return c.html(
|
||||
`CWD 评论部署成功,当前版本 ${VERSION},<a href="https://github.com/anghunk/cwd-comments" target="_blank" rel="noreferrer">查看文档</a>`
|
||||
);
|
||||
});
|
||||
|
||||
app.get('/api/comments', getComments);
|
||||
app.post('/api/comments', postComment);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user