Skip to content

Commit

Permalink
fix: build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Sep 25, 2024
1 parent 2bbc98b commit df2f30b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions apps/nextjs/src/app/[locale]/manage/tools/api/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Stack, Tabs, TabsList, TabsPanel, TabsTab } from "@mantine/core";
import { openApiDocument } from "@homarr/api";
import { api } from "@homarr/api/server";
import { extractBaseUrlFromHeaders } from "@homarr/common";
import { useScopedI18n } from "@homarr/translation/client";
import { getScopedI18n } from "@homarr/translation/server";

import { SwaggerUIClient } from "~/app/[locale]/manage/tools/api/components/swagger-ui";
Expand All @@ -21,13 +22,14 @@ export async function generateMetadata() {
export default async function ApiPage() {
const document = openApiDocument(extractBaseUrlFromHeaders(headers()));
const apiKeys = await api.apiKeys.getAll();
const t = useScopedI18n("management.page.tool.api.tab");

return (
<Stack>
<Tabs defaultValue={"documentation"}>
<TabsList>
<TabsTab value={"documentation"}>Documentation</TabsTab>
<TabsTab value={"authentication"}>Authentication</TabsTab>
<TabsTab value={"documentation"}>{t("documentation.label")}</TabsTab>
<TabsTab value={"authentication"}>{t("apiKey.label")}</TabsTab>
</TabsList>
<TabsPanel value={"authentication"}>
<ApiKeysManagement apiKeys={apiKeys} />
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/api/[...trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const handlerAsync = async (req: Request) => {
let session: Session | null;

logger.info(
"Creating OpenAPI fetch handler for user " + (apiKeyHeaderValue ? "with an api key" : "without an api key"),
`Creating OpenAPI fetch handler for user ${apiKeyHeaderValue ? "with an api key" : "without an api key"}`,
);

if (apiKeyHeaderValue !== null) {
Expand Down Expand Up @@ -46,7 +46,7 @@ const handlerAsync = async (req: Request) => {
req,
endpoint: "/",
router: appRouter,
createContext: () => createTRPCContext({ session: session, headers: req.headers }),
createContext: () => createTRPCContext({ session, headers: req.headers }),
});
};

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/router/apiKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const apiKeysRouter = createTRPCRouter({
await db.insert(apiKeys).values({
id: createId(),
apiKey: hashedRandomToken,
salt: salt,
salt,
userId: ctx.session.user.id,
});
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/callbacks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { cookies } from "next/headers";
import type { Adapter } from "@auth/core/adapters";
import type { Session } from "@auth/core/types";
import dayjs from "dayjs";
import type { NextAuthConfig } from "next-auth";

import type { Session } from "@homarr/auth";
import type { Database } from "@homarr/db";
import { eq, inArray } from "@homarr/db";
import { groupMembers, groupPermissions, users } from "@homarr/db/schema/sqlite";
Expand Down Expand Up @@ -43,7 +43,7 @@ export const createSessionAsync = async (
permissions: await getCurrentUserPermissionsAsync(db, user.id),
colorScheme: "auto",
},
} satisfies Session;
} as Session;
};

export const createSessionCallback = (db: Database): NextAuthCallbackOf<"session"> => {
Expand Down
4 changes: 4 additions & 0 deletions packages/translation/src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,11 @@ export default {
},
},
tab: {
documentation: {
label: "Documentation",
},
apiKey: {
label: "Authentication",
title: "API Keys",
button: {
createApiToken: "Create API token",
Expand Down

0 comments on commit df2f30b

Please sign in to comment.