Skip to content

Commit

Permalink
test: import app-pages-router from aws (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored Jan 29, 2025
1 parent 60e7582 commit 94e992f
Show file tree
Hide file tree
Showing 63 changed files with 1,241 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/e2e/app-pages-router/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SOME_ENV_VAR=foo
42 changes: 42 additions & 0 deletions examples/e2e/app-pages-router/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
.open-next
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
43 changes: 43 additions & 0 deletions examples/e2e/app-pages-router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# app-pages-router

## 0.1.6

### Patch Changes

- 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)]:
- @opennextjs/aws@3.4.1

## 0.1.5

### Patch Changes

- 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)]:
- @opennextjs/aws@3.4.0

## 0.1.4

### Patch Changes

- 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)]:
- @opennextjs/aws@3.3.1

## 0.1.3

### Patch Changes

- 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)]:
- @opennextjs/aws@3.3.0

## 0.1.2

### Patch Changes

- 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)]:
- @opennextjs/aws@3.2.2

## 0.1.1

### Patch Changes

- 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)]:
- @opennextjs/aws@3.2.1
3 changes: 3 additions & 0 deletions examples/e2e/app-pages-router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# App Pages Router

This project uses both the App and Pages router.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { getSong } from "@example/shared/api";
import Modal from "@example/shared/components/Modal";

type Props = {
params: Promise<{
album: string;
song: string;
}>;
};
export default async function SongPage(props: Props) {
const params = await props.params;
const song = await getSong(params.album, params.song);
return (
<Modal>
<h1>Modal</h1>
Album: {decodeURIComponent(params.album)}
<div className="absolute top-1/2 mt-10">
{/* <video width={1000} height={1000} autoPlay src={`https://youtube.com/watch?v=${params.song}`} /> */}
<iframe
width="560"
height="315"
title={params.song}
allowFullScreen
src={`https://youtube.com/embed/${song?.videoId}?autoplay=1`}
></iframe>
</div>
</Modal>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Modal from "@example/shared/components/Modal";

type Props = {
params: Promise<{
artist: string;
}>;
};
export default async function ArtistPage(props: Props) {
const params = await props.params;
return <Modal>Artists {params.artist}</Modal>;
}
3 changes: 3 additions & 0 deletions examples/e2e/app-pages-router/app/albums/@modal/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Default() {
return null;
}
25 changes: 25 additions & 0 deletions examples/e2e/app-pages-router/app/albums/[album]/[song]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { getSong } from "@example/shared/api";

type Props = {
params: Promise<{
album: string;
song: string;
}>;
};
export default async function Song(props: Props) {
const params = await props.params;
const song = await getSong(params.album, params.song);

return (
<div>
<h1>Not Modal</h1>
{decodeURIComponent(params.album)}
<iframe
width="560"
height="315"
allowFullScreen
src={`https://youtube.com/embed/${song?.videoId}?autoplay=1`}
></iframe>
</div>
);
}
3 changes: 3 additions & 0 deletions examples/e2e/app-pages-router/app/albums/[album]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function ArtistPage() {
return <div>Artist</div>;
}
10 changes: 10 additions & 0 deletions examples/e2e/app-pages-router/app/albums/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ReactNode } from "react";

export default function Layout({ children, modal }: { children: ReactNode; modal: ReactNode }) {
return (
<div>
{children}
{modal}
</div>
);
}
13 changes: 13 additions & 0 deletions examples/e2e/app-pages-router/app/albums/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getAlbums } from "@example/shared/api";
import Album from "@example/shared/components/Album";

export default async function AlbumPage() {
const albums = await getAlbums();
return (
<div>
{albums.map((album) => (
<Album album={album} />
))}
</div>
);
}
7 changes: 7 additions & 0 deletions examples/e2e/app-pages-router/app/api/client/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { NextResponse } from "next/server";

export async function GET(request: Request) {
return NextResponse.json({
hello: "client",
});
}
7 changes: 7 additions & 0 deletions examples/e2e/app-pages-router/app/api/host/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { NextResponse } from "next/server";

export async function GET(request: Request) {
return NextResponse.json({
url: request.url,
});
}
40 changes: 40 additions & 0 deletions examples/e2e/app-pages-router/app/api/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use client";

import { useCallback, useState } from "react";

