fix: restore dark post view and API revalidation
This commit is contained in:
1 parent
5c554f27ea
commit
0933220c70
12 files changed
+100
-31
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// GET /api/posts/[id]/replies, POST /api/posts/[id]/replies
|
||||
import pool from '@/lib/db';
|
||||
import { getUser } from '@/lib/auth';
|
||||
import { jsonWithEtag } from '@/lib/http-cache';
|
||||
|
||||
export async function GET(req, { params }) {
|
||||
try {
|
||||
@@ -12,7 +13,7 @@ export async function GET(req, { params }) {
|
||||
ORDER BY r.created_at ASC`,
|
||||
[(await params).id]
|
||||
);
|
||||
return Response.json(r.rows);
|
||||
return jsonWithEtag(req, r.rows);
|
||||
} catch {
|
||||
return Response.json({ error: '服务器错误' }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// GET /api/posts/[id], DELETE /api/posts/[id]
|
||||
import pool from '@/lib/db';
|
||||
import { getUser } from '@/lib/auth';
|
||||
import { jsonWithEtag } from '@/lib/http-cache';
|
||||
|
||||
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
@@ -21,7 +22,7 @@ export async function GET(req, { params }) {
|
||||
if (r.rows.length === 0) {
|
||||
return invalidId();
|
||||
}
|
||||
return Response.json(r.rows[0]);
|
||||
return jsonWithEtag(req, r.rows[0]);
|
||||
} catch {
|
||||
return Response.json({ error: '服务器错误' }, { status: 500 });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user