Skip to content

Commit 9b81f15

Browse files
build(deps): bump axios and @directus/sdk (#521)
* build(deps): bump axios and @directus/sdk Bumps [axios](https://github.com/axios/axios) to 1.8.3 and updates ancestor dependency [@directus/sdk](https://github.com/directus/directus/tree/HEAD/sdk). These dependencies need to be updated together. Updates `axios` from 1.7.9 to 1.8.3 - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](axios/axios@v1.7.9...v1.8.3) Updates `@directus/sdk` from 10.3.5 to 18.0.3 - [Release notes](https://github.com/directus/directus/releases) - [Commits](https://github.com/directus/directus/commits/HEAD/sdk) --- updated-dependencies: - dependency-name: axios dependency-type: indirect - dependency-name: "@directus/sdk" dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * feat: migrate to latest directus sdk * fix: typescript issue with readonly string[] of languages --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: David Scheidt <[email protected]>
1 parent 3c51c55 commit 9b81f15

File tree

6 files changed

+73
-84
lines changed

6 files changed

+73
-84
lines changed

app/i18next-options.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
export const supportedLanguages = ["en", "de"] as const;
2+
13
export default {
24
// This is the list of languages your application supports
3-
supportedLngs: ["en", "de"],
5+
supportedLngs: supportedLanguages,
46
// This is the language you want to use in case
57
// if the user language is not in the supportedLngs
68
fallbackLng: "en",

app/i18next.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let i18next: RemixI18Next = new RemixI18Next({
88
detection: {
99
// persist language selection in cookie
1010
cookie: i18nCookie,
11-
supportedLanguages: i18nextOptions.supportedLngs,
11+
supportedLanguages: [...i18nextOptions.supportedLngs],
1212
fallbackLanguage: i18nextOptions.fallbackLng,
1313
},
1414
// This is the configuration for i18next used

app/lib/directus.ts

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,45 @@
1-
import { Directus, type ID } from '@directus/sdk';
1+
import {
2+
createDirectus,
3+
type DirectusClient,
4+
rest,
5+
type RestClient,
6+
} from "@directus/sdk";
27

3-
const directusUrl = process.env.DIRECTUS_URL || 'http://localhost:8055'
8+
const directusUrl = process.env.DIRECTUS_URL || "http://localhost:8055";
49

510
export type UseCase = {
6-
id: ID,
7-
status: string,
8-
image: string,
9-
title: string,
10-
description: string,
11-
content: string,
12-
language: "de" | "en"
13-
}
11+
id: number | string;
12+
status: string;
13+
image: string;
14+
title: string;
15+
description: string;
16+
content: string;
17+
language: "de" | "en";
18+
};
1419

1520
export type Feature = {
16-
id: ID,
17-
title: string,
18-
description: string,
19-
icon: string,
20-
language: "de" | "en"
21-
}
21+
id: number | string;
22+
title: string;
23+
description: string;
24+
icon: string;
25+
language: "de" | "en";
26+
};
2227

2328
export type Partner = {
24-
id: ID,
25-
name: string,
26-
logo: string,
27-
link: string
28-
}
29+
id: number | string;
30+
name: string;
31+
logo: string;
32+
link: string;
33+
};
2934

3035
type DirectusCollection = {
31-
use_cases: UseCase,
32-
features: Feature,
33-
partners: Partner
34-
}
36+
use_cases: UseCase[];
37+
features: Feature[];
38+
partners: Partner[];
39+
};
3540

36-
const directus = new Directus<DirectusCollection>(directusUrl)
41+
const directus = createDirectus<DirectusCollection>(directusUrl).with(rest());
3742

38-
export async function getDirectusClient () {
39-
return directus
40-
}
43+
export function getDirectusClient(): DirectusClient<DirectusCollection> & RestClient<DirectusCollection> {
44+
return directus;
45+
}

app/routes/_index.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readItems } from "@directus/sdk";
12
import { useMediaQuery } from "@mantine/hooks";
23
import { motion } from "framer-motion";
34
import { useTranslation } from "react-i18next";
@@ -11,6 +12,7 @@ import Integrations from "~/components/landing/sections/integrations";
1112
import Partners from "~/components/landing/sections/partners";
1213
import PricingPlans from "~/components/landing/sections/pricing-plans";
1314
import Stats from "~/components/landing/stats";
15+
import { type supportedLanguages } from "~/i18next-options";
1416
import i18next from "~/i18next.server";
1517
import { type Partner, getDirectusClient } from "~/lib/directus";
1618
import { getLatestDevices } from "~/models/device.server";
@@ -44,26 +46,26 @@ const sections = [
4446
];
4547

4648
export const loader = async ({ request }: LoaderFunctionArgs) => {
47-
let locale = await i18next.getLocale(request);
48-
const directus = await getDirectusClient();
49+
const locale = await i18next.getLocale(request) as typeof supportedLanguages[number];
50+
const directus = getDirectusClient();
4951

50-
const useCasesResponse = await directus.items("use_cases").readByQuery({
52+
const useCasesResponse = await directus.request(readItems("use_cases", {
5153
fields: ["*"],
5254
filter: {
53-
language: locale,
55+
language: {_eq: locale },
5456
},
55-
});
57+
}));
5658

57-
const featuresResponse = await directus.items("features").readByQuery({
59+
const featuresResponse = await directus.request(readItems("features", {
5860
fields: ["*"],
5961
filter: {
60-
language: locale,
62+
language: {_eq: locale },
6163
},
62-
});
64+
}));
6365

64-
const partnersResponse = await directus.items("partners").readByQuery({
66+
const partnersResponse = await directus.request(readItems("partners", {
6567
fields: ["*"],
66-
});
68+
}));
6769

6870
//* Get user Id from session
6971
const userId = await getUserId(request);
@@ -78,9 +80,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
7880
const latestDevices = await getLatestDevices();
7981

8082
return data({
81-
useCases: useCasesResponse.data,
82-
features: featuresResponse.data,
83-
partners: partnersResponse.data,
83+
useCases: useCasesResponse,
84+
features: featuresResponse,
85+
partners: partnersResponse,
8486
stats: stats,
8587
header: { userId: userId, userName: userName },
8688
locale: locale,

package-lock.json

Lines changed: 19 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@conform-to/react": "^0.9.2",
3131
"@conform-to/zod": "^0.9.2",
32-
"@directus/sdk": "^10.3.5",
32+
"@directus/sdk": "^18.0.3",
3333
"@heroicons/react": "^2.0.18",
3434
"@hookform/resolvers": "^3.3.4",
3535
"@isaacs/express-prometheus-middleware": "^1.2.1",

0 commit comments

Comments
 (0)