Skip to content

Commit 9a4d9cc

Browse files
committed
Initial commit
0 parents  commit 9a4d9cc

36 files changed

+22645
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_STORE
3+
.env

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# voice-notes
2+
3+
A simple voice-based note-taking webapp, built on the MERN stack.
4+
5+
## Frontend
6+
7+
Authenticated state maintained across different pages with React's `useContext` API. Two higher-order components, `PrivateRoute` and `PublicRoute`, return `react-router` routes based on authentication status. `AuthService` handles authentication endpoints, and note-taking relies on the `SpeechRecognition` interface from the Web Speech API.
8+
9+
## Backend
10+
11+
Node with Express backend. Uses `Passport.js` for issuing JSON web tokens to users, `Mongoose` for querying users and notes, and `bcrypt` for password hashing. Frontend served via Express route.

client/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
node_modules
2+
.DS_STORE# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3+
4+
# dependencies
5+
/node_modules
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
# production
13+
/build
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*

client/package.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "voice-notes-frontend",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@testing-library/jest-dom": "^4.2.4",
7+
"@testing-library/react": "^9.3.2",
8+
"@testing-library/user-event": "^7.1.2",
9+
"react": "^16.13.1",
10+
"react-dom": "^16.13.1",
11+
"react-router": "^5.1.2",
12+
"react-router-dom": "^5.1.2",
13+
"react-scripts": "3.4.1"
14+
},
15+
"scripts": {
16+
"dev": "react-scripts start",
17+
"build": "react-scripts build",
18+
"test": "react-scripts test",
19+
"eject": "react-scripts eject"
20+
},
21+
"eslintConfig": {
22+
"extends": "react-app"
23+
},
24+
"browserslist": {
25+
"production": [
26+
">0.2%",
27+
"not dead",
28+
"not op_mini all"
29+
],
30+
"development": [
31+
"last 1 chrome version",
32+
"last 1 firefox version",
33+
"last 1 safari version"
34+
]
35+
},
36+
"proxy": "http://localhost:5000",
37+
"secure": false
38+
}

client/public/favicon.ico

3.08 KB
Binary file not shown.

client/public/index.html

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

client/public/logo192.png

5.22 KB
Loading

client/public/logo512.png

9.44 KB
Loading

client/public/manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

client/public/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

client/src/App.css

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&display=swap');
2+
3+
body {
4+
font-family: 'IBM Plex Mono', monospace;
5+
font-weight: 400;
6+
font-size: 16px;
7+
max-width: 800px;
8+
margin-left: auto;
9+
margin-right: auto;
10+
background: #f8f7f8;
11+
}
12+
13+
input {
14+
border: none;
15+
outline: none;
16+
background: none;
17+
display: block;
18+
font-family: 'IBM Plex Mono', monospace;
19+
font-size: 20px;
20+
width: 100%;
21+
border-bottom: 1px solid #cccccc;
22+
padding: 12px 0;
23+
margin-top: 12px;
24+
}
25+
26+
input:focus {
27+
border-color: #777777;
28+
}
29+
30+
button {
31+
border: none;
32+
outline: none;
33+
background-color: #00baff;
34+
color: white;
35+
font-family: 'IBM Plex Mono', monospace;
36+
font-weight: 700;
37+
font-size: 20px;
38+
padding: 12px 20px;
39+
cursor: pointer;
40+
border-radius: 8px;
41+
-webkit-transition: all 0.15s ease-in-out;
42+
-moz-transition: all 0.15s ease-in-out;
43+
-ms-transition: all 0.15s ease-in-out;
44+
-o-transition: all 0.15s ease-in-out;
45+
transition: all 0.15s ease-in-out;
46+
}
47+
48+
button img {
49+
margin-right: 16px;
50+
}
51+
52+
a {
53+
color: #00baff;
54+
text-decoration: none;
55+
}
56+
57+
.nav {
58+
padding: 20px 0;
59+
}
60+
61+
.nav span {
62+
cursor: pointer;
63+
float: right;
64+
color: #00baff;
65+
}
66+
67+
.note {
68+
margin-top: 20px;
69+
font-size: 20px;
70+
line-height: 36px;
71+
}
72+
73+
.note span {
74+
color: #777777;
75+
display: block;
76+
}
77+
78+
.form-container {
79+
max-width: 400px;
80+
margin-left: auto;
81+
margin-right: auto;
82+
}
83+
84+
.form-container a {
85+
display: block;
86+
margin-top: 40px;
87+
}
88+
89+
.form-container button {
90+
margin-top: 20px;
91+
width: 100%;
92+
}
93+
94+
.notes-container {
95+
max-height: calc(100vh - 188px);
96+
overflow: scroll;
97+
}
98+
99+
.center {
100+
text-align: center;
101+
}
102+
103+
.button-container {
104+
bottom: 40px;
105+
position: fixed;
106+
display: flex;
107+
align-items: center;
108+
flex-direction: column;
109+
left: 50%;
110+
transform: translateX(-50%);
111+
}
112+
113+
.button-container button {
114+
width: 264px;
115+
white-space: nowrap;
116+
display: flex;
117+
align-items: center;
118+
}
119+
120+
.message {
121+
margin-top: 20px;
122+
background-color: #ffe2e2;
123+
color: #ed2626;
124+
padding: 12px 16px;
125+
text-align: center;
126+
border-radius: 8px;
127+
}

