Enhances API infrastructure with Swagger, feature flags, and refactored middleware
Implements @elysiajs/swagger for automated API documentation and introduces a feature flag system to expose service capabilities based on environment variables. Refactors authentication guards into native Elysia scoped middleware for improved integration and type safety. Updates error handling to support custom status codes and adds instance-specific headers to responses for better observability. Includes an IP fallback mechanism for bug reports that utilizes internal system info when the direct submitter IP is unavailable.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Elysia, t } from "elysia";
|
||||
import { adminKeyGuard } from "../middleware/auth";
|
||||
import { adminKeyGuard2 } from "../middleware/auth";
|
||||
import {
|
||||
listBugReports,
|
||||
getBugReport,
|
||||
@@ -21,7 +21,7 @@ import { Log } from "../logger";
|
||||
import type { BugReportStatus, DbEnv } from "../types";
|
||||
|
||||
export const adminRoutes = new Elysia({ prefix: "/api/admin" })
|
||||
.onRequest(adminKeyGuard)
|
||||
.use(adminKeyGuard2)
|
||||
.get(
|
||||
"/bug-reports",
|
||||
async ({ query, headers }) => {
|
||||
@@ -37,7 +37,7 @@ export const adminRoutes = new Elysia({ prefix: "/api/admin" })
|
||||
"ADMIN",
|
||||
`List bug reports page=${page} pageSize=${pageSize} status=${status || "all"} search=${search || ""}`,
|
||||
);
|
||||
return await listBugReports(
|
||||
const res = await listBugReports(
|
||||
{
|
||||
page,
|
||||
pageSize,
|
||||
@@ -46,6 +46,7 @@ export const adminRoutes = new Elysia({ prefix: "/api/admin" })
|
||||
},
|
||||
useTestDb,
|
||||
);
|
||||
return res;
|
||||
},
|
||||
{
|
||||
query: t.Object({
|
||||
|
||||
Reference in New Issue
Block a user