Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions apps/next-app-router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dont get excited, it doesnt work.
3 changes: 3 additions & 0 deletions apps/next-app-router/next-app-router-4000/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
37 changes: 37 additions & 0 deletions apps/next-app-router/next-app-router-4000/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
/.yarn

# 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*

# local env files
.env*
!.env*.example

# vercel
.vercel

# typescript
*.tsbuildinfo
1 change: 1 addition & 0 deletions apps/next-app-router/next-app-router-4000/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
2 changes: 2 additions & 0 deletions apps/next-app-router/next-app-router-4000/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
pnpm-lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type Category = {
name: string;
slug: string;
count: number;
parent: string | null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { notFound } from 'next/navigation';
import type { Category } from './category';

// `server-only` guarantees any modules that import code in file
// will never run on the client. Even though this particular API
// doesn't currently use sensitive environment variables, it's
// good practice to add `server-only` preemptively.
import 'server-only';

export async function getCategories({ parent }: { parent?: string } = {}) {
const res = await fetch(
`https://app-playground-api.vercel.app/api/categories${
parent ? `?parent=${parent}` : ''
}`,
);

if (!res.ok) {
// Render the closest `error.js` Error Boundary
throw new Error('Something went wrong!');
}

const categories = (await res.json()) as Category[];

if (categories.length === 0) {
// Render the closest `not-found.js` Error Boundary
notFound();
}

return categories;
}

export async function getCategory({ slug }: { slug: string }) {
const res = await fetch(
`https://app-playground-api.vercel.app/api/categories${
slug ? `?slug=${slug}` : ''
}`,
);

if (!res.ok) {
// Render the closest `error.js` Error Boundary
throw new Error('Something went wrong!');
}

const category = (await res.json()) as Category;

if (!category) {
// Render the closest `not-found.js` Error Boundary
notFound();
}

return category;
}
Binary file not shown.
Loading