├── .prettierrc.json ├── nodemon.json ├── .prettierignore ├── .eslintignore ├── client ├── src │ ├── pages │ │ ├── Apps │ │ │ ├── index.js │ │ │ └── Apps.js │ │ ├── Logs │ │ │ ├── index.js │ │ │ └── Logs.js │ │ └── Login │ │ │ ├── index.js │ │ │ ├── Login.stories.js │ │ │ └── Login.js │ ├── components │ │ ├── Button │ │ │ ├── index.js │ │ │ ├── Button.js │ │ │ └── Button.stories.js │ │ ├── Header │ │ │ ├── index.js │ │ │ ├── Header.stories.js │ │ │ └── Header.js │ │ ├── LogsTable │ │ │ ├── index.js │ │ │ ├── LogsTable.js │ │ │ └── LogsTable.stories.js │ │ ├── ErrorButton │ │ │ ├── index.js │ │ │ ├── ErrorButton.js │ │ │ └── ErrorButton.stories.js │ │ ├── InfoButton │ │ │ ├── index.js │ │ │ ├── InfoButton.js │ │ │ └── InfoButton.stories.js │ │ ├── LevelFilters │ │ │ ├── index.js │ │ │ ├── LevelFilters.stories.js │ │ │ └── LevelFilters.js │ │ ├── LogsTableRow │ │ │ ├── index.js │ │ │ └── LogsTableRow.js │ │ ├── WarningButton │ │ │ ├── index.js │ │ │ ├── WarningButton.js │ │ │ └── WarningButton.stories.js │ │ └── LanguageSelector │ │ │ ├── index.js │ │ │ └── LanguageSelector.js │ ├── assets │ │ ├── logo.png │ │ ├── direction.svg │ │ ├── flow.svg │ │ ├── code-brackets.svg │ │ ├── comments.svg │ │ ├── repo.svg │ │ ├── plugin.svg │ │ ├── stackalt.svg │ │ └── colors.svg │ ├── App.test.js │ ├── api │ │ ├── logs.js │ │ └── auth.js │ ├── setupTests.js │ ├── i18n │ │ ├── en.json │ │ ├── de.json │ │ └── context.js │ ├── index.js │ ├── hooks │ │ ├── useCookie.js │ │ └── useFetch.js │ ├── App.js │ ├── GlobalStyles.js │ └── serviceWorker.js ├── public │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── robots.txt │ ├── fonts │ │ ├── Cascadia.eot │ │ ├── Cascadia.otf │ │ ├── Cascadia.ttf │ │ └── Cascadia.woff │ ├── manifest.json │ └── index.html ├── .storybook │ ├── main.js │ └── preview.js ├── .gitignore ├── package.json └── README.md ├── README.md ├── .eslintrc.json ├── lib ├── db.js ├── logsRouter.js └── authRouter.js ├── .github └── workflows │ └── node.js.yml ├── LICENSE ├── server.js ├── .gitignore └── package.json /.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignore": ["client/*"] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | build 3 | coverage -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | storybook-static/ -------------------------------------------------------------------------------- /client/src/pages/Apps/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./Apps"; 2 | -------------------------------------------------------------------------------- /client/src/pages/Logs/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./Logs"; 2 | -------------------------------------------------------------------------------- /client/src/pages/Login/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./Login"; 2 | -------------------------------------------------------------------------------- /client/src/components/Button/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./Button"; 2 | -------------------------------------------------------------------------------- /client/src/components/Header/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./Header"; 2 | -------------------------------------------------------------------------------- /client/src/components/LogsTable/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./LogsTable"; 2 | -------------------------------------------------------------------------------- /client/src/components/ErrorButton/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./ErrorButton"; 2 | -------------------------------------------------------------------------------- /client/src/components/InfoButton/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./InfoButton"; 2 | -------------------------------------------------------------------------------- /client/src/components/LevelFilters/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./LevelFilters"; 2 | -------------------------------------------------------------------------------- /client/src/components/LogsTableRow/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./LogsTableRow"; 2 | -------------------------------------------------------------------------------- /client/src/components/WarningButton/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./WarningButton"; 2 | -------------------------------------------------------------------------------- /client/src/components/LanguageSelector/index.js: -------------------------------------------------------------------------------- 1 | export { default } from "./LanguageSelector"; 2 | -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/logo192.png -------------------------------------------------------------------------------- /client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/logo512.png -------------------------------------------------------------------------------- /client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /client/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/src/assets/logo.png -------------------------------------------------------------------------------- /client/public/fonts/Cascadia.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/fonts/Cascadia.eot -------------------------------------------------------------------------------- /client/public/fonts/Cascadia.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/fonts/Cascadia.otf -------------------------------------------------------------------------------- /client/public/fonts/Cascadia.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/fonts/Cascadia.ttf -------------------------------------------------------------------------------- /client/public/fonts/Cascadia.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmachens/logs/HEAD/client/public/fonts/Cascadia.woff -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Node.js CI](https://github.com/lmachens/logs/workflows/Node.js%20CI/badge.svg) 2 | 3 | # cra-with-api 4 | 5 | Boilerplate for Create-React-App with an Express.js API 6 | -------------------------------------------------------------------------------- /client/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { render } from "@testing-library/react"; 3 | import App from "./App"; 4 | 5 | test("renders App", () => { 6 | render(); 7 | }); 8 | -------------------------------------------------------------------------------- /client/.storybook/main.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], 3 | addons: [ 4 | "@storybook/addon-links", 5 | "@storybook/addon-essentials", 6 | "@storybook/preset-create-react-app", 7 | ], 8 | }; 9 | -------------------------------------------------------------------------------- /client/src/api/logs.js: -------------------------------------------------------------------------------- 1 | export const getLogs = async (filters) => { 2 | const queryParams = filters.map((filter) => `level=${filter}`).join("&"); 3 | const response = await fetch(`/api/logs?${queryParams}`); 4 | const logs = await response.json(); 5 | return logs; 6 | }; 7 | -------------------------------------------------------------------------------- /client/src/pages/Apps/Apps.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useDictMessages } from "../../i18n/context"; 3 | 4 | const Apps = () => { 5 | const dictMessages = useDictMessages(); 6 | 7 | return
{dictMessages.comingSoon}
; 8 | }; 9 | 10 | export default Apps; 11 | -------------------------------------------------------------------------------- /client/src/components/InfoButton/InfoButton.js: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | import Button from "../Button"; 3 | 4 | const InfoButton = styled(Button)` 5 | color: var(--info-color); 6 | `; 7 | 8 | InfoButton.displayName = "InfoButton"; 9 | 10 | export default InfoButton; 11 | -------------------------------------------------------------------------------- /client/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import "@testing-library/jest-dom/extend-expect"; 6 | -------------------------------------------------------------------------------- /client/src/pages/Login/Login.stories.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import Login from "./Login"; 4 | 5 | export default { 6 | title: "Login", 7 | component: Login, 8 | }; 9 | 10 | const Template = (args) => ; 11 | 12 | export const Default = Template.bind({}); 13 | -------------------------------------------------------------------------------- /client/src/components/ErrorButton/ErrorButton.js: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | import Button from "../Button"; 3 | 4 | const ErrorButton = styled(Button)` 5 | color: var(--error-color); 6 | `; 7 | 8 | ErrorButton.displayName = "ErrorButton"; 9 | 10 | export default ErrorButton; 11 | -------------------------------------------------------------------------------- /client/src/components/WarningButton/WarningButton.js: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | import Button from "../Button"; 3 | 4 | const WarningButton = styled(Button)` 5 | color: var(--warning-color); 6 | `; 7 | 8 | WarningButton.displayName = "WarningButton"; 9 | 10 | export default WarningButton; 11 | -------------------------------------------------------------------------------- /client/src/components/Button/Button.js: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | 3 | const Button = styled.button` 4 | border: 1px solid currentColor; 5 | border-radius: 15px; 6 | background: none; 7 | padding: 0.3rem 0.6rem; 8 | filter: ${(props) => (props.inactive ? "grayscale(1)" : "none")}; 9 | `; 10 | 11 | export default Button; 12 | -------------------------------------------------------------------------------- /client/src/api/auth.js: -------------------------------------------------------------------------------- 1 | export const login = async (credentials) => { 2 | const response = await fetch("/api/login", { 3 | method: "POST", 4 | headers: { 5 | "Content-Type": "application/json", 6 | }, 7 | body: JSON.stringify(credentials), 8 | }); 9 | 10 | const account = await response.json(); 11 | return account; 12 | }; 13 | -------------------------------------------------------------------------------- /client/src/i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "locale": "en", 3 | "messages": { 4 | "login": "Login", 5 | "emailPlaceholder": "What's your email?", 6 | "loading": "Loading...", 7 | "origin": "Origin", 8 | "createdAt": "Created At", 9 | "level": "Level", 10 | "message": "Message", 11 | "comingSoon": "Coming soon..." 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/src/i18n/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "locale": "de", 3 | "messages": { 4 | "login": "Einloggen", 5 | "emailPlaceholder": "Wie ist deine E-Mail?", 6 | "loading": "Lade...", 7 | "origin": "Quelle", 8 | "createdAt": "Erstellt am", 9 | "level": "Level", 10 | "message": "Nachricht", 11 | "comingSoon": "In Entwicklung..." 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 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 | /storybook-static 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* 25 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true 7 | }, 8 | "extends": [ 9 | "react-app", 10 | "eslint:recommended", 11 | "plugin:react/recommended", 12 | "prettier" 13 | ], 14 | "parserOptions": { 15 | "ecmaFeatures": { 16 | "jsx": true 17 | }, 18 | "ecmaVersion": 12, 19 | "sourceType": "module" 20 | }, 21 | "rules": {} 22 | } 23 | -------------------------------------------------------------------------------- /client/src/components/Button/Button.stories.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import Button from "./Button"; 4 | 5 | export default { 6 | title: "Button", 7 | component: Button, 8 | }; 9 | 10 | const Template = (args) => 57 | 58 | ); 59 | }; 60 | 61 | export default Login; 62 | -------------------------------------------------------------------------------- /lib/authRouter.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const jwt = require("jsonwebtoken"); 3 | 4 | const { getCollection } = require("./db"); 5 | 6 | const authRouter = express.Router(); 7 | 8 | const ONE_MONTH_IN_SECONDS = 30 * 24 * 60 * 60; 9 | authRouter.post("/login", async (request, response) => { 10 | try { 11 | const { email } = request.body; 12 | 13 | const account = await getCollection("accounts").findOne({ email }); 14 | 15 | if (!account) { 16 | return response.status(404).end("Account not found"); 17 | } 18 | const authToken = jwt.sign({ email }, process.env.JWT_SECRET, { 19 | expiresIn: ONE_MONTH_IN_SECONDS, 20 | }); 21 | 22 | response.setHeader( 23 | "Set-Cookie", 24 | `authToken=${authToken};path=/;Max-Age=${ONE_MONTH_IN_SECONDS}` 25 | ); 26 | response.json(account); 27 | } catch (error) { 28 | console.error(error); 29 | response.status(500).send("Internal server error"); 30 | } 31 | }); 32 | 33 | authRouter.post("/register", async (request, response) => { 34 | try { 35 | const { email } = request.body; 36 | 37 | const existingAccount = await getCollection("accounts").findOne({ email }); 38 | 39 | if (existingAccount) { 40 | return response.status(409).end("Account already exists"); 41 | } 42 | 43 | const inserted = await getCollection("accounts").insertOne({ email }); 44 | if (!inserted.result.ok) { 45 | return response.status(500).end("Can not register account"); 46 | } 47 | 48 | const account = inserted.ops[0]; 49 | response.json(account); 50 | } catch (error) { 51 | console.error(error); 52 | response.status(500).send("Internal server error"); 53 | } 54 | }); 55 | module.exports = authRouter; 56 | -------------------------------------------------------------------------------- /client/src/components/Header/Header.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styled from "@emotion/styled"; 3 | import PropTypes from "prop-types"; 4 | import logoSrc from "../../assets/logo.png"; 5 | import { Link, useLocation } from "react-router-dom"; 6 | import LanguageSelector from "../LanguageSelector"; 7 | 8 | const FlexHeader = styled.header` 9 | display: flex; 10 | align-items: center; 11 | 12 | img { 13 | height: 3rem; 14 | margin-right: 1rem; 15 | } 16 | 17 | h1 { 18 | flex-grow: 1; 19 | font-size: 1.4rem; 20 | text-transform: uppercase; 21 | } 22 | ul { 23 | list-style: none; 24 | margin: 0; 25 | 26 | li { 27 | display: inline-block; 28 | margin-left: 1rem; 29 | } 30 | } 31 | `; 32 | 33 | const NavLink = styled(({ active, ...props }) => )` 34 | color: ${(props) => (props.active ? "var(--active-color)" : "inherit")}; 35 | `; 36 | 37 | const Header = ({ loggedIn, ...props }) => { 38 | const location = useLocation(); 39 | 40 | const navItems = loggedIn ? ( 41 | <> 42 |
  • 43 | 44 | Logs 45 | 46 |
  • 47 |
  • 48 | 49 | Apps 50 | 51 |
  • 52 | 53 | ) : ( 54 |
  • 55 | 56 | Login 57 | 58 |
  • 59 | ); 60 | 61 | return ( 62 | 63 | Logo 64 |

    Logs

    65 | 66 | 69 |
    70 | ); 71 | }; 72 | 73 | Header.propTypes = { 74 | loggedIn: PropTypes.bool, 75 | }; 76 | 77 | export default Header; 78 | -------------------------------------------------------------------------------- /client/src/GlobalStyles.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Global, css } from "@emotion/core"; 3 | 4 | const GlobalStyles = () => ( 5 | 69 | ); 70 | 71 | export default GlobalStyles; 72 | -------------------------------------------------------------------------------- /client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | CRA-With-API 28 | 29 | 30 | 31 |
    32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /client/src/assets/plugin.svg: -------------------------------------------------------------------------------- 1 | illustration/plugin -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cra-with-api", 3 | "private": true, 4 | "version": "1.0.0", 5 | "description": "Boilerplate for Create-React-App with an Express.js API", 6 | "main": "server.js", 7 | "scripts": { 8 | "postinstall": "cd client && npm install", 9 | "build": "cd client && npm run build && npm run build-storybook", 10 | "test": "npm run lint && cd client && npm test", 11 | "lint": "eslint . --ext .js", 12 | "prettify": "prettier --write .", 13 | "dev": "concurrently \"npm run server\" \"npm run client\"", 14 | "client": "cd client && npm start", 15 | "server": "nodemon server.js", 16 | "storybook": "cd client && npm run storybook", 17 | "start": "node server.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/lmachens/cra-with-api.git" 22 | }, 23 | "keywords": [], 24 | "author": "Leon Machens", 25 | "license": "MIT", 26 | "bugs": { 27 | "url": "https://github.com/lmachens/cra-with-api/issues" 28 | }, 29 | "homepage": "https://github.com/lmachens/cra-with-api#readme", 30 | "dependencies": { 31 | "body-parser": "^1.19.0", 32 | "cookie-parser": "^1.4.5", 33 | "dotenv": "^8.2.0", 34 | "express": "^4.17.1", 35 | "js-cookie": "^2.2.1", 36 | "jsonwebtoken": "^8.5.1", 37 | "mongodb": "^3.6.1" 38 | }, 39 | "devDependencies": { 40 | "@typescript-eslint/eslint-plugin": "^4.0.1", 41 | "@typescript-eslint/parser": "^4.0.1", 42 | "babel-eslint": "^10.1.0", 43 | "concurrently": "^5.3.0", 44 | "eslint": "^6.6.0", 45 | "eslint-config-prettier": "^6.11.0", 46 | "eslint-config-react-app": "^5.2.1", 47 | "eslint-plugin-flowtype": "^5.2.0", 48 | "eslint-plugin-import": "^2.22.0", 49 | "eslint-plugin-jsx-a11y": "^6.3.1", 50 | "eslint-plugin-react": "^7.20.6", 51 | "eslint-plugin-react-hooks": "^4.1.0", 52 | "husky": "^4.2.5", 53 | "lint-staged": "^10.2.13", 54 | "nodemon": "^2.0.4", 55 | "prettier": "2.1.1", 56 | "typescript": "^4.0.2" 57 | }, 58 | "husky": { 59 | "hooks": { 60 | "pre-commit": "lint-staged" 61 | } 62 | }, 63 | "lint-staged": { 64 | "*.js": "eslint --cache --fix", 65 | "*.{js,css,md}": "prettier --write" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /client/src/assets/stackalt.svg: -------------------------------------------------------------------------------- 1 | illustration/stackalt -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
    10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
    13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
    18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
    23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
    26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /client/src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === "localhost" || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === "[::1]" || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener("load", () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | "This web app is being served cache-first by a service " + 46 | "worker. To learn more, visit https://bit.ly/CRA-PWA" 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then((registration) => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === "installed") { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | "New content is available and will be used when all " + 74 | "tabs for this page are closed. See https://bit.ly/CRA-PWA." 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log("Content is cached for offline use."); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch((error) => { 97 | console.error("Error during service worker registration:", error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { "Service-Worker": "script" }, 105 | }) 106 | .then((response) => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get("content-type"); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf("javascript") === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then((registration) => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | "No internet connection found. App is running in offline mode." 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ("serviceWorker" in navigator) { 133 | navigator.serviceWorker.ready 134 | .then((registration) => { 135 | registration.unregister(); 136 | }) 137 | .catch((error) => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /client/src/assets/colors.svg: -------------------------------------------------------------------------------- 1 | illustration/colors --------------------------------------------------------------------------------