Skip to content

Commit c2668af

Browse files
committed
feat: foundational commit with poc integrated
1 parent c2de256 commit c2668af

Some content is hidden

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

43 files changed

+22243
-0
lines changed

.gitignore

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
### Node ###
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
11+
# Diagnostic reports (https://nodejs.org/api/report.html)
12+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13+
14+
# Runtime data
15+
pids
16+
*.pid
17+
*.seed
18+
*.pid.lock
19+
20+
# Directory for instrumented libs generated by jscoverage/JSCover
21+
lib-cov
22+
23+
# Coverage directory used by tools like istanbul
24+
coverage
25+
*.lcov
26+
27+
# nyc test coverage
28+
.nyc_output
29+
30+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
31+
.grunt
32+
33+
# Bower dependency directory (https://bower.io/)
34+
bower_components
35+
36+
# node-waf configuration
37+
.lock-wscript
38+
39+
# Compiled binary addons (https://nodejs.org/api/addons.html)
40+
build/Release
41+
42+
# Dependency directories
43+
node_modules/
44+
jspm_packages/
45+
46+
# TypeScript v1 declaration files
47+
typings/
48+
49+
# TypeScript cache
50+
*.tsbuildinfo
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Microbundle cache
59+
.rpt2_cache/
60+
.rts2_cache_cjs/
61+
.rts2_cache_es/
62+
.rts2_cache_umd/
63+
64+
# Optional REPL history
65+
.node_repl_history
66+
67+
# Output of 'npm pack'
68+
*.tgz
69+
70+
# Yarn Integrity file
71+
.yarn-integrity
72+
73+
# dotenv environment variables file
74+
.env
75+
.env.test
76+
.env*.local
77+
78+
# parcel-bundler cache (https://parceljs.org/)
79+
.cache
80+
.parcel-cache
81+
82+
# Next.js build output
83+
.next
84+
85+
# Nuxt.js build / generate output
86+
.nuxt
87+
dist
88+
89+
# Gatsby files
90+
.cache/
91+
# Comment in the public line in if your project uses Gatsby and not Next.js
92+
# https://nextjs.org/blog/next-9-1#public-directory-support
93+
# public
94+
95+
# vuepress build output
96+
.vuepress/dist
97+
98+
# Serverless directories
99+
.serverless/
100+
101+
# FuseBox cache
102+
.fusebox/
103+
104+
# DynamoDB Local files
105+
.dynamodb/
106+
107+
# TernJS port file
108+
.tern-port
109+
110+
# Stores VSCode versions used for testing VSCode extensions
111+
.vscode-test
112+
113+
### OSX ###
114+
# General
115+
.DS_Store
116+
.AppleDouble
117+
.LSOverride
118+
119+
# Icon must end with two \r
120+
Icon
121+
122+
123+
# Thumbnails
124+
._*
125+
126+
# Files that might appear in the root of a volume
127+
.DocumentRevisions-V100
128+
.fseventsd
129+
.Spotlight-V100
130+
.TemporaryItems
131+
.Trashes
132+
.VolumeIcon.icns
133+
.com.apple.timemachine.donotpresent
134+
135+
# Directories potentially created on remote AFP share
136+
.AppleDB
137+
.AppleDesktop
138+
Network Trash Folder
139+
Temporary Items
140+
.apdisk
141+
142+
# End of https://www.toptal.com/developers/gitignore/api/osx,node
143+
144+
# CLI
145+
.netlify
146+
demo/.next

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

demo/.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "next",
3+
"root": true
4+
}

demo/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
35+
36+
netlify/functions
37+
.netlify/functions
38+
.netlify/cache

demo/components/Header.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Header() {
2+
return <h1>header</h1>
3+
}

demo/pages/_app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '../styles/globals.css'
2+
3+
function MyApp({ Component, pageProps }) {
4+
return <Component {...pageProps} />
5+
}
6+
7+
export default MyApp

demo/pages/api/hello-background.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default (req, res) => {
2+
res.setHeader('Content-Type', 'application/json')
3+
res.status(200)
4+
res.json({ message: 'hello world :)' })
5+
}

demo/pages/api/hello.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2+
3+
export default (req, res) => {
4+
res.status(200).json({ name: 'John Doe' })
5+
}

