Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf!: Update to NextJS 15.0.0-canary.177 & next-intl 3.21.0-canary #543

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"@nestjs/schedule": "^4.1.1",
"@nestjs/serve-static": "^4.0.2",
"pg": "^8.13.0",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-dom": "19.0.0-rc-fb9a90fa48-20240614",
"react": "19.0.0-rc-459fd418-20241001",
"react-dom": "19.0.0-rc-459fd418-20241001",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
},
Expand All @@ -42,7 +42,7 @@
"@types/express": "^4.17.21",
"@types/node": "^22.7.4",
"@types/pg": "^8.11.10",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cross-env": "^7.0.3",
Expand Down
8 changes: 1 addition & 7 deletions apps/frontend/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import type { NextConfig } from 'next';
import VitNodeConfig from 'vitnode-frontend/next.config';

// @ts-ignore
const nextConfig: NextConfig = {
logging: {
fetches: {
fullUrl: process.env.NODE_ENV === 'development',
},
},
};
const nextConfig: NextConfig = {};

export default VitNodeConfig(nextConfig);
10 changes: 5 additions & 5 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"dependencies": {
"geist": "^1.3.1",
"lucide-react": "^0.446.0",
"next": "15.0.0-canary.158",
"next-intl": "^3.20.0",
"react": "19.0.0-rc-fb9a90fa48-20240614",
"react-dom": "19.0.0-rc-fb9a90fa48-20240614",
"next": "15.0.0-canary.177",
"next-intl": "3.21.0-canary.0",
"react": "19.0.0-rc-459fd418-20241001",
"react-dom": "19.0.0-rc-459fd418-20241001",
"react-hook-form": "^7.53.0",
"sonner": "^1.5.0",
"vitnode-frontend": "workspace:*",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^22.7.4",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.20",
"eslint-config-typescript-vitnode": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// ! DO NOT TOUCH THIS FILE!!! IT IS GENERATED BY VITNODE-CLI
import {
DevPluginAdminLayout,
DevPluginAdminLayoutProps,
generateMetadataDevPluginAdminLayout,
} from 'vitnode-frontend/admin/core/plugins/views/dev/layout/layout';

export const generateMetadata = generateMetadataDevPluginAdminLayout;

export default function Layout(props: DevPluginAdminLayoutProps) {
export default function Layout(
props: React.ComponentProps<typeof DevPluginAdminLayout>,
) {
return <DevPluginAdminLayout {...props} />;
}
3 changes: 1 addition & 2 deletions apps/frontend/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { GeistSans } from 'geist/font/sans';
import {
generateMetadataRootLayout,
RootLayout,
RootLayoutProps,
} from 'vitnode-frontend/views/layout/root-layout';

import './global.css';

export const generateMetadata = generateMetadataRootLayout;

export default function Layout(props: RootLayoutProps) {
export default function Layout(props: React.ComponentProps<typeof RootLayout>) {
return <RootLayout className={GeistSans.className} {...props} />;
}
28 changes: 19 additions & 9 deletions apps/frontend/src/i18n/request.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { getRequestConfig } from 'next-intl/server';
import { i18nConfig } from 'vitnode-frontend/i18n';

export default getRequestConfig(async args => {
const config = await i18nConfig({
...args,
pathsToMessagesFromPlugins: async ({ plugin, locale }) => {
return import(`@/plugins/${plugin}/langs/${locale}.json`);
},
});
export default getRequestConfig(async ({ requestLocale }) => {
let locale = await requestLocale;

if (!locale) {
locale = 'en';
}

return config;
const core = (await import(`@/plugins/core/langs/${locale}.json`)).default;
const admin = (await import(`@/plugins/admin/langs/${locale}.json`)).default;
const welcome = (await import(`@/plugins/welcome/langs/${locale}.json`))
.default;

return {
locale,
messages: {
...core,
...admin,
...welcome,
},
};
});
15 changes: 13 additions & 2 deletions apps/frontend/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { createMiddleware } from 'vitnode-frontend/middleware';
import createMiddleware from 'next-intl/middleware';
import { NextRequest } from 'next/server';

export default createMiddleware();
export default function middleware(request: NextRequest) {
// Step 2: Create and call the next-intl middleware (example)
const handleI18nRouting = createMiddleware({
locales: ['en'],
defaultLocale: 'en',
localePrefix: 'as-needed',
});
const response = handleI18nRouting(request);

return response;
}

export const config = {
matcher: '/((?!_next|robots.txt|sitemap.xml|sitemap).*)',
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"typescript": "^5.5.4"
},
"dependencies": {
"@ai-sdk/google": "^0.0.48",
"@ai-sdk/openai": "^0.0.61",
"@ai-sdk/google": "^0.0.51",
"@ai-sdk/openai": "^0.0.64",
"@apollo/server": "^4.11.0",
"@graphql-codegen/near-operation-file-preset": "^3.0.0",
"@graphql-codegen/typescript": "^4.0.9",
Expand All @@ -70,7 +70,7 @@
"@react-email/render": "^1.0.1",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.28",
"ai": "^3.4.0",
"ai": "^3.4.8",
"busboy": "^1.6.0",
"cookie-parser": "^1.4.6",
"helmet": "^8.0.0",
Expand Down Expand Up @@ -98,7 +98,7 @@
"@types/nodemailer": "^6.4.16",
"@types/object-path": "^0.11.4",
"@types/pg": "^8.11.10",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"concurrently": "^9.0.1",
Expand Down
12 changes: 7 additions & 5 deletions packages/backend/src/core/admin/members/show/show.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ export class ShowAdminMembersService {
const where = id
? eq(core_users.id, id)
: and(
or(
ilike(core_users.name, `%${search}%`),
ilike(core_users.email, `%${search}%`),
Number(search) ? eq(core_users.id, Number(search)) : undefined,
),
search
? or(
ilike(core_users.name, `%${search}%`),
ilike(core_users.email, `%${search}%`),
Number(search) ? eq(core_users.id, Number(search)) : undefined,
)
: undefined,
groups && groups.length > 0
? inArray(core_users.group_id, groups)
: undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/create-vitnode-app/helpers/create-packages-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const createPackagesJSON = ({
},
devDependencies: {
'@types/node': '^22.7.4',
'@types/react': '^18.3.10',
'@types/react': '^18.3.11',
'@types/react-dom': '^18.3.0',
autoprefixer: '^10.4.20',
...(eslint ? { eslint: '^9.11.1' } : {}),
Expand Down Expand Up @@ -154,7 +154,7 @@ export const createPackagesJSON = ({
'@types/express': '^4.17.21',
'@types/node': '^22.7.4',
'@types/pg': '^8.11.10',
'@types/react': '^18.3.10',
'@types/react': '^18.3.11',
'cross-env': '^7.0.3',
'drizzle-kit': '^0.24.2',
'drizzle-orm': '^0.33.0',
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config-typescript-vitnode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"@eslint/js": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-perfectionist": "^3.7.0",
"eslint-plugin-perfectionist": "^3.8.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.0",
"globals": "^15.9.0",
"eslint-plugin-react": "^7.37.1",
"globals": "^15.10.0",
"prettier-plugin-tailwindcss": "^0.6.8",
"typescript-eslint": "^8.7.0"
"typescript-eslint": "^8.8.0"
}
}
4 changes: 2 additions & 2 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
"eslint-config-typescript-vitnode": "workspace:*",
"graphql-tag": "^2.12.6",
"lucide-react": "^0.446.0",
"next": "15.0.0-canary.158",
"next-intl": "^3.20.0",
"next": "15.0.0-canary.177",
"next-intl": "3.21.0-canary.0",
"react": "19.0.0-rc-e56f4ae3-20240830",
"react-dom": "19.0.0-rc-e56f4ae3-20240830",
"react-hook-form": "^7.53.0",
Expand Down
13 changes: 8 additions & 5 deletions packages/frontend/src/graphql/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const cookieFromStringToObject = (

export const setCookieFromApi = ({ res }: { res: Response }) => {
return cookieFromStringToObject(res.headers.getSetCookie()).forEach(
cookie => {
async cookie => {
const key = Object.keys(cookie)[0];
const value = Object.values(cookie)[0];

if (typeof value !== 'string' || typeof key !== 'string') return;

cookies().set(key, value, {
(await cookies()).set(key, value, {
domain: cookie.Domain,
path: cookie.Path,
expires: new Date(cookie.Expires),
Expand Down Expand Up @@ -150,15 +150,18 @@ export async function fetcher<TData, TVariables = object>({
});
}

const nextInternalHeaders = nextHeaders();
const [nextInternalHeaders, cookie] = await Promise.all([
nextHeaders(),
cookies(),
]);

const internalHeaders = {
Cookie: cookies().toString(),
Cookie: cookie.toString(),
['user-agent']: nextInternalHeaders.get('user-agent') ?? 'node',
['x-forwarded-for']:
nextInternalHeaders.get('x-forwarded-for') ?? '0.0.0.0',
['x-real-ip']: nextInternalHeaders.get('x-real-ip') ?? '0.0.0.0',
'x-vitnode-user-language': cookies().get('NEXT_LOCALE')?.value ?? 'en',
'x-vitnode-user-language': cookie.get('NEXT_LOCALE')?.value ?? 'en',
...headers,
};

Expand Down
10 changes: 6 additions & 4 deletions packages/frontend/src/graphql/get-pagination-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface SearchParamsPagination {

interface Args<T> {
defaultPageSize: 10 | 20 | 30 | 40 | 50;
searchParams: SearchParamsPagination;
searchParams: Promise<SearchParamsPagination>;
search?: boolean;
sortByEnum?: T;
}
Expand All @@ -23,11 +23,13 @@ interface ReturnValues<T> {
sortBy?: { column: keyof T; direction: SortDirectionEnum };
}

export function getPaginationTool<T extends Record<string, unknown>>({
export async function getPaginationTool<T extends Record<string, unknown>>({
defaultPageSize,
searchParams,
searchParams: searchParamsPromise,
sortByEnum,
}: Args<T>): ReturnValues<T> {
}: Args<T>): Promise<ReturnValues<T>> {
const searchParams = await searchParamsPromise;

const pagination = {
first: Number(searchParams?.last ?? 0)
? null
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/graphql/get-user-id-cookie.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { cookies } from 'next/headers';
import 'server-only';

export const getUserIdCookie = () => {
return cookies().get('vitnode-user-id')?.value;
export const getUserIdCookie = async () => {
return (await cookies()).get('vitnode-user-id')?.value;
};

export const getAdminIdCookie = () => {
return cookies().get('vitnode-admin-id')?.value;
export const getAdminIdCookie = async () => {
return (await cookies()).get('vitnode-admin-id')?.value;
};
8 changes: 5 additions & 3 deletions packages/frontend/src/hooks/core/sign/in/mutation-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { revalidateTags } from '@/graphql/revalidate-tags';
import { redirect } from '@/navigation';
import { cookies } from 'next/headers';
import { getLocale } from 'next-intl/server';

export const mutationApi = async (
variables: Core_Sessions__Sign_InMutationVariables,
Expand All @@ -23,14 +24,14 @@ export const mutationApi = async (
variables,
});

const cookie = cookies();
const cookie = await cookies();
if (!variables.admin) {
const userIdFromCookie = cookie.get('vitnode-user-id')?.value;
if (userIdFromCookie) {
revalidateTags.session(+userIdFromCookie);
}
} else {
const adminIdFromCookie = getAdminIdCookie();
const adminIdFromCookie = await getAdminIdCookie();
if (adminIdFromCookie) {
revalidateTags.sessionAdmin(+adminIdFromCookie);
}
Expand All @@ -41,5 +42,6 @@ export const mutationApi = async (
return { error: e.message };
}

redirect(variables.admin ? '/admin/core/dashboard' : '/');
const locale = await getLocale();
redirect({ href: variables.admin ? '/admin/core/dashboard' : '/', locale });
};
6 changes: 4 additions & 2 deletions packages/frontend/src/hooks/core/sign/out/mutation-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@/graphql/mutations/sessions/core_sessions__sign_out.generated';
import { revalidateTags } from '@/graphql/revalidate-tags';
import { redirect } from '@/navigation';
import { getLocale } from 'next-intl/server';

export const mutationApi = async () => {
try {
Expand All @@ -19,7 +20,7 @@ export const mutationApi = async () => {
query: Core_Sessions__Sign_Out,
});

const userIdFromCookie = getUserIdCookie();
const userIdFromCookie = await getUserIdCookie();
if (userIdFromCookie) {
revalidateTags.session(+userIdFromCookie);
}
Expand All @@ -29,5 +30,6 @@ export const mutationApi = async () => {
return { error: e.message };
}

redirect('/');
const locale = await getLocale();
redirect({ href: '/', locale });
};
Loading
Loading