Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions examples/common/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const apps = [
"playground15",
"vercel-blog-starter",
"ssg-app",
"prisma",
// e2e
"app-pages-router",
"app-router",
Expand Down
47 changes: 47 additions & 0 deletions examples/prisma/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

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

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

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

# playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
36 changes: 36 additions & 0 deletions examples/prisma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
3 changes: 3 additions & 0 deletions examples/prisma/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { configurePlaywright } from "../../common/config-e2e";

export default configurePlaywright("prisma");
21 changes: 21 additions & 0 deletions examples/prisma/e2e/prisma.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test, expect } from "@playwright/test";

test.describe("playground/cloudflare", () => {
test("Prisma doesn't crash", async ({ page }) => {
await page.goto("/");
const aliceName = await page.getByTestId("name-1").innerText();
expect(aliceName).toBe("Alice");
const aliceEmail = await page.getByTestId("email-1").innerText();
expect(aliceEmail).toBe("[email protected]");

const bobName = await page.getByTestId("name-2").innerText();
expect(bobName).toBe("Bob");
const bobEmail = await page.getByTestId("email-2").innerText();
expect(bobEmail).toBe("[email protected]");

const carolName = await page.getByTestId("name-3").innerText();
expect(carolName).toBe("Carol");
const carolEmail = await page.getByTestId("email-3").innerText();
expect(carolEmail).toBe("[email protected]");
});
});
8 changes: 8 additions & 0 deletions examples/prisma/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
serverExternalPackages: ["@prisma/client", ".prisma/client"],
};

export default nextConfig;
3 changes: 3 additions & 0 deletions examples/prisma/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineCloudflareConfig } from "@opennextjs/cloudflare";

export default defineCloudflareConfig({});
34 changes: 34 additions & 0 deletions examples/prisma/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "prisma",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint",
"prepare:db": "npx prisma generate && wrangler d1 ",
"build:worker": "npx prisma generate && pnpm opennextjs-cloudflare build",
"preview:worker": "pnpm opennextjs-cloudflare preview",
"preview": "pnpm build:worker && pnpm preview:worker",
"e2e": "playwright test -c e2e/playwright.config.ts",
"e2e:dev": "playwright test -c e2e/playwright.dev.config.ts",
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
},
"dependencies": {
"@opennextjs/cloudflare": "workspace:*",
"@prisma/adapter-d1": "^6.7.0",
"@prisma/client": "^6.7.0",
"next": "catalog:e2e",
"react": "catalog:e2e",
"react-dom": "catalog:e2e"
},
"devDependencies": {
"@types/node": "catalog:",
"@types/react": "catalog:e2e",
"@types/react-dom": "catalog:e2e",
"prisma": "^6.7.0",
"typescript": "catalog:",
"wrangler": "catalog:"
}
}
11 changes: 11 additions & 0 deletions examples/prisma/populate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT NOT NULL,
UNIQUE (email) ON CONFLICT REPLACE
);

INSERT INTO users (name, email) VALUES
('Alice', '[email protected]'),
('Bob', '[email protected]'),
('Carol', '[email protected]');
6 changes: 6 additions & 0 deletions examples/prisma/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { PrismaConfig } from "prisma";

export default {
earlyAccess: true,
schema: "./schema.prisma",
} satisfies PrismaConfig;
15 changes: 15 additions & 0 deletions examples/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "sqlite"
url = env("NOT_USED")
}

model users {
id Int @id @default(autoincrement())
email String @unique
name String?
}
Binary file added examples/prisma/src/app/favicon.ico
Binary file not shown.
42 changes: 42 additions & 0 deletions examples/prisma/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:root {
--background: #ffffff;
--foreground: #171717;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

html,
body {
max-width: 100vw;
overflow-x: hidden;
}

body {
color: var(--foreground);
background: var(--background);
font-family: Arial, Helvetica, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

* {
box-sizing: border-box;
padding: 0;
margin: 0;
}

a {
color: inherit;
text-decoration: none;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}
30 changes: 30 additions & 0 deletions examples/prisma/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

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

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={`${geistSans.variable} ${geistMono.variable}`}>{children}</body>
</html>
);
}
Loading
Loading