demo/pages/api/shows/[...params].js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export default async (req, res) => {
2+
// Respond with JSON
3+
res.setHeader('Content-Type', 'application/json')
4+
5+
// Get the params and query string parameters
6+
const { query } = req
7+
const { params, ...queryStringParams } = query
8+
9+
// Get the ID of the show
10+
const id = params[0]
11+
12+
// Get the data
13+
const fetchRes = await fetch(`https://api.tvmaze.com/shows/${id}`)
14+
const data = await fetchRes.json()
15+
16+
// If show was found, return it
17+
if (fetchRes.status == 200) {
18+
res.status(200)
19+
res.json({ params, queryStringParams, show: data })
20+
}
21+
// If show was not found, return error
22+
else {
23+
res.status(404)
24+
res.json({ error: 'Show not found' })
25+
}
26+
}

demo/pages/api/shows/[id].js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default async (req, res) => {
2+
// Respond with JSON
3+
res.setHeader('Content-Type', 'application/json')
4+
5+
// Get the ID of the show
6+
const { query } = req
7+
const { id } = query
8+
9+
// Get the data
10+
const fetchRes = await fetch(`https://api.tvmaze.com/shows/${id}`)
11+
const data = await fetchRes.json()
12+
13+
// If show was found, return it
14+
if (fetchRes.status == 200) {
15+
res.status(200)
16+
res.json({ show: data })
17+
}
18+
// If show was not found, return error
19+
else {
20+
res.status(404)
21+
res.json({ error: 'Show not found' })
22+
}
23+
}

demo/pages/deep/import.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Link from 'next/link'
2+
import dynamic from 'next/dynamic'
3+
const Header = dynamic(() => import(/* webpackChunkName: 'header' */ '../../components/Header'), { ssr: true })
4+
5+
const Show = ({ show }) => (
6+
<div>
7+
<Header />
8+
<p>
9+
This page uses getInitialProps() to fetch the show with the ID provided in the URL: /shows/:id
10+
<br />
11+
Refresh the page to see server-side rendering in action.
12+
<br />
13+
You can also try changing the ID to any other number between 1-10000.
14+
</p>
15+
16+
<hr />
17+
18+
<h1>Show #{show.id}</h1>
19+
<p>{show.name}</p>
20+
21+
<hr />
22+
23+
<Link href="/">
24+
<a>Go back home</a>
25+
</Link>
26+
</div>
27+
)
28+
29+
export const getServerSideProps = async ({ params }) => {
30+
const res = await fetch('https://api.tvmaze.com/shows/42')
31+
const data = await res.json()
32+
33+
return {
34+
props: {
35+
show: data,
36+
},
37+
}
38+
}
39+
40+
export default Show

demo/pages/getServerSideProps/[id].js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Error from 'next/error'
2+
import Link from 'next/link'
3+
4+
const Show = ({ errorCode, show }) => {
5+
// If show item was not found, render 404 page
6+
if (errorCode) {
7+
return <Error statusCode={errorCode} />
8+
}
9+
10+
// Otherwise, render show
11+
return (
12+
<div>
13+
<p>
14+
This page uses getInitialProps() to fetch the show with the ID provided in the URL: /shows/:id
15+
<br />
16+
Refresh the page to see server-side rendering in action.
17+
<br />
18+
You can also try changing the ID to any other number between 1-10000.
19+
</p>
20+
21+
<hr />
22+
23+
<h1>Show #{show.id}</h1>
24+
<p>{show.name}</p>
25+
26+
<hr />
27+
28+
<Link href="/">
29+
<a>Go back home</a>
30+
</Link>
31+
</div>
32+
)
33+
}
34+
35+
export const getServerSideProps = async ({ params }) => {
36+
// The ID to render
37+
const { id } = params
38+
39+
const res = await fetch(`https://api.tvmaze.com/shows/${id}`)
40+
const data = await res.json()
41+
42+
// Set error code if show item could not be found
43+
const errorCode = res.status > 200 ? res.status : false
44+
45+
return {
46+
props: {
47+
errorCode,
48+
show: data,
49+
},
50+
}
51+
}
52+
53+
export default Show

0 commit comments

Comments
 (0)