Skip to content

Commit 94e992f

Browse files
authored
test: import app-pages-router from aws (#292)
1 parent 60e7582 commit 94e992f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1241
-0
lines changed

examples/e2e/app-pages-router/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SOME_ENV_VAR=foo
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
.open-next
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
38+
# playwright
39+
/test-results/
40+
/playwright-report/
41+
/blob-report/
42+
/playwright/.cache/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# app-pages-router
2+
3+
## 0.1.6
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`7eda030388880d8ad25d3f4692e24bac31b7ec4f`](https://github.com/opennextjs/opennextjs-aws/commit/7eda030388880d8ad25d3f4692e24bac31b7ec4f), [`e5678b39e0f3c21d3e30d08a89f5cb0acdd3d050`](https://github.com/opennextjs/opennextjs-aws/commit/e5678b39e0f3c21d3e30d08a89f5cb0acdd3d050), [`1981a47dd3dbc77066d2bf5cad5d5d406fecb010`](https://github.com/opennextjs/opennextjs-aws/commit/1981a47dd3dbc77066d2bf5cad5d5d406fecb010), [`b4ad0f0e0f6069ca87f3b72c23d655cedebc86e5`](https://github.com/opennextjs/opennextjs-aws/commit/b4ad0f0e0f6069ca87f3b72c23d655cedebc86e5)]:
8+
- @opennextjs/aws@3.4.1
9+
10+
## 0.1.5
11+
12+
### Patch Changes
13+
14+
- Updated dependencies [[`e8f6dc8c7a421e316f5fbed03dcb82bb860c5249`](https://github.com/opennextjs/opennextjs-aws/commit/e8f6dc8c7a421e316f5fbed03dcb82bb860c5249), [`00ce837cb98e5902316f26163c9fb927058f956c`](https://github.com/opennextjs/opennextjs-aws/commit/00ce837cb98e5902316f26163c9fb927058f956c), [`d1cea5601943afaa197d56f931593234f351c441`](https://github.com/opennextjs/opennextjs-aws/commit/d1cea5601943afaa197d56f931593234f351c441), [`6884444cb929ab60c074c918954d24100f4e9668`](https://github.com/opennextjs/opennextjs-aws/commit/6884444cb929ab60c074c918954d24100f4e9668), [`86916bfd9246a63f321352bb11346eeb0ca3f6da`](https://github.com/opennextjs/opennextjs-aws/commit/86916bfd9246a63f321352bb11346eeb0ca3f6da), [`eaa9ef8daf2fc454139c77ce0e100cb48da15561`](https://github.com/opennextjs/opennextjs-aws/commit/eaa9ef8daf2fc454139c77ce0e100cb48da15561), [`ae7fb9c5d24ecf3eeb99682aa34bcbe0adb45675`](https://github.com/opennextjs/opennextjs-aws/commit/ae7fb9c5d24ecf3eeb99682aa34bcbe0adb45675), [`e708ec4d9f4c87d3249a01382482347d295ed28a`](https://github.com/opennextjs/opennextjs-aws/commit/e708ec4d9f4c87d3249a01382482347d295ed28a)]:
15+
- @opennextjs/aws@3.4.0
16+
17+
## 0.1.4
18+
19+
### Patch Changes
20+
21+
- Updated dependencies [[`9595714ac23e5f131b879d04d5cfb2a5d11bdbdd`](https://github.com/opennextjs/opennextjs-aws/commit/9595714ac23e5f131b879d04d5cfb2a5d11bdbdd), [`4e88b47935523de1d15da067b56105bd6be91e47`](https://github.com/opennextjs/opennextjs-aws/commit/4e88b47935523de1d15da067b56105bd6be91e47), [`7140ca56e1e88d7a7cae327eceb3ef8c2fde2a1e`](https://github.com/opennextjs/opennextjs-aws/commit/7140ca56e1e88d7a7cae327eceb3ef8c2fde2a1e)]:
22+
- @opennextjs/aws@3.3.1
23+
24+
## 0.1.3
25+
26+
### Patch Changes
27+
28+
- Updated dependencies [[`4d328e3fc306b878e9497986baa65bfd1d4de66a`](https://github.com/opennextjs/opennextjs-aws/commit/4d328e3fc306b878e9497986baa65bfd1d4de66a), [`2b2a48b70ae95b5e600ac2e4b7f2df8702c5c26e`](https://github.com/opennextjs/opennextjs-aws/commit/2b2a48b70ae95b5e600ac2e4b7f2df8702c5c26e), [`f685ddea8f8a5c82591dc02713aff7138f2d9896`](https://github.com/opennextjs/opennextjs-aws/commit/f685ddea8f8a5c82591dc02713aff7138f2d9896), [`ef1fe48d570863266c271e5dedaf02b943849ded`](https://github.com/opennextjs/opennextjs-aws/commit/ef1fe48d570863266c271e5dedaf02b943849ded), [`8ab921f8b5bd40c7ba109ccef3e59a6c24283fb2`](https://github.com/opennextjs/opennextjs-aws/commit/8ab921f8b5bd40c7ba109ccef3e59a6c24283fb2), [`2202f36ce0f87357b249bd127cdd5e84d6deffd3`](https://github.com/opennextjs/opennextjs-aws/commit/2202f36ce0f87357b249bd127cdd5e84d6deffd3), [`44392ba82990d43e16a614113d9e7d8e257e5bdd`](https://github.com/opennextjs/opennextjs-aws/commit/44392ba82990d43e16a614113d9e7d8e257e5bdd), [`4dea7ea2f5ffd1848e51502c88d2efcc1896bb8c`](https://github.com/opennextjs/opennextjs-aws/commit/4dea7ea2f5ffd1848e51502c88d2efcc1896bb8c), [`0ac604e5867497cc93fb677b5ebc28ef87e057f8`](https://github.com/opennextjs/opennextjs-aws/commit/0ac604e5867497cc93fb677b5ebc28ef87e057f8), [`1ece6b479bb4e0309892ffbd1200870821a410c4`](https://github.com/opennextjs/opennextjs-aws/commit/1ece6b479bb4e0309892ffbd1200870821a410c4), [`697681bf9ce25212ce4e2e94d886ca425428280d`](https://github.com/opennextjs/opennextjs-aws/commit/697681bf9ce25212ce4e2e94d886ca425428280d)]:
29+
- @opennextjs/aws@3.3.0
30+
31+
## 0.1.2
32+
33+
### Patch Changes
34+
35+
- Updated dependencies [[`6f798debb575b157acb2f5068658f95ace0fae50`](https://github.com/opennextjs/opennextjs-aws/commit/6f798debb575b157acb2f5068658f95ace0fae50), [`fe600ac6f5e513376cf233a5d2ce68affaa3aa5a`](https://github.com/opennextjs/opennextjs-aws/commit/fe600ac6f5e513376cf233a5d2ce68affaa3aa5a), [`5f0cbc8feac9eec728c27bb3b7ff5c3f3bc26716`](https://github.com/opennextjs/opennextjs-aws/commit/5f0cbc8feac9eec728c27bb3b7ff5c3f3bc26716), [`8b51108d9aee7e5ed3027c1ceda99091b579951d`](https://github.com/opennextjs/opennextjs-aws/commit/8b51108d9aee7e5ed3027c1ceda99091b579951d), [`b999c4e9a38499680bed77ddeb94b62a3301c0fa`](https://github.com/opennextjs/opennextjs-aws/commit/b999c4e9a38499680bed77ddeb94b62a3301c0fa), [`ba84259d2e35e79a562a7e3f055e350a03c9d651`](https://github.com/opennextjs/opennextjs-aws/commit/ba84259d2e35e79a562a7e3f055e350a03c9d651)]:
36+
- @opennextjs/aws@3.2.2
37+
38+
## 0.1.1
39+
40+
### Patch Changes
41+
42+
- Updated dependencies [[`cf33973f3fbab73e77898fdd072a00a1f037257a`](https://github.com/opennextjs/opennextjs-aws/commit/cf33973f3fbab73e77898fdd072a00a1f037257a), [`77d87e7a870fad6afad022bf75aca18c8656c268`](https://github.com/opennextjs/opennextjs-aws/commit/77d87e7a870fad6afad022bf75aca18c8656c268), [`a43b82b4cb68889371ac8260aefef9e04eefb037`](https://github.com/opennextjs/opennextjs-aws/commit/a43b82b4cb68889371ac8260aefef9e04eefb037), [`bfa1a8c4056bd691fb57617dd6287693e51071b4`](https://github.com/opennextjs/opennextjs-aws/commit/bfa1a8c4056bd691fb57617dd6287693e51071b4), [`5839217411012d1df2874d299daa977ba3701c2c`](https://github.com/opennextjs/opennextjs-aws/commit/5839217411012d1df2874d299daa977ba3701c2c), [`dfc174d88b7bcc54eede09c98d9443dd84b93fd8`](https://github.com/opennextjs/opennextjs-aws/commit/dfc174d88b7bcc54eede09c98d9443dd84b93fd8)]:
43+
- @opennextjs/aws@3.2.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# App Pages Router
2+
3+
This project uses both the App and Pages router.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { getSong } from "@example/shared/api";
2+
import Modal from "@example/shared/components/Modal";
3+
4+
type Props = {
5+
params: Promise<{
6+
album: string;
7+
song: string;
8+
}>;
9+
};
10+
export default async function SongPage(props: Props) {
11+
const params = await props.params;
12+
const song = await getSong(params.album, params.song);
13+
return (
14+
<Modal>
15+
<h1>Modal</h1>
16+
Album: {decodeURIComponent(params.album)}
17+
<div className="absolute top-1/2 mt-10">
18+
{/* <video width={1000} height={1000} autoPlay src={`https://youtube.com/watch?v=${params.song}`} /> */}
19+
<iframe
20+
width="560"
21+
height="315"
22+
title={params.song}
23+
allowFullScreen
24+
src={`https://youtube.com/embed/${song?.videoId}?autoplay=1`}
25+
></iframe>
26+
</div>
27+
</Modal>
28+
);
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Modal from "@example/shared/components/Modal";
2+
3+
type Props = {
4+
params: Promise<{
5+
artist: string;
6+
}>;
7+
};
8+
export default async function ArtistPage(props: Props) {
9+
const params = await props.params;
10+
return <Modal>Artists {params.artist}</Modal>;
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Default() {
2+
return null;
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { getSong } from "@example/shared/api";
2+
3+
type Props = {
4+
params: Promise<{
5+
album: string;
6+
song: string;
7+
}>;
8+
};
9+
export default async function Song(props: Props) {
10+
const params = await props.params;
11+
const song = await getSong(params.album, params.song);
12+
13+
return (
14+
<div>
15+
<h1>Not Modal</h1>
16+
{decodeURIComponent(params.album)}
17+
<iframe
18+
width="560"
19+
height="315"
20+
allowFullScreen
21+
src={`https://youtube.com/embed/${song?.videoId}?autoplay=1`}
22+
></iframe>
23+
</div>
24+
);
25+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function ArtistPage() {
2+
return <div>Artist</div>;
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { ReactNode } from "react";
2+
3+
export default function Layout({ children, modal }: { children: ReactNode; modal: ReactNode }) {
4+
return (
5+
<div>
6+
{children}
7+
{modal}
8+
</div>
9+
);
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getAlbums } from "@example/shared/api";
2+
import Album from "@example/shared/components/Album";
3+
4+
export default async function AlbumPage() {
5+
const albums = await getAlbums();
6+
return (
7+
<div>
8+
{albums.map((album) => (
9+
<Album album={album} />
10+
))}
11+
</div>
12+
);
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { NextResponse } from "next/server";
2+
3+
export async function GET(request: Request) {
4+
return NextResponse.json({
5+
hello: "client",
6+
});
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { NextResponse } from "next/server";
2+
3+
export async function GET(request: Request) {
4+
return NextResponse.json({
5+
url: request.url,
6+
});
7+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"use client";
2+
3+
import { useCallback, useState } from "react";
4+
5+
/**
6+
* Make /api/hello call exclusively on the client
7+
* - we already know SSR can fetch itself w/o issues
8+
*/
9+
export default function Page() {
10+
const [data, setData] = useState();
11+
12+
const onClientClick = useCallback(async () => {
13+
const { protocol, host } = window.location;
14+
const url = `${protocol}//${host}`;
15+
const r = await fetch(`${url}/api/client`);
16+
const d = await r.json();
17+
setData(d);
18+
}, []);
19+
20+
const onMiddlewareClick = useCallback(async () => {
21+
const { protocol, host } = window.location;
22+
const url = `${protocol}//${host}`;
23+
const r = await fetch(`${url}/api/middleware`);
24+
const d = await r.json();
25+
setData(d);
26+
}, []);
27+
28+
return (
29+
<div>
30+
<div>API: {data ? JSON.stringify(data, null, 2) : "N/A"}</div>
31+
32+
<button className="border p-2" onClick={onClientClick}>
33+
Call /api/client
34+
</button>
35+
<button className="border p-2" onClick={onMiddlewareClick}>
36+
Call /api/middleware
37+
</button>
38+
</div>
39+
);
40+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
:root {
6+
--foreground-rgb: 0, 0, 0;
7+
--background-start-rgb: 214, 219, 220;
8+
--background-end-rgb: 255, 255, 255;
9+
}
10+
11+
@media (prefers-color-scheme: dark) {
12+
:root {
13+
--foreground-rgb: 255, 255, 255;
14+
--background-start-rgb: 0, 0, 0;
15+
--background-end-rgb: 0, 0, 0;
16+
}
17+
}
18+
19+
body {
20+
color: rgb(var(--foreground-rgb));
21+
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
22+
rgb(var(--background-start-rgb));
23+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Image from "next/image";
2+
3+
export default function ImageOptimization() {
4+
return (
5+
<div>
6+
<Image src="/static/corporate_holiday_card.jpg" alt="Corporate Holiday Card" width={300} height={300} />
7+
</div>
8+
);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
async function getTime() {
2+
return new Date().toISOString();
3+
}
4+
5+
export const revalidate = 10;
6+
export default async function ISR() {
7+
const time = getTime();
8+
return <div>Time: {time}</div>;
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import "./globals.css";
2+
3+
import type { Metadata } from "next";
4+
import { Inter } from "next/font/google";
5+
6+
const inter = Inter({ subsets: ["latin"] });
7+
8+
export const metadata: Metadata = {
9+
title: "Nextjs App Router",
10+
description: "Generated by create next app",
11+
};
12+
13+
export default function RootLayout({ children }: { children: React.ReactNode }) {
14+
return (
15+
<html lang="en">
16+
<body className={inter.className}>
17+
<header>Header</header>
18+
{children}
19+
</body>
20+
</html>
21+
);
22+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Nav from "@example/shared/components/Nav";
2+
3+
export default function Home() {
4+
return (
5+
<>
6+
<h1>App Router</h1>
7+
<main className="grid grid-cols-2 gap-4 p-10 [&>a]:border">
8+
<Nav href={"/albums"} title="Albums">
9+
Modal and interception of the greatest hits
10+
</Nav>
11+
<Nav href={"/rewrite"} title="Rewrite">
12+
Middleware Rewrite of a page. /rewrite should rewrite the contents of /rewrite-destination
13+
</Nav>
14+
<Nav href={"/redirect"} title="Redirect">
15+
Middleware Rewrite of a page. /redirect should redirect page to /redirect-destination
16+
</Nav>
17+
<Nav href={"/server-actions"} title="Server Actions">
18+
Client component imports a 'use server' server action and calls it directly without setting up any
19+
api endpoints
20+
</Nav>
21+
<Nav href={"/isr"} title="ISR">
22+
Incremental Static Regeneration revalidates every 10 seconds with a new timestamp
23+
</Nav>
24+
<Nav href={"/ssr"} title="SSR">
25+
Server Side Render should generate a new timestamp on each load
26+
</Nav>
27+
<Nav href={"/api"} title="API">
28+
Calls an API endpoint defined in app/api/hello/route and middleware
29+
</Nav>
30+
<Nav href={"/parallel"} title="Parallel">
31+
Parallel routing
32+
</Nav>
33+
<Nav href={"/image-optimization"} title="Image Optimization">
34+
Image Optimization with next/image
35+
</Nav>
36+
</main>
37+
<h1>Pages Router</h1>
38+
<main className="grid grid-cols-2 gap-4 p-10 [&>a]:border">
39+
<Nav href="/pages_isr" title="/Pages_ISR" icon="/static/frank.webp">
40+
revalidates every 10 seconds
41+
</Nav>
42+
<Nav href="/pages_ssr" title="/Pages_SSR" icon="/static/frank.webp">
43+
SSR on each load
44+
</Nav>
45+
</main>
46+
</>
47+
);
48+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function APage() {
2+
return <div>A Page</div>;
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Link from "next/link";
2+
3+
export default function A() {
4+
return (
5+
<div className="border p-4">
6+
<h1>Parallel Route A</h1>
7+
<Link href="/parallel/a-page">Go to a-page</Link>
8+
</div>
9+
);
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function BPage() {
2+
return <div>B Page</div>;
3+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Link from "next/link";
2+
3+
export default function B() {
4+
return (
5+
<div className="border p-4">
6+
<h1>Parallel Route B</h1>
7+
8+
<Link href="/parallel/b-page">Go to b-page</Link>
9+
</div>
10+
);
11+
}

0 commit comments

Comments
 (0)