Skip to content

Commit

Permalink
Migrate to App Router (#600)
Browse files Browse the repository at this point in the history
* * 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]>
  • Loading branch information
5 people authored Oct 29, 2024
1 parent 4b4d2c4 commit 6353b7c
Show file tree
Hide file tree
Showing 41 changed files with 4,229 additions and 4,365 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ next/node_modules
express/node_modules
/.pnp
.pnp.js
.vercel

# testing
/coverage
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ services:
ports: [9989:9989]
volumes: [./mini-relay/data:/data:rw]
postgres:
image: 'postgres:alpine'
image: "postgres:alpine"
environment:
- POSTGRES_PASSWORD=postgres
init: true
ports: [5432:5432]
volumes:
- ./postgres/data/empowerplant.sql:/docker-entrypoint-initdb.d/empowerplant.sql:ro
1 change: 1 addition & 0 deletions next/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
25 changes: 0 additions & 25 deletions next/config-overrides.js

This file was deleted.

13 changes: 13 additions & 0 deletions next/global-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use client' // Error boundaries must be Client Components

export default function GlobalError({ error, reset }) {
return (
// global-error must include html and body tags
<html>
<body>
<h2>Something went wrong!</h2>
<button onClick={() => reset()}>Try again</button>
</body>
</html>
)
}
66 changes: 66 additions & 0 deletions next/lib/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { sql } from "@vercel/postgres";

import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

// export type Product = {
// id: number;
// description: string;
// descriptionfull: string;
// price: number;
// img: string;
// imgcropped: string;
// reviews: Review[] | [];
// }

// export type Review = {
// id: number;
// productid: number;
// rating: number;
// customerid: string;
// description: string;
// created: string;
// }


export default async function getProducts() {
try {
console.log("Fetching products...");
// Artificial slowdown for demoing
await new Promise((resolve) => setTimeout(resolve, 2000));

const products = await prisma.products.findMany();
// const products = data.rows;

for (let i = 0; i < products.length; ++i) {

const product_reviews = await prisma.reviews.findMany({
where: { id: i },
});

products[i].reviews = product_reviews;
}
console.log("products: ", products);
return products;
} catch (error) {
console.error("Database Error:", error)
// do sentry stuff
}


async function getReview(i) {
try {
const data = await sql`SELECT * from reviews WHERE productId=${i}`;
console.log(data.rows);
return data.rows;
} catch (error) {
console.error("Db error", error);
}
}
}

export async function getProductsPrisma() {
const products = await prisma.products.findMany();
console.log("prisma", products);
}
8 changes: 7 additions & 1 deletion next/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { withSentryConfig } from '@sentry/nextjs';

/** @type {import('next').NextConfig} */
const nextConfig = {
distDir: './dist', // Changes the build output directory to `./dist/`.
// This should be removed during a refactor, following these directions:
// https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
experimental: {
missingSuspenseWithCSRBailout: false,
},
};

export default withSentryConfig(nextConfig, {
Expand Down Expand Up @@ -35,7 +41,7 @@ export default withSentryConfig(nextConfig, {
hideSourceMaps: true,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
disableLogger: false,

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

0 comments on commit 6353b7c

Please sign in to comment.