Skip to content

Commit 4dedb1d

Browse files
author
sw-yx
committed
try to deploy
1 parent 743a354 commit 4dedb1d

26 files changed

+11416
-44
lines changed

.netlify/state.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"siteId": "62390d51-d3e5-4901-a676-8ae1a95ea9dc"
3+
}

example/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

example/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#Netlify Identity + Reach Router by wrapping the goTrue API in a React Hook.
2+
3+
[Deployed site here](https://unruffled-roentgen-04c3b8.netlify.com/)
4+
5+
this is a demo of using Netlify Identity with Reach Router by wrapping the goTrue API in a React Hook.
6+
7+
⚠️Make sure Netlify Identity is enabled!!! or demo wont work
8+
9+
Reach Router is used to show authentication as per [Ryan Florence](https://twitter.com/ryanflorence/status/1060361144701833216).
10+
11+
If you want to fork/deploy this yourself on Netlfiy, click this:
12+
13+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/netlify/create-react-app-lambda/tree/reachRouterAndGoTrueDemo&stack=cms)

example/lambda/async-dadjoke.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// example of async handler using async-await
2+
// https://github.com/netlify/netlify-lambda/issues/43#issuecomment-444618311
3+
4+
import fetch from "node-fetch"
5+
export async function handler(event, context) {
6+
try {
7+
const response = await fetch("https://icanhazdadjoke.com", { headers: { Accept: "application/json" } })
8+
if (!response.ok) {
9+
// NOT res.status >= 200 && res.status < 300
10+
return { statusCode: response.status, body: response.statusText }
11+
}
12+
const data = await response.json()
13+
14+
return {
15+
statusCode: 200,
16+
body: JSON.stringify({ msg: data.joke })
17+
}
18+
} catch (err) {
19+
console.log(err) // output to netlify function log
20+
return {
21+
statusCode: 500,
22+
body: JSON.stringify({ msg: err.message }) // Could be a custom message or object i.e. JSON.stringify(err)
23+
}
24+
}
25+
}

example/lambda/authEndPoint.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// example of async handler using async-await
2+
// https://github.com/netlify/netlify-lambda/issues/43#issuecomment-444618311
3+
4+
import fetch from 'node-fetch';
5+
export async function handler(event, context) {
6+
if (!context.clientContext && !context.clientContext.identity) {
7+
return {
8+
statusCode: 500,
9+
body: JSON.stringify({
10+
msg:
11+
'No identity instance detected. Did you enable it? Also, Netlify Identity is not supported on local dev yet.'
12+
}) // Could be a custom message or object i.e. JSON.stringify(err)
13+
};
14+
}
15+
const { identity, user } = context.clientContext;
16+
try {
17+
const response = await fetch('https://api.chucknorris.io/jokes/random');
18+
if (!response.ok) {
19+
// NOT res.status >= 200 && res.status < 300
20+
return { statusCode: response.status, body: response.statusText };
21+
}
22+
const data = await response.json();
23+
24+
return {
25+
statusCode: 200,
26+
body: JSON.stringify({ identity, user, msg: data.value })
27+
};
28+
} catch (err) {
29+
console.log(err); // output to netlify function log
30+
return {
31+
statusCode: 500,
32+
body: JSON.stringify({ msg: err.message }) // Could be a custom message or object i.e. JSON.stringify(err)
33+
};
34+
}
35+
}

example/lambda/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "lambda",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "async-dadjoke.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"node-fetch": "^2.4.1"
14+
}
15+
}

example/lambda/yarn.lock

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
node-fetch@^2.4.1:
6+
version "2.4.1"
7+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.4.1.tgz#b2e38f1117b8acbedbe0524f041fb3177188255d"
8+
integrity sha512-P9UbpFK87NyqBZzUuDBDz4f6Yiys8xm8j7ACDbi6usvFm6KItklQUKjeoqTrYS/S1k6I8oaOC2YLLDr/gg26Mw==

example/package.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@reach/router": "^1.2.1",
7+
"react-netlify-identity": "^0.0.12",
8+
"react-scripts": "3.0.0",
9+
"typescript": "3.4.5"
10+
},
11+
"scripts": {
12+
"start": "react-scripts start",
13+
"build": "react-scripts build",
14+
"test": "react-scripts test",
15+
"eject": "react-scripts eject"
16+
},
17+
"eslintConfig": {
18+
"extends": "react-app"
19+
},
20+
"browserslist": {
21+
"production": [
22+
">0.2%",
23+
"not dead",
24+
"not op_mini all"
25+
],
26+
"development": [
27+
"last 1 chrome version",
28+
"last 1 firefox version",
29+
"last 1 safari version"
30+
]
31+
},
32+
"devDependencies": {
33+
"@types/jest": "24.0.11",
34+
"@types/node": "11.13.8",
35+
"@types/reach__router": "^1.2.4",
36+
"@types/react": "16.8.14",
37+
"@types/react-dom": "16.8.4",
38+
"react": "^16.8.6",
39+
"react-dom": "^16.8.6"
40+
}
41+
}

example/public/_redirects

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* /index.html 200

example/public/favicon.ico

3.78 KB
Binary file not shown.

example/public/index.html

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<!--
9+
manifest.json provides metadata used when your web app is installed on a
10+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
11+
-->
12+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
13+
<!--
14+
Notice the use of %PUBLIC_URL% in the tags above.
15+
It will be replaced with the URL of the `public` folder during the build.
16+
Only files inside the `public` folder can be referenced from the HTML.
17+
18+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
19+
work correctly both with client-side routing and a non-root public URL.
20+
Learn how to configure a non-root public URL by running `npm run build`.
21+
-->
22+
<title>React App</title>
23+
</head>
24+
<body>
25+
<noscript>You need to enable JavaScript to run this app.</noscript>
26+
<div id="root"></div>
27+
<!--
28+
This HTML file is a template.
29+
If you open it directly in the browser, you will see an empty page.
30+
31+
You can add webfonts, meta tags, or analytics to this file.
32+
The build step will place the bundled scripts into the <body> tag.
33+
34+
To begin the development, run `npm start` or `yarn start`.
35+
To create a production bundle, use `npm run build` or `yarn build`.
36+
-->
37+
</body>
38+
</html>

