Skip to content

Commit f90df5d

Browse files
committed
Added Next.js BE & FE
1 parent 4cf8c45 commit f90df5d

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

src/app/api-docs/page.tsx

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"use client";
2+
3+
import React, { useState, useEffect } from "react";
4+
import dynamic from "next/dynamic";
5+
import CircularProgress from "@mui/material/CircularProgress";
6+
import "swagger-ui-react/swagger-ui.css";
7+
8+
const SwaggerUI = dynamic(() => import("swagger-ui-react"), { ssr: false });
9+
10+
type SwaggerSpec = typeof import("../api/swagger").default;
11+
12+
export default function SwaggerPage() {
13+
const [swaggerSpec, setSwaggerSpec] = useState<SwaggerSpec | null>(null);
14+
15+
useEffect(() => {
16+
import("../api/swagger").then((module) => {
17+
setSwaggerSpec(module.default);
18+
});
19+
}, []);
20+
21+
if (!swaggerSpec) {
22+
return (
23+
<div
24+
style={{
25+
display: "flex",
26+
justifyContent: "center",
27+
alignItems: "center",
28+
height: "100vh",
29+
backgroundColor: "#ffffff",
30+
}}
31+
>
32+
<CircularProgress />
33+
</div>
34+
);
35+
}
36+
37+
return (
38+
<div
39+
style={{
40+
height: "100vh",
41+
backgroundColor: "#ffffff",
42+
padding: "20px",
43+
}}
44+
>
45+
<style>
46+
{`
47+
/* Set all Swagger UI backgrounds to white */
48+
.swagger-ui,
49+
.swagger-ui .topbar,
50+
.swagger-ui .opblock-section-header,
51+
.swagger-ui .model-box,
52+
.swagger-ui .model {
53+
background-color: #ffffff !important;
54+
}
55+
56+
/* Remove border shadows for cleaner design */
57+
.swagger-ui .opblock {
58+
box-shadow: none !important;
59+
}
60+
61+
/* Ensure text colors remain visible */
62+
.swagger-ui .opblock-summary {
63+
color: #fff !important;
64+
}
65+
`}
66+
</style>
67+
<SwaggerUI spec={swaggerSpec} />
68+
</div>
69+
);
70+
}

src/app/api/todo/route.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/app/api/todos/route.ts
21
import { NextResponse } from "next/server";
32

43
interface Todo {

0 commit comments

Comments
 (0)