refactor(db): rename redirect_path→redirect, add uid/addLog helpers, simplify Caddy CRUD
- Rename caddy.redirect_path to caddy.redirect across schema, server, frontend and docs - Remove obsolete ALTER TABLE migration (fresh-install model has no migrations) - Move uid() from server.ts to server-db.ts for shared use - Add addLog() general helper (prepared statement, shared timestamp support) and replace ~24 inline INSERT INTO logs calls throughout server.ts - Caddy CRUD now takes CaddyRouteInput object instead of positional arguments; add/update reuse getCaddyRouteById() to avoid duplicate SELECT
This commit is contained in:
@ -35,7 +35,7 @@ interface CaddyRoute {
|
||||
upstream: string;
|
||||
tls: number;
|
||||
compress: number;
|
||||
redirect_path: string;
|
||||
redirect: string;
|
||||
}
|
||||
|
||||
interface DbInfo {
|
||||
@ -384,7 +384,7 @@ export default function Settings({ currentUser: _currentUser }: SettingsProps) {
|
||||
try {
|
||||
const res = await authFetch('/api/caddy/routes', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ hostname: newHostname.trim(), upstream: newUpstream.trim(), tls: newTls, compress: newCompress, redirectPath: newRedirect.trim() }),
|
||||
body: JSON.stringify({ hostname: newHostname.trim(), upstream: newUpstream.trim(), tls: newTls, compress: newCompress, redirect: newRedirect.trim() }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const d = await res.json();
|
||||
@ -424,7 +424,7 @@ export default function Settings({ currentUser: _currentUser }: SettingsProps) {
|
||||
setEditUpstream(r.upstream);
|
||||
setEditTls(r.tls === 1);
|
||||
setEditCompress(r.compress === 1);
|
||||
setEditRedirect(r.redirect_path || '');
|
||||
setEditRedirect(r.redirect || '');
|
||||
}
|
||||
|
||||
function handleEditCancel() {
|
||||
@ -437,7 +437,7 @@ export default function Settings({ currentUser: _currentUser }: SettingsProps) {
|
||||
try {
|
||||
const res = await authFetch(`/api/caddy/routes/${id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ hostname: editHostname.trim(), upstream: editUpstream.trim(), tls: editTls, compress: editCompress, redirectPath: editRedirect.trim() }),
|
||||
body: JSON.stringify({ hostname: editHostname.trim(), upstream: editUpstream.trim(), tls: editTls, compress: editCompress, redirect: editRedirect.trim() }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const d = await res.json();
|
||||
@ -1013,7 +1013,7 @@ export default function Settings({ currentUser: _currentUser }: SettingsProps) {
|
||||
<span className="text-[11px] font-mono text-slate-400 truncate">{r.upstream}</span>
|
||||
{r.tls ? <span className="text-[9px] font-semibold text-sky-500 font-mono">TLS</span> : null}
|
||||
{r.compress ? <span className="text-[9px] font-semibold text-slate-500 font-mono">GZ</span> : null}
|
||||
{r.redirect_path ? <span className="text-[9px] font-mono text-slate-500 truncate">↳ {r.redirect_path}</span> : null}
|
||||
{r.redirect ? <span className="text-[9px] font-mono text-slate-500 truncate">↳ {r.redirect}</span> : null}
|
||||
</div>
|
||||
<div className="flex items-center gap-1 ml-3 shrink-0">
|
||||
<button type="button" onClick={() => handleEditStart(r)}
|
||||
|
||||
Reference in New Issue
Block a user