Skip to content

Commit

Permalink
docs: Add basic example for app router with Docker (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
JorWo authored Nov 2, 2024
1 parent 8262b5d commit 20c690b
Show file tree
Hide file tree
Showing 31 changed files with 5,814 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
/node_modules
/coverage

.env
.DS_Store
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/.github
/src
/test
/examples
/__mocks__
/node_modules
/coverage

.env*
.DS_Store
CODEOWNERS
CONTRIBUTING.md

eslint.config.mjs
.prettierrc
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,17 @@ const isLoggedIn = await isLoggedIn();

## Examples

For the full demo, Docker is required.
A fully functional demo is available using Docker.

- [App Router](https://github.com/uhawaii-system-its-ti-iam/next-cas-client/blob/main/examples/app-router)
- [Page Router](https://github.com/uhawaii-system-its-ti-iam/next-cas-client/blob/main/examples/page-router)
To start:

1. Clone or download this repo
2. Change directory to `/examples`
3. Execute `docker compose up`. A CAS server for demo purposes will launch at https://localhost:8443/cas
4. Change directory to `/app-router` or `/pages-router` depending on the router you would like to view the example for
5. Execute `npm run dev`. The Next.js example app will be available at http://localhost:3000

**Note:** You may encounter a `NET:ERR_CERT_INVALID` error in your browser when attempting to visit the CAS login page. Bypass the error by trusting the page. The browser is attempting to protect you from visiting a suspicious secure site at https://localhost.

## Contributing

Expand Down
3 changes: 3 additions & 0 deletions examples/app-router/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cache
build
node_modules
10 changes: 10 additions & 0 deletions examples/app-router/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_CAS_URL=https://localhost:8443/cas

# FOR DEMO PURPOSES ONLY
# PLEASE GENERATE YOUR OWN 32 CHARACTER LONG PASSWORD
NEXT_CAS_CLIENT_SECRET=GenerateA32CharacterLongPassword

# FOR DEMO PURPOSES ONLY
# DISABLES CERTIFICATE VERIFICATION TO ALLOW COMMUNICATION WITH https://localhost:8443/cas
NODE_TLS_REJECT_UNAUTHORIZED=0
3 changes: 3 additions & 0 deletions examples/app-router/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
36 changes: 36 additions & 0 deletions examples/app-router/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.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
36 changes: 36 additions & 0 deletions examples/app-router/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.
20 changes: 20 additions & 0 deletions examples/app-router/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": false,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
4 changes: 4 additions & 0 deletions examples/app-router/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
Loading

0 comments on commit 20c690b

Please sign in to comment.