/**
* Make /api/hello call exclusively on the client
* - we already know SSR can fetch itself w/o issues
*/
export default function Page() {
const [data, setData] = useState();

const onClientClick = useCallback(async () => {
const { protocol, host } = window.location;
const url = `${protocol}//${host}`;
const r = await fetch(`${url}/api/client`);
const d = await r.json();
setData(d);
}, []);

const onMiddlewareClick = useCallback(async () => {
const { protocol, host } = window.location;
const url = `${protocol}//${host}`;
const r = await fetch(`${url}/api/middleware`);
const d = await r.json();
setData(d);
}, []);

return (
<div>
<div>API: {data ? JSON.stringify(data, null, 2) : "N/A"}</div>

<button className="border p-2" onClick={onClientClick}>
Call /api/client
</button>
<button className="border p-2" onClick={onMiddlewareClick}>
Call /api/middleware
</button>
</div>
);
}
23 changes: 23 additions & 0 deletions examples/e2e/app-pages-router/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
rgb(var(--background-start-rgb));
}
9 changes: 9 additions & 0 deletions examples/e2e/app-pages-router/app/image-optimization/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Image from "next/image";

export default function ImageOptimization() {
return (
<div>
<Image src="/static/corporate_holiday_card.jpg" alt="Corporate Holiday Card" width={300} height={300} />
</div>
);
}
9 changes: 9 additions & 0 deletions examples/e2e/app-pages-router/app/isr/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
async function getTime() {
return new Date().toISOString();
}

export const revalidate = 10;
export default async function ISR() {
const time = getTime();
return <div>Time: {time}</div>;
}
22 changes: 22 additions & 0 deletions examples/e2e/app-pages-router/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "./globals.css";

import type { Metadata } from "next";
import { Inter } from "next/font/google";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Nextjs App Router",
description: "Generated by create next app",
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className={inter.className}>
<header>Header</header>
{children}
</body>
</html>
);
}
48 changes: 48 additions & 0 deletions examples/e2e/app-pages-router/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import Nav from "@example/shared/components/Nav";

export default function Home() {
return (
<>
<h1>App Router</h1>
<main className="grid grid-cols-2 gap-4 p-10 [&>a]:border">
<Nav href={"/albums"} title="Albums">
Modal and interception of the greatest hits
</Nav>
<Nav href={"/rewrite"} title="Rewrite">
Middleware Rewrite of a page. /rewrite should rewrite the contents of /rewrite-destination
</Nav>
<Nav href={"/redirect"} title="Redirect">
Middleware Rewrite of a page. /redirect should redirect page to /redirect-destination
</Nav>
<Nav href={"/server-actions"} title="Server Actions">
Client component imports a 'use server' server action and calls it directly without setting up any
api endpoints
</Nav>
<Nav href={"/isr"} title="ISR">
Incremental Static Regeneration revalidates every 10 seconds with a new timestamp
</Nav>
<Nav href={"/ssr"} title="SSR">
Server Side Render should generate a new timestamp on each load
</Nav>
<Nav href={"/api"} title="API">
Calls an API endpoint defined in app/api/hello/route and middleware
</Nav>
<Nav href={"/parallel"} title="Parallel">
Parallel routing
</Nav>
<Nav href={"/image-optimization"} title="Image Optimization">
Image Optimization with next/image
</Nav>
</main>
<h1>Pages Router</h1>
<main className="grid grid-cols-2 gap-4 p-10 [&>a]:border">
<Nav href="/pages_isr" title="/Pages_ISR" icon="/static/frank.webp">
revalidates every 10 seconds
</Nav>
<Nav href="/pages_ssr" title="/Pages_SSR" icon="/static/frank.webp">
SSR on each load
</Nav>
</main>
</>
);
}
3 changes: 3 additions & 0 deletions examples/e2e/app-pages-router/app/parallel/@a/a-page/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function APage() {
return <div>A Page</div>;
}
10 changes: 10 additions & 0 deletions examples/e2e/app-pages-router/app/parallel/@a/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Link from "next/link";

export default function A() {
return (
<div className="border p-4">
<h1>Parallel Route A</h1>
<Link href="/parallel/a-page">Go to a-page</Link>
</div>
);
}
3 changes: 3 additions & 0 deletions examples/e2e/app-pages-router/app/parallel/@b/b-page/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function BPage() {
return <div>B Page</div>;
}
11 changes: 11 additions & 0 deletions examples/e2e/app-pages-router/app/parallel/@b/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Link from "next/link";

export default function B() {
return (
<div className="border p-4">
<h1>Parallel Route B</h1>

<Link href="/parallel/b-page">Go to b-page</Link>
</div>
);
}
Loading

0 comments on commit 94e992f

Please sign in to comment.