Skip to content

Commit 01b008e

Browse files
committed
update 05
1 parent 80c48ec commit 01b008e

File tree

6 files changed

+36
-29
lines changed

6 files changed

+36
-29
lines changed

04-frameworks/08-nextjs/05-server-side-rendering/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ npm run start:prod
5353
>
5454
> Press F5 and check that it renders again.
5555
56-
We can migrate use it on `car details` too:
56+
We can migrate and use it on `car details` too:
5757

5858
_./app/cars/\[carId\]/page.tsx_
5959

@@ -116,7 +116,7 @@ interface Props {
116116
}
117117

118118
export const generateMetadata = async (props: Props): Promise<Metadata> => {
119-
const { params } = props;
119+
const params = await props.params;
120120
- const car = await api.getCar(params.carId);
121121
+ const car = await api.getCar(params.carId, { cache: 'no-store' }); // Check 'force-cache' too
122122
return {
@@ -125,7 +125,7 @@ export const generateMetadata = async (props: Props): Promise<Metadata> => {
125125
};
126126

127127
const CarPage = async (props: Props) => {
128-
const { params } = props;
128+
const params = await props.params;
129129
- const car = await api.getCar(params.carId);
130130
+ const car = await api.getCar(params.carId, { cache: 'no-store' }); // Check 'force-cache' too
131131
console.log('Car page', car);

04-frameworks/08-nextjs/05-server-side-rendering/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

04-frameworks/08-nextjs/05-server-side-rendering/package.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,31 @@
33
"version": "1.0.0",
44
"description": "Nextjs examples",
55
"scripts": {
6-
"start": "run-p start:dev start:api-server",
6+
"start": "run-p -l start:dev start:api-server",
77
"start:dev": "next dev",
88
"build": "rimraf .next && next build",
99
"start:prod": "next start -p 8080",
1010
"start:api-server": "cd api-server && npm run mock-server",
1111
"postinstall": "cd ./api-server && npm install"
1212
},
1313
"imports": {
14-
"#*": [
15-
"./src/*",
16-
"./src/*.ts",
17-
"./src/*.tsx",
18-
"./src/*/index.ts",
19-
"./src/*/index.tsx"
20-
]
14+
"#*": "./src/*"
2115
},
2216
"author": "Lemoncode",
2317
"license": "MIT",
2418
"dependencies": {
25-
"next": "^14.2.9",
19+
"next": "^15.1.6",
2620
"normalize.css": "^8.0.1",
27-
"react": "^18.3.1",
28-
"react-dom": "^18.3.1",
21+
"react": "^19.0.0",
22+
"react-dom": "^19.0.0",
2923
"sharp": "^0.33.5"
3024
},
3125
"devDependencies": {
32-
"@types/node": "22.5.4",
33-
"@types/react": "^18.3.5",
34-
"@types/react-dom": "^18.3.0",
26+
"@types/node": "22.13.1",
27+
"@types/react": "^19.0.8",
28+
"@types/react-dom": "^19.0.3",
3529
"npm-run-all": "^4.1.5",
3630
"rimraf": "^6.0.1",
37-
"typescript": "^5.6.2"
31+
"typescript": "^5.7.3"
3832
}
3933
}

04-frameworks/08-nextjs/05-server-side-rendering/src/app/cars/[carId]/page.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ import { Metadata } from 'next';
33
import { Car, api, mapCarFromApiToVm } from '#pods/car';
44

55
interface Props {
6-
params: { carId: string };
6+
params: Promise<{ carId: string }>;
77
}
88

99
export const generateMetadata = async (props: Props): Promise<Metadata> => {
10-
const { params } = props;
10+
const params = await props.params;
1111
const car = await api.getCar(params.carId, { cache: 'no-store' }); // Check 'force-cache' too
12-
1312
return {
1413
title: `Rent a car - Car ${car.name} details`,
1514
};
1615
};
1716

1817
const CarPage = async (props: Props) => {
19-
const { params } = props;
18+
const params = await props.params;
2019
const car = await api.getCar(params.carId, { cache: 'no-store' }); // Check 'force-cache' too
2120
console.log('Car page', car);
2221

04-frameworks/08-nextjs/05-server-side-rendering/src/pods/car/api/car.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const getCar = async (
1414

1515
export const bookCar = async (car: Car): Promise<boolean> => {
1616
await fetch(`${url}/${car.id}`, {
17-
method: 'PUT',
17+
method: 'PATCH',
1818
headers: { 'Content-Type': 'application/json' },
1919
body: JSON.stringify(car),
2020
});

04-frameworks/08-nextjs/05-server-side-rendering/tsconfig.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"compilerOptions": {
3-
"lib": ["dom", "dom.iterable", "esnext"],
3+
"lib": [
4+
"dom",
5+
"dom.iterable",
6+
"esnext"
7+
],
48
"allowJs": true,
59
"skipLibCheck": true,
610
"strict": false,
@@ -19,9 +23,19 @@
1923
],
2024
"baseUrl": ".",
2125
"paths": {
22-
"#*": ["./src/*"]
23-
}
26+
"#*": [
27+
"./src/*"
28+
]
29+
},
30+
"target": "ES2017"
2431
},
25-
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
26-
"exclude": ["node_modules"]
32+
"include": [
33+
"next-env.d.ts",
34+
".next/types/**/*.ts",
35+
"**/*.ts",
36+
"**/*.tsx"
37+
],
38+
"exclude": [
39+
"node_modules"
40+
]
2741
}

0 commit comments

Comments
 (0)