example/public/manifest.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
}
10+
],
11+
"start_url": ".",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}

example/src/App.css

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.title {
6+
color: #d44b15;
7+
text-align: center;
8+
background-color: #e5e4e4;
9+
font-family: Lato, serif;
10+
margin-top: 0px;
11+
display: flex;
12+
13+
align-items: center;
14+
justify-content: center;
15+
}
16+
17+
.title .italic {
18+
color: #fff;
19+
font-size: 2em;
20+
font-style: italic;
21+
vertical-align: bottom;
22+
margin: 0 -0.3em;
23+
}
24+
pre {
25+
text-align: left;
26+
overflow-x: scroll;
27+
overflow-y: hidden;
28+
}
29+
30+
form {
31+
text-align: left;
32+
margin: 0 auto;
33+
display: inline-block;
34+
}
35+
form > div {
36+
margin-bottom: 1rem;
37+
}
38+
39+
nav {
40+
background: #ffe259; /* fallback for old browsers */
41+
background: -webkit-linear-gradient(
42+
to right,
43+
#ffa751,
44+
#ffe259
45+
); /* Chrome 10-25, Safari 5.1-6 */
46+
background: linear-gradient(
47+
to right,
48+
#ffa751,
49+
#ffe259
50+
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
51+
padding: 1rem;
52+
font-family: Lato, serif;
53+
font-weight: bold;
54+
margin-bottom: 1rem;
55+
}
56+
57+
nav a {
58+
color: brown;
59+
text-decoration: none;
60+
}
61+
62+
/* http://tobiasahlin.com/spinkit/ */
63+
64+
.sk-folding-cube {
65+
margin: 20px auto;
66+
width: 40px;
67+
height: 40px;
68+
position: relative;
69+
-webkit-transform: rotateZ(45deg);
70+
transform: rotateZ(45deg);
71+
}
72+
73+
.sk-folding-cube .sk-cube {
74+
float: left;
75+
width: 50%;
76+
height: 50%;
77+
position: relative;
78+
-webkit-transform: scale(1.1);
79+
-ms-transform: scale(1.1);
80+
transform: scale(1.1);
81+
}
82+
.sk-folding-cube .sk-cube:before {
83+
content: '';
84+
position: absolute;
85+
top: 0;
86+
left: 0;
87+
width: 100%;
88+
height: 100%;
89+
background-color: #333;
90+
-webkit-animation: sk-foldCubeAngle 2.4s infinite linear both;
91+
animation: sk-foldCubeAngle 2.4s infinite linear both;
92+
-webkit-transform-origin: 100% 100%;
93+
-ms-transform-origin: 100% 100%;
94+
transform-origin: 100% 100%;
95+
}
96+
.sk-folding-cube .sk-cube2 {
97+
-webkit-transform: scale(1.1) rotateZ(90deg);
98+
transform: scale(1.1) rotateZ(90deg);
99+
}
100+
.sk-folding-cube .sk-cube3 {
101+
-webkit-transform: scale(1.1) rotateZ(180deg);
102+
transform: scale(1.1) rotateZ(180deg);
103+
}
104+
.sk-folding-cube .sk-cube4 {
105+
-webkit-transform: scale(1.1) rotateZ(270deg);
106+
transform: scale(1.1) rotateZ(270deg);
107+
}
108+
.sk-folding-cube .sk-cube2:before {
109+
-webkit-animation-delay: 0.3s;
110+
animation-delay: 0.3s;
111+
}
112+
.sk-folding-cube .sk-cube3:before {
113+
-webkit-animation-delay: 0.6s;
114+
animation-delay: 0.6s;
115+
}
116+
.sk-folding-cube .sk-cube4:before {
117+
-webkit-animation-delay: 0.9s;
118+
animation-delay: 0.9s;
119+
}
120+
@-webkit-keyframes sk-foldCubeAngle {
121+
0%,
122+
10% {
123+
-webkit-transform: perspective(140px) rotateX(-180deg);
124+
transform: perspective(140px) rotateX(-180deg);
125+
opacity: 0;
126+
}
127+
25%,
128+
75% {
129+
-webkit-transform: perspective(140px) rotateX(0deg);
130+
transform: perspective(140px) rotateX(0deg);
131+
opacity: 1;
132+
}
133+
90%,
134+
100% {
135+
-webkit-transform: perspective(140px) rotateY(180deg);
136+
transform: perspective(140px) rotateY(180deg);
137+
opacity: 0;
138+
}
139+
}
140+
141+
@keyframes sk-foldCubeAngle {
142+
0%,
143+
10% {
144+
-webkit-transform: perspective(140px) rotateX(-180deg);
145+
transform: perspective(140px) rotateX(-180deg);
146+
opacity: 0;
147+
}
148+
25%,
149+
75% {
150+
-webkit-transform: perspective(140px) rotateX(0deg);
151+
transform: perspective(140px) rotateX(0deg);
152+
opacity: 1;
153+
}
154+
90%,
155+
100% {
156+
-webkit-transform: perspective(140px) rotateY(180deg);
157+
transform: perspective(140px) rotateY(180deg);
158+
opacity: 0;
159+
}
160+
}

0 commit comments

Comments
 (0)