Skip to content

Commit 6353b7c

Browse files
lukemunLuke MunroAidan LandenlforstAidan Landen
authored
Migrate to App Router (#600)
* * Create app router directory structure * Added pages and root layout * Temp made all components client as 1st migration step * Renamed conflicting pages from pages router to *2 Ran locally and checked all pages load. migrate all linked pages to app router * Create a SC route for products (#602) * Uploaded hardware db to vercel postgres * Created producs-sc page with SC Co-authored-by: Luke Munro <[email protected]> * added vercel tracing target * added vercel tracing target * updated sentry import to nextjs * removed withProfiler from about page * Reconfigure layout (#606) * Migrate layout to server * fix a bunch of crap (#607) * upgrade to next 15 * commented out session storage * commented out crasher * Moved some files and implemented naming conventions * moved some css around to fix styling * more refactor * accidently removed dynamic export * trying to disable vercel cache --------- Co-authored-by: Luke Munro <[email protected]> Co-authored-by: Luca Forstner <[email protected]> Co-authored-by: Aidan Landen <[email protected]> --------- Co-authored-by: Luke Munro <[email protected]> Co-authored-by: Aidan Landen <[email protected]> Co-authored-by: Luca Forstner <[email protected]> Co-authored-by: Aidan Landen <[email protected]>
1 parent 4b4d2c4 commit 6353b7c

Some content is hidden

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

41 files changed

+4229
-4365
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ next/node_modules
88
express/node_modules
99
/.pnp
1010
.pnp.js
11+
.vercel
1112

1213
# testing
1314
/coverage

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ services:
3131
ports: [9989:9989]
3232
volumes: [./mini-relay/data:/data:rw]
3333
postgres:
34-
image: 'postgres:alpine'
34+
image: "postgres:alpine"
3535
environment:
3636
- POSTGRES_PASSWORD=postgres
3737
init: true
38+
ports: [5432:5432]
3839
volumes:
3940
- ./postgres/data/empowerplant.sql:/docker-entrypoint-initdb.d/empowerplant.sql:ro

next/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vercel

next/config-overrides.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

next/global-error.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client' // Error boundaries must be Client Components
2+
3+
export default function GlobalError({ error, reset }) {
4+
return (
5+
// global-error must include html and body tags
6+
<html>
7+
<body>
8+
<h2>Something went wrong!</h2>
9+
<button onClick={() => reset()}>Try again</button>
10+
</body>
11+
</html>
12+
)
13+
}

next/lib/data.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { sql } from "@vercel/postgres";
2+
3+
import { PrismaClient } from '@prisma/client';
4+
5+
const prisma = new PrismaClient();
6+
7+
// export type Product = {
8+
// id: number;
9+
// description: string;
10+
// descriptionfull: string;
11+
// price: number;
12+
// img: string;
13+
// imgcropped: string;
14+
// reviews: Review[] | [];
15+
// }
16+
17+
// export type Review = {
18+
// id: number;
19+
// productid: number;
20+
// rating: number;
21+
// customerid: string;
22+
// description: string;
23+
// created: string;
24+
// }
25+
26+
27+
export default async function getProducts() {
28+
try {
29+
console.log("Fetching products...");
30+
// Artificial slowdown for demoing
31+
await new Promise((resolve) => setTimeout(resolve, 2000));
32+
33+
const products = await prisma.products.findMany();
34+
// const products = data.rows;
35+
36+
for (let i = 0; i < products.length; ++i) {
37+
38+
const product_reviews = await prisma.reviews.findMany({
39+
where: { id: i },
40+
});
41+
42+
products[i].reviews = product_reviews;
43+
}
44+
console.log("products: ", products);
45+
return products;
46+
} catch (error) {
47+
console.error("Database Error:", error)
48+
// do sentry stuff
49+
}
50+
51+
52+
async function getReview(i) {
53+
try {
54+
const data = await sql`SELECT * from reviews WHERE productId=${i}`;
55+
console.log(data.rows);
56+
return data.rows;
57+
} catch (error) {
58+
console.error("Db error", error);
59+
}
60+
}
61+
}
62+
63+
export async function getProductsPrisma() {
64+
const products = await prisma.products.findMany();
65+
console.log("prisma", products);
66+
}

next/next.config.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { withSentryConfig } from '@sentry/nextjs';
2+
23
/** @type {import('next').NextConfig} */
34
const nextConfig = {
45
distDir: './dist', // Changes the build output directory to `./dist/`.
6+
// This should be removed during a refactor, following these directions:
7+
// https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
8+
experimental: {
9+
missingSuspenseWithCSRBailout: false,
10+
},
511
};
612

713
export default withSentryConfig(nextConfig, {
@@ -35,7 +41,7 @@ export default withSentryConfig(nextConfig, {
3541
hideSourceMaps: true,
3642

3743
// Automatically tree-shake Sentry logger statements to reduce bundle size
38-
disableLogger: true,
44+
disableLogger: false,
3945

4046
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
4147
// See the following for more information:

0 commit comments

Comments
 (0)