mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-15 00:15:04 +02:00
migrate to next 15 and react 19
This commit is contained in:
parent
2322640dc0
commit
ce19cc4ba4
20 changed files with 196 additions and 187 deletions
|
@ -22,7 +22,7 @@ RUN npm install --omit=dev
|
|||
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY ./config/config.example.yml /app/dist/
|
||||
COPY ./config/config.example.yml ./
|
||||
COPY server/db/names.json /app/dist/names.json
|
||||
|
||||
CMD ["npm", "start"]
|
||||
|
|
16
package.json
16
package.json
|
@ -54,13 +54,13 @@
|
|||
"js-yaml": "4.1.0",
|
||||
"lucide-react": "0.447.0",
|
||||
"moment": "2.30.1",
|
||||
"next": "14.2.13",
|
||||
"next": "15.0.1",
|
||||
"next-themes": "0.3.0",
|
||||
"node-fetch": "3.3.2",
|
||||
"nodemailer": "6.9.15",
|
||||
"oslo": "1.2.1",
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
"react": "19.0.0-rc-69d4b800-20241021",
|
||||
"react-dom": "19.0.0-rc-69d4b800-20241021",
|
||||
"react-hook-form": "7.53.0",
|
||||
"rebuild": "0.1.2",
|
||||
"tailwind-merge": "2.5.3",
|
||||
|
@ -80,17 +80,21 @@
|
|||
"@types/js-yaml": "4.0.9",
|
||||
"@types/node": "^20",
|
||||
"@types/nodemailer": "6.4.16",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"@types/react": "npm:types-react@19.0.0-rc.1",
|
||||
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
||||
"@types/yargs": "17.0.33",
|
||||
"drizzle-kit": "0.24.2",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.2.13",
|
||||
"eslint-config-next": "15.0.1",
|
||||
"postcss": "^8",
|
||||
"react-email": "3.0.1",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"tsc-alias": "1.8.10",
|
||||
"tsx": "4.19.1",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"overrides": {
|
||||
"@types/react": "npm:types-react@19.0.0-rc.1",
|
||||
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ const environmentSchema = z.object({
|
|||
email: z
|
||||
.object({
|
||||
smtp_host: z.string().optional(),
|
||||
smtp_port: z.number().optional(),
|
||||
smtp_port: z.number().positive().gt(0).lte(65535).optional(),
|
||||
smtp_user: z.string().optional(),
|
||||
smtp_pass: z.string().optional(),
|
||||
no_reply: z.string().email().optional(),
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { cookies } from "next/headers";
|
||||
|
||||
export function authCookieHeader() {
|
||||
const sessionId = cookies().get("session")?.value ?? null;
|
||||
export async function authCookieHeader() {
|
||||
const allCookies = await cookies();
|
||||
const sessionId = allCookies.get("session")?.value ?? null;
|
||||
return {
|
||||
headers: {
|
||||
Cookie: `session=${sessionId}`
|
||||
|
|
|
@ -40,23 +40,28 @@ const topNavItems = [
|
|||
|
||||
interface ConfigurationLaytoutProps {
|
||||
children: React.ReactNode;
|
||||
params: { orgId: string };
|
||||
params: Promise<{ orgId: string }>;
|
||||
}
|
||||
|
||||
export default async function ConfigurationLaytout({
|
||||
children,
|
||||
params,
|
||||
}: ConfigurationLaytoutProps) {
|
||||
export default async function ConfigurationLaytout(
|
||||
props: ConfigurationLaytoutProps
|
||||
) {
|
||||
const params = await props.params;
|
||||
|
||||
const { children } = props;
|
||||
|
||||
const user = await verifySession();
|
||||
|
||||
if (!user) {
|
||||
redirect("/auth/login");
|
||||
}
|
||||
|
||||
const cookie = await authCookieHeader();
|
||||
|
||||
try {
|
||||
await internal.get<AxiosResponse<GetOrgResponse>>(
|
||||
`/org/${params.orgId}`,
|
||||
authCookieHeader(),
|
||||
cookie
|
||||
);
|
||||
} catch {
|
||||
redirect(`/`);
|
||||
|
@ -66,7 +71,7 @@ export default async function ConfigurationLaytout({
|
|||
try {
|
||||
const res = await internal.get<AxiosResponse<ListOrgsResponse>>(
|
||||
`/orgs`,
|
||||
authCookieHeader(),
|
||||
cookie
|
||||
);
|
||||
if (res && res.data.data.orgs) {
|
||||
orgs = res.data.data.orgs;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { redirect } from "next/navigation";
|
||||
|
||||
type OrgPageProps = {
|
||||
params: { orgId: string };
|
||||
params: Promise<{ orgId: string }>;
|
||||
};
|
||||
|
||||
export default async function Page({ params }: OrgPageProps) {
|
||||
export default async function Page(props: OrgPageProps) {
|
||||
const params = await props.params;
|
||||
redirect(`/${params.orgId}/sites`);
|
||||
|
||||
return <></>;
|
||||
|
|
|
@ -22,20 +22,23 @@ export const metadata: Metadata = {
|
|||
|
||||
interface SettingsLayoutProps {
|
||||
children: React.ReactNode;
|
||||
params: { resourceId: string; orgId: string };
|
||||
params: Promise<{ resourceId: string; orgId: string }>;
|
||||
}
|
||||
|
||||
export default async function SettingsLayout({
|
||||
children,
|
||||
params,
|
||||
}: SettingsLayoutProps) {
|
||||
export default async function SettingsLayout(props: SettingsLayoutProps) {
|
||||
const params = await props.params;
|
||||
|
||||
const {
|
||||
children
|
||||
} = props;
|
||||
|
||||
let resource = null;
|
||||
|
||||
if (params.resourceId !== "create") {
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetResourceResponse>>(
|
||||
`/resource/${params.resourceId}`,
|
||||
authCookieHeader(),
|
||||
await authCookieHeader(),
|
||||
);
|
||||
resource = res.data.data;
|
||||
} catch {
|
||||
|
|
|
@ -3,11 +3,12 @@ import { Separator } from "@/components/ui/separator";
|
|||
import { CreateResourceForm } from "./components/CreateResource";
|
||||
import { GeneralForm } from "./components/GeneralForm";
|
||||
|
||||
export default function SettingsPage({
|
||||
params,
|
||||
}: {
|
||||
params: { resourceId: string };
|
||||
}) {
|
||||
export default async function SettingsPage(
|
||||
props: {
|
||||
params: Promise<{ resourceId: string }>;
|
||||
}
|
||||
) {
|
||||
const params = await props.params;
|
||||
const isCreate = params.resourceId === "create";
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useState, use } from "react";
|
||||
import { PlusCircle, Trash2, Server, Globe, Cpu } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
@ -25,11 +25,12 @@ const isValidIPAddress = (ip: string) => {
|
|||
return ipv4Regex.test(ip);
|
||||
};
|
||||
|
||||
export default function ReverseProxyTargets({
|
||||
params,
|
||||
}: {
|
||||
params: { resourceId: string };
|
||||
}) {
|
||||
export default function ReverseProxyTargets(
|
||||
props: {
|
||||
params: Promise<{ resourceId: string }>;
|
||||
}
|
||||
) {
|
||||
const params = use(props.params);
|
||||
const [targets, setTargets] = useState<ListTargetsResponse["targets"]>([]);
|
||||
const [nextId, setNextId] = useState(1);
|
||||
const [ipError, setIpError] = useState("");
|
||||
|
|
|
@ -5,15 +5,16 @@ import { AxiosResponse } from "axios";
|
|||
import { ListResourcesResponse } from "@server/routers/resource";
|
||||
|
||||
type ResourcesPageProps = {
|
||||
params: { orgId: string };
|
||||
params: Promise<{ orgId: string }>;
|
||||
};
|
||||
|
||||
export default async function Page({ params }: ResourcesPageProps) {
|
||||
export default async function Page(props: ResourcesPageProps) {
|
||||
const params = await props.params;
|
||||
let resources: ListResourcesResponse["resources"] = [];
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<ListResourcesResponse>>(
|
||||
`/org/${params.orgId}/resources`,
|
||||
authCookieHeader(),
|
||||
await authCookieHeader(),
|
||||
);
|
||||
resources = res.data.data.resources;
|
||||
} catch (e) {
|
||||
|
|
|
@ -22,20 +22,23 @@ import { ClientLayout } from "./components/ClientLayout";
|
|||
|
||||
interface SettingsLayoutProps {
|
||||
children: React.ReactNode;
|
||||
params: { niceId: string; orgId: string };
|
||||
params: Promise<{ niceId: string; orgId: string }>;
|
||||
}
|
||||
|
||||
export default async function SettingsLayout({
|
||||
children,
|
||||
params,
|
||||
}: SettingsLayoutProps) {
|
||||
export default async function SettingsLayout(props: SettingsLayoutProps) {
|
||||
const params = await props.params;
|
||||
|
||||
const {
|
||||
children
|
||||
} = props;
|
||||
|
||||
let site = null;
|
||||
|
||||
if (params.niceId !== "create") {
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetSiteResponse>>(
|
||||
`/org/${params.orgId}/site/${params.niceId}`,
|
||||
authCookieHeader(),
|
||||
await authCookieHeader(),
|
||||
);
|
||||
site = res.data.data;
|
||||
} catch {
|
||||
|
|
|
@ -3,11 +3,12 @@ import { Separator } from "@/components/ui/separator";
|
|||
import { CreateSiteForm } from "./components/CreateSite";
|
||||
import { GeneralForm } from "./components/GeneralForm";
|
||||
|
||||
export default function SettingsPage({
|
||||
params,
|
||||
}: {
|
||||
params: { niceId: string };
|
||||
}) {
|
||||
export default async function SettingsPage(
|
||||
props: {
|
||||
params: Promise<{ niceId: string }>;
|
||||
}
|
||||
) {
|
||||
const params = await props.params;
|
||||
const isCreate = params.niceId === "create";
|
||||
|
||||
return (
|
||||
|
|
|
@ -5,15 +5,16 @@ import { AxiosResponse } from "axios";
|
|||
import SitesTable, { SiteRow } from "./components/SitesTable";
|
||||
|
||||
type SitesPageProps = {
|
||||
params: { orgId: string };
|
||||
params: Promise<{ orgId: string }>;
|
||||
};
|
||||
|
||||
export default async function Page({ params }: SitesPageProps) {
|
||||
export default async function Page(props: SitesPageProps) {
|
||||
const params = await props.params;
|
||||
let sites: ListSitesResponse["sites"] = [];
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<ListSitesResponse>>(
|
||||
`/org/${params.orgId}/sites`,
|
||||
authCookieHeader(),
|
||||
await authCookieHeader(),
|
||||
);
|
||||
sites = res.data.data.sites;
|
||||
} catch (e) {
|
||||
|
|
|
@ -3,11 +3,12 @@ import { verifySession } from "@app/lib/auth/verifySession";
|
|||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { [key: string]: string | string[] | undefined };
|
||||
}) {
|
||||
export default async function Page(
|
||||
props: {
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}
|
||||
) {
|
||||
const searchParams = await props.searchParams;
|
||||
const user = await verifySession();
|
||||
|
||||
if (user) {
|
||||
|
|
|
@ -3,11 +3,12 @@ import { verifySession } from "@app/lib/auth/verifySession";
|
|||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { [key: string]: string | string[] | undefined };
|
||||
}) {
|
||||
export default async function Page(
|
||||
props: {
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}
|
||||
) {
|
||||
const searchParams = await props.searchParams;
|
||||
const user = await verifySession();
|
||||
|
||||
if (user) {
|
||||
|
|
|
@ -2,11 +2,12 @@ import VerifyEmailForm from "@app/app/auth/verify-email/VerifyEmailForm";
|
|||
import { verifySession } from "@app/lib/auth/verifySession";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { [key: string]: string | string[] | undefined };
|
||||
}) {
|
||||
export default async function Page(
|
||||
props: {
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}
|
||||
) {
|
||||
const searchParams = await props.searchParams;
|
||||
const user = await verifySession();
|
||||
|
||||
if (!user) {
|
||||
|
|
|
@ -29,7 +29,7 @@ export default async function RootLayout({
|
|||
try {
|
||||
const res = await internal.get<AxiosResponse<ListOrgsResponse>>(
|
||||
`/orgs`,
|
||||
authCookieHeader(),
|
||||
await authCookieHeader(),
|
||||
);
|
||||
if (res && res.data.data.orgs) {
|
||||
orgs = res.data.data.orgs;
|
||||
|
|
|
@ -20,7 +20,7 @@ export default async function Page() {
|
|||
try {
|
||||
const res = await internal.get<AxiosResponse<ListOrgsResponse>>(
|
||||
`/orgs`,
|
||||
authCookieHeader(),
|
||||
await authCookieHeader(),
|
||||
);
|
||||
if (res && res.data.data.orgs) {
|
||||
orgs = res.data.data.orgs;
|
||||
|
|
|
@ -2,13 +2,13 @@ import { internal } from "@app/api";
|
|||
import { authCookieHeader } from "@app/api/cookies";
|
||||
import { GetUserResponse } from "@server/routers/user";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function verifySession(): Promise<GetUserResponse | null> {
|
||||
const sessionId = cookies().get("session")?.value ?? null;
|
||||
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetUserResponse>>("/user", authCookieHeader());
|
||||
const res = await internal.get<AxiosResponse<GetUserResponse>>(
|
||||
"/user",
|
||||
await authCookieHeader()
|
||||
);
|
||||
|
||||
return res.data.data;
|
||||
} catch {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
|
@ -18,29 +14,17 @@
|
|||
"incremental": true,
|
||||
"baseUrl": "src",
|
||||
"paths": {
|
||||
"@server/*": [
|
||||
"../server/*"
|
||||
],
|
||||
"@app/*": [
|
||||
"*"
|
||||
],
|
||||
"@/*": [
|
||||
"./*"
|
||||
]
|
||||
"@server/*": ["../server/*"],
|
||||
"@app/*": ["*"],
|
||||
"@/*": ["./*"]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
"target": "ES2017"
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue