Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Plüddemann committed Jul 25, 2024
1 parent 18061b8 commit b6b9232
Show file tree
Hide file tree
Showing 142 changed files with 7,459 additions and 7,259 deletions.
17 changes: 15 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"ignore": [
"node_modules",
"src/data",
".next"
".next",
".devenv",
".direnv",
"doc",
"public",
"screenshots"
]
},
"organizeImports": {
Expand All @@ -28,6 +33,14 @@
}
},
"formatter": {
"enabled": true
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf"
},
"json": {
"formatter": {
"trailingCommas": "none"
}
}
}
6 changes: 3 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
typedRoutes: true,
},
experimental: {
typedRoutes: true,
},
};

export default nextConfig;
26 changes: 13 additions & 13 deletions src/app/analyzer/[domainstory_id]/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
export default function Error({
error,
reset,
error,
reset,
}: {
error: Error;
reset: () => void;
error: Error;
reset: () => void;
}) {
return (
<div className="flex flex-grow flex-col items-center margin-auto">
<h2>Something went wrong!</h2>
<p>{error.message}</p>
<button onClick={() => reset()} className="btn">
Try again
</button>
</div>
);
return (
<div className="flex flex-grow flex-col items-center margin-auto">
<h2>Something went wrong!</h2>
<p>{error.message}</p>
<button onClick={() => reset()} className="btn">
Try again
</button>
</div>
);
}
6 changes: 3 additions & 3 deletions src/app/analyzer/[domainstory_id]/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class DomainStoryNotFoundError extends Error {
constructor({ id }: { id: string }) {
super(`Domain Story with id ${id} not found`);
}
constructor({ id }: { id: string }) {
super(`Domain Story with id ${id} not found`);
}
}
104 changes: 52 additions & 52 deletions src/app/analyzer/[domainstory_id]/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,70 @@ import type { RuntimeQualityAnalysisDefinition } from "@/types/rqa/definition/Ru
import { DomainStoryNotFoundError } from "./errors";

const backendUrl = new URL(
"/api/v2",
`http://${process.env.DQAPI_HOST}` || "http://localhost:8099",
"/api/v2",
`http://${process.env.DQAPI_HOST}` || "http://localhost:8099",
);

export const readAllRqas = async (): Promise<
RuntimeQualityAnalysisDefinition[]
RuntimeQualityAnalysisDefinition[]
> => {
try {
const res = await fetch(`${backendUrl}/rqa`, {
next: { tags: ["rqas"], revalidate: 30 },
});
if (!res.ok) {
throw new Error("Failed to fetch data");
}
try {
const res = await fetch(`${backendUrl}/rqa`, {
next: { tags: ["rqas"], revalidate: 30 },
});
if (!res.ok) {
throw new Error("Failed to fetch data");
}

return await res.json();
} catch (error) {
console.error("Error fetching rqas:", error);
throw error;
}
return await res.json();
} catch (error) {
console.error("Error fetching rqas:", error);
throw error;
}
};

export const readDomainstoryById = async (id: string): Promise<DomainStory> => {
try {
const res = await fetch(`${backendUrl}/domain-story/${id}`, {
next: { tags: ["domainstories"], revalidate: 30 },
});
try {
const res = await fetch(`${backendUrl}/domain-story/${id}`, {
next: { tags: ["domainstories"], revalidate: 30 },
});

switch (res.status) {
case 200:
return await res.json();
case 404:
throw new DomainStoryNotFoundError({ id });
default:
throw new Error("Unknown error");
}
} catch (error) {
console.error("Error fetching domain story:", error);
throw error;
}
switch (res.status) {
case 200:
return await res.json();
case 404:
throw new DomainStoryNotFoundError({ id });
default:
throw new Error("Unknown error");
}
} catch (error) {
console.error("Error fetching domain story:", error);
throw error;
}
};

export const readDamByDomainStoryId = async (
id: string,
id: string,
): Promise<DomainArchitectureMapping> => {
try {
const res = await fetch(`${backendUrl}/dam/domain-story/${id}`);
try {
const res = await fetch(`${backendUrl}/dam/domain-story/${id}`);

switch (res.status) {
case 200:
return await await res.json();
case 400:
throw new Error("Invalid domain story ID");
case 401:
throw new Error("Unauthorized");
case 404:
throw new Error("DAM not found");
case 500:
throw new Error("Internal server error");
default:
throw new Error("Unknown error");
}
} catch (error) {
console.error("Error fetching DAM:", error);
throw error;
}
switch (res.status) {
case 200:
return await await res.json();
case 400:
throw new Error("Invalid domain story ID");
case 401:
throw new Error("Unauthorized");
case 404:
throw new Error("DAM not found");
case 500:
throw new Error("Internal server error");
default:
throw new Error("Unknown error");
}
} catch (error) {
console.error("Error fetching DAM:", error);
throw error;
}
};
14 changes: 7 additions & 7 deletions src/app/analyzer/[domainstory_id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import { ReactFlowProvider } from "reactflow";

export default function Layout({
children,
children,
}: Readonly<{
children: React.ReactNode;
children: React.ReactNode;
}>) {
return (
<div className="root">
<ReactFlowProvider>{children}</ReactFlowProvider>
</div>
);
return (
<div className="root">
<ReactFlowProvider>{children}</ReactFlowProvider>
</div>
);
}
24 changes: 12 additions & 12 deletions src/app/analyzer/[domainstory_id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {
readAllRqas,
readDamByDomainStoryId,
readDomainstoryById,
readAllRqas,
readDamByDomainStoryId,
readDomainstoryById,
} from "@/app/analyzer/[domainstory_id]/fetch";
import { DqContextProvider } from "@/app/providers/DqContext";
import Graph from "@/components/analyzer/graph";

export default async function Analyzer({
params,
params,
}: { params: { domainstory_id: string } }) {
const domainstory = await readDomainstoryById(params.domainstory_id);
const rqas = await readAllRqas();
const dam = await readDamByDomainStoryId(domainstory.id);
const domainstory = await readDomainstoryById(params.domainstory_id);
const rqas = await readAllRqas();
const dam = await readDamByDomainStoryId(domainstory.id);

return (
<DqContextProvider value={{ dam, domainstory, rqas }}>
<Graph />
</DqContextProvider>
);
return (
<DqContextProvider value={{ dam, domainstory, rqas }}>
<Graph />
</DqContextProvider>
);
}
26 changes: 13 additions & 13 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
export default function Error({
error,
reset,
error,
reset,
}: {
error: Error;
reset: () => void;
error: Error;
reset: () => void;
}) {
return (
<div className="flex flex-grow flex-col items-center margin-auto">
<h2>Something went wrong!</h2>
<p>{error.message}</p>
<button onClick={() => reset()} className="btn">
Try again
</button>
</div>
);
return (
<div className="flex flex-grow flex-col items-center margin-auto">
<h2>Something went wrong!</h2>
<p>{error.message}</p>
<button onClick={() => reset()} className="btn">
Try again
</button>
</div>
);
}
42 changes: 21 additions & 21 deletions src/app/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use server";

const backendUrl = new URL(
"/api/v2/domain-story",
`http://${process.env.DQAPI_HOST}` || "http://localhost:8099",
"/api/v2/domain-story",
`http://${process.env.DQAPI_HOST}` || "http://localhost:8099",
);

/**
Expand All @@ -11,25 +11,25 @@ const backendUrl = new URL(
* @returns {Promise<string[]>} A promise that resolves to an array of domain story IDs.
*/
export const readAllDomainStoryIds = async (): Promise<string[]> => {
try {
// Send a GET request to the backend's '/api/v2/domain-story/ids' endpoint.
// The 'cache' option is set to 'no-store' to prevent caching of the response.
const res = await fetch(`${backendUrl}/ids`, {
cache: "no-store",
});
try {
// Send a GET request to the backend's '/api/v2/domain-story/ids' endpoint.
// The 'cache' option is set to 'no-store' to prevent caching of the response.
const res = await fetch(`${backendUrl}/ids`, {
cache: "no-store",
});

// If the response status is not OK, throw an error.
if (!res.ok) {
throw new Error(
`Failed to fetch domain story IDs: ${res.status} ${res.statusText}`,
);
}
// If the response status is not OK, throw an error.
if (!res.ok) {
throw new Error(
`Failed to fetch domain story IDs: ${res.status} ${res.statusText}`,
);
}

// Parse the response as JSON and return it.
return await res.json();
} catch (error) {
// If an error occurs, log it to the console and rethrow it.
console.error("Error fetching domain story IDs:", error);
throw error;
}
// Parse the response as JSON and return it.
return await res.json();
} catch (error) {
// If an error occurs, log it to the console and rethrow it.
console.error("Error fetching domain story IDs:", error);
throw error;
}
};
18 changes: 9 additions & 9 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import "./globals.css";
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
children,
}: Readonly<{
children: React.ReactNode;
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
}
Loading

0 comments on commit b6b9232

Please sign in to comment.