client/src/App.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import './App.css';
3+
import { BrowserRouter as Router } from 'react-router-dom';
4+
5+
import PrivateRoute from './routes/PrivateRoute';
6+
import PublicRoute from './routes/PublicRoute';
7+
8+
import Home from './pages/Home';
9+
import Login from './pages/Login';
10+
import Register from './pages/Register';
11+
12+
const App = () => {
13+
return (
14+
<Router>
15+
<PrivateRoute exact path="/" component={Home} />
16+
<PublicRoute exact path="/login" component={Login} />
17+
<PublicRoute exact path="/register" component={Register} />
18+
</Router>
19+
);
20+
};
21+
22+
export default App;

client/src/assets/start.svg

+4
Loading

client/src/assets/stop.svg

+4
Loading

client/src/components/AuthForm.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
3+
const AuthForm = ({
4+
isLogin,
5+
message,
6+
onChange,
7+
onSubmit,
8+
username,
9+
password,
10+
}) => {
11+
return (
12+
<div className="form-container">
13+
{message && <div className="message">{message}</div>}
14+
<h1>{isLogin ? 'Login' : 'Register'}</h1>
15+
<input
16+
type="text"
17+
name="username"
18+
placeholder="username"
19+
value={username}
20+
onChange={onChange}
21+
/>
22+
<input
23+
name="password"
24+
type="password"
25+
placeholder="password"
26+
value={password}
27+
onChange={onChange}
28+
/>
29+
<button onClick={onSubmit}>{isLogin ? 'Login' : 'Register'}</button>
30+
{isLogin ? (
31+
<a href="/register">No account? Register</a>
32+
) : (
33+
<a href="/login">Have an account? Login</a>
34+
)}
35+
</div>
36+
);
37+
};
38+
39+
export default AuthForm;

client/src/components/Navigation.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React, { useContext } from 'react';
2+
import { AuthContext } from '../context/AuthContext';
3+
import AuthService from '../services/AuthService';
4+
5+
const Navigation = () => {
6+
const { user, setUser, setIsAuthenticated } = useContext(AuthContext);
7+
8+
const logout = (event) => {
9+
AuthService.logout().then((data) => {
10+
const { success } = data;
11+
if (success) {
12+
setUser('');
13+
setIsAuthenticated(false);
14+
}
15+
});
16+
};
17+
return (
18+
<div className="nav">
19+
{user} <span onClick={logout}>Logout</span>
20+
</div>
21+
);
22+
};
23+
24+
export default Navigation;

client/src/components/Note.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
const Note = (props) => {
4+
const { date, content } = props;
5+
return (
6+
<div className="note">
7+
<span>{date}</span>
8+
{content}
9+
</div>
10+
);
11+
};
12+
13+
export default Note;

0 commit comments

Comments
 (0)