├── client ├── assets │ ├── bongocat.png │ ├── keylogo.png │ ├── 100keyboard.png │ ├── 60keyboard.png │ ├── 65keyboard.png │ ├── 75keyboard.png │ ├── 80keyboard.png │ └── bongocatkeyboard.png ├── redux │ ├── store.js │ └── userSlice.js ├── index.html ├── components │ ├── SavedBuildsButton.js │ ├── App.js │ ├── LogoutButton.js │ ├── Landing.js │ ├── HomePage.js │ ├── SavedKeebsPage.js │ ├── SavedBuilds.js │ ├── Signup.js │ ├── Login.js │ └── StartBuild.js ├── index.js └── scss │ └── styles.scss ├── .babelrc ├── .github └── pull_request_template.md ├── server ├── routes │ ├── login.js │ ├── signup.js │ └── build.js ├── models │ └── keebuildsModel.js ├── server.js └── controllers │ ├── loginSignupController.js │ └── keebuildsController.js ├── .eslintrc.json ├── keebuild_schema.sql ├── README.md ├── CONTRIBUTING.md ├── webpack.config.js ├── package.json ├── .gitignore ├── CODE_OF_CONDUCT.md ├── __tests__ └── server.test.js └── LICENSE /client/assets/bongocat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/bongocat.png -------------------------------------------------------------------------------- /client/assets/keylogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/keylogo.png -------------------------------------------------------------------------------- /client/assets/100keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/100keyboard.png -------------------------------------------------------------------------------- /client/assets/60keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/60keyboard.png -------------------------------------------------------------------------------- /client/assets/65keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/65keyboard.png -------------------------------------------------------------------------------- /client/assets/75keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/75keyboard.png -------------------------------------------------------------------------------- /client/assets/80keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/80keyboard.png -------------------------------------------------------------------------------- /client/assets/bongocatkeyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSDC-inc/Keebuilds/HEAD/client/assets/bongocatkeyboard.png -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "modules": false 7 | } 8 | ], 9 | "@babel/preset-react" 10 | ], 11 | "plugins": ["react-hot-loader/babel"] 12 | } 13 | -------------------------------------------------------------------------------- /client/redux/store.js: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit'; 2 | import userSlice from './userSlice'; 3 | //redux toolkit boilerplate 4 | export const store = configureStore({ 5 | reducer: { 6 | setUser: userSlice, 7 | }, 8 | }); -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Related Issue 2 | - Write about issue here 3 | 4 | ## Changes 5 | - Change 1 6 | - Change 2 7 | 8 | ## Additional Info 9 | - Any context or additional information 10 | 11 | # Checklist 12 | - [ ] Tests 13 | - [ ] Comments 14 | - [ ] Linting 15 | -------------------------------------------------------------------------------- /client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | keebuilds 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /server/routes/login.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const loginSignupController = require('../controllers/loginSignupController.js'); 3 | const loginRouter = express.Router(); 4 | 5 | 6 | // Post a build to the database 7 | loginRouter.get('/', loginSignupController.getUser, (req, res) => { 8 | return res.status(201).json(res.locals.isLogged); 9 | }); 10 | 11 | 12 | module.exports = loginRouter; 13 | -------------------------------------------------------------------------------- /server/routes/signup.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const loginSignupController = require('../controllers/loginSignupController.js'); 3 | const signupRouter = express.Router(); 4 | 5 | 6 | // Post a build to the database 7 | signupRouter.post('/', loginSignupController.createUser, (req, res, next) => { 8 | return res.status(201).json(res.locals.isLogged); 9 | }); 10 | 11 | module.exports = signupRouter; 12 | -------------------------------------------------------------------------------- /client/components/SavedBuildsButton.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Button from '@mui/material/Button'; 3 | import { Link } from 'react-router-dom'; 4 | import '../scss/styles.scss'; 5 | 6 | const SavedBuildsButton = () => { 7 | //link => render saved keebs 8 | 9 | return ( 10 |
11 | 12 | 13 | 14 |
15 | ); 16 | }; 17 | 18 | export default SavedBuildsButton; 19 | -------------------------------------------------------------------------------- /client/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from 'react-dom'; 3 | import { BrowserRouter } from 'react-router-dom'; 4 | import App from './components/App'; 5 | import './scss/styles.scss'; 6 | import { store } from './redux/store'; 7 | import { Provider } from 'react-redux'; 8 | //store passed in for redux toolkit 9 | //browserrouter enabling react router 10 | render( 11 | 12 | 13 | 14 | 15 | , 16 | document.getElementById('root') 17 | ); -------------------------------------------------------------------------------- /server/models/keebuildsModel.js: -------------------------------------------------------------------------------- 1 | const { Pool } = require('pg'); 2 | const PG_URI = 'postgres://dzrhvowm:YM3EpUISNrlmG2C6ifbDRV-HV1bjzPt1@jelani.db.elephantsql.com/dzrhvowm'; 3 | 4 | // create a new pool here using the connection string above 5 | const pool = new Pool({ 6 | connectionString: PG_URI 7 | }); 8 | 9 | // We export an object that contains a property called query, 10 | // which is a function that returns the invocation of pool.query() after logging the query 11 | // This will be required in the controllers to be the access point to the database 12 | module.exports = { 13 | query: (text, params, callback) => { 14 | return pool.query(text, params, callback); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "ignorePatterns": ["**/test", "**/__tests__"], 4 | "env": { 5 | "node": true, 6 | "browser": true, 7 | "es2021": true 8 | }, 9 | "plugins": ["react"], 10 | "extends": ["eslint:recommended", "plugin:react/recommended"], 11 | "parserOptions": { 12 | "sourceType": "module", 13 | "ecmaFeatures": { 14 | "jsx": true 15 | } 16 | }, 17 | "rules": { 18 | "indent": ["warn", 2], 19 | "no-unused-vars": ["off", { "vars": "local" }], 20 | "prefer-const": "warn", 21 | "quotes": ["warn", "single"], 22 | "react/prop-types": "off", 23 | "semi": ["warn", "always"], 24 | "space-infix-ops": "warn" 25 | }, 26 | "settings": { 27 | "react": { "version": "detect"} 28 | } 29 | } -------------------------------------------------------------------------------- /client/redux/userSlice.js: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit'; 2 | 3 | 4 | const initialState = { 5 | username: 'fake username lol', 6 | isLoggedIn: false, //when application starts, defaults to false 7 | }; 8 | 9 | export const userSlice = createSlice({ 10 | name: 'setUser', 11 | initialState, 12 | reducers: { 13 | changeUserState: state => { 14 | if (state.isLoggedIn) { 15 | state.isLoggedIn = false; //signs out the user 16 | } else { 17 | state.isLoggedIn = true; //signs the user in 18 | } 19 | }, 20 | setUsername: (state, action) => { 21 | state.username = action.payload; 22 | }, 23 | }, 24 | }); 25 | 26 | export const { changeUserState, setUsername } = userSlice.actions; 27 | 28 | export default userSlice.reducer; -------------------------------------------------------------------------------- /keebuild_schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE userFavorites ( 2 | build_id serial NOT NULL PRIMARY KEY, 3 | build_name varchar NOT NULL, 4 | user_id int, 5 | FOREIGN KEY(user_id) 6 | REFERENCES users(user_id), 7 | case_type varchar NOT NULL, 8 | pcb varchar NOT NULL, 9 | plate varchar NOT NULL, 10 | switches varchar NOT NULL, 11 | keycaps varchar NOT NULL); 12 | 13 | INSERT INTO userFavorites (build_name, user_id, case_type, pcb, plate, switches, keycaps) 14 | VALUES ('buildOneDummy', 15, '100%', 'Hotswap','Polycarbonite','Linear','GMK'); 15 | 16 | INSERT INTO userFavorites (build_name, user_id, case_type, pcb, plate, switches, keycaps) 17 | SELECT 'build', user_id, 'TKL', 'trad', 'aluminium', 'clicky', 'pbt' 18 | FROM users 19 | WHERE username='dinosaur'; 20 | -------------------------------------------------------------------------------- /client/components/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import '../scss/styles.scss'; 3 | import { Routes, Route } from 'react-router-dom'; 4 | import HomePage from './HomePage'; 5 | import SavedKeebsPage from './SavedKeebsPage'; 6 | import Landing from './Landing'; 7 | import Signup from './Signup'; 8 | import Login from './Login'; 9 | 10 | const App = () => { 11 | 12 | return ( 13 |
14 | {/* React router boilterplate for dynamic rendering */} 15 | 16 | } /> 17 | } /> 18 | } /> 19 | } /> 20 | } /> 21 | 22 |
23 | ); 24 | }; 25 | 26 | export default App; 27 | -------------------------------------------------------------------------------- /client/components/LogoutButton.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Button from '@mui/material/Button'; 3 | import '../scss/styles.scss'; 4 | import { changeUserState } from '../redux/userSlice'; 5 | import { useDispatch } from 'react-redux'; 6 | import { useNavigate } from 'react-router-dom'; 7 | 8 | function LogoutButton() { 9 | const navigate = useNavigate(); 10 | const navToHome = () => navigate('/'); 11 | const dispatch = useDispatch(); 12 | 13 | //changes userState to {isLogged: false} 14 | function logout() { 15 | dispatch(changeUserState()); 16 | return navToHome(); 17 | 18 | } 19 | 20 | return ( 21 |
22 |
23 | 24 |
25 |
26 | ); 27 | } 28 | 29 | export default LogoutButton; -------------------------------------------------------------------------------- /client/components/Landing.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | 4 | 5 | function Landing() { 6 | //TODO: move inline styling to scss folder 7 | return ( 8 |
9 |
10 |

hello :3 welcome

11 |
12 |

13 |
14 | KEEBUILDS_ 15 |
16 |

17 |
18 |
19 | login_ 20 | signup_ 21 |
22 |
23 |
24 | ); 25 | } 26 | 27 | export default Landing; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Keebuilds 2 | 3 |
4 | 5 | ![Bongo Cat](./client/assets/bongocatkeyboard.png "Keebuilds Logo") 6 | 7 |
8 | 9 | Consumer friendly web application used to customize and build your niche quality fully operating mechanical keyboard! 10 | 11 | 12 | ## Technologies 13 | 14 | * [React](https://reactjs.org/) 15 | * [React Router](https://reactrouter.com/en/main) 16 | * [Redux Toolkit](https://redux-toolkit.js.org/) 17 | * [Material UI](https://mui.com/) 18 | * [Webpack](https://webpack.js.org/) 19 | * [Node](https://nodejs.org/en/) 20 | * [Express](https://expressjs.com/) 21 | * [Jest](https://jestjs.io/) 22 | * [Supertest](https://www.npmjs.com/package/supertest) 23 | 24 | 25 | ## Features 26 | 27 | - Ability to save and delete user builds 28 | - Secured signup/login 29 | - Niche mechanical keyboard selections 30 | 31 | ## Running Keebuilds 32 | 33 | 1. Install dependencies with 34 | 35 | npm install 36 | 37 | 38 | 2. Run the application 39 | 40 | npm run dev 41 | 42 | 43 | 44 | ## License 45 | 46 | This project is licensed under Mozilla Public License Version 2.0 - see the LICENSE.md file for details. 47 | -------------------------------------------------------------------------------- /server/routes/build.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const keebuildsController = require('./../controllers/keebuildsController'); 3 | 4 | const loginSignupController = require('../controllers/loginSignupController.js'); 5 | const buildRouter = express.Router(); 6 | 7 | 8 | // Post a build to the database 9 | buildRouter.post('/build', keebuildsController.createBuild, (req, res) => { 10 | return res.status(201).send('end of buildRouter post, create build'); 11 | }); 12 | 13 | //Get build from database 14 | buildRouter.get( 15 | '/saved', 16 | keebuildsController.getBuildsForSession, 17 | (req, res) => { 18 | return res.status(200).json(res.locals.builds); 19 | } 20 | ); 21 | 22 | buildRouter.delete( 23 | '/build', 24 | keebuildsController.deleteBuild, 25 | (req, res) => { 26 | return res.status(204).send('end of buildRouter delete, delete build'); 27 | } 28 | ); 29 | 30 | 31 | buildRouter.post('/signup', loginSignupController.createUser, 32 | (req, res) => { 33 | return res.status(201).json(res.locals.isLogged); 34 | }); 35 | 36 | buildRouter.get('/login', loginSignupController.getUser, 37 | (req, res) => { 38 | return res.status(201).json(res.locals.isLogged); 39 | }); 40 | 41 | 42 | module.exports = buildRouter; 43 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Keebuilds 2 | 3 | Thank you for your contribution! Contributions are welcome and are greatly appreciated and every little bit helps. 4 | 5 | ## Reporting Bugs 6 | 7 | All code changes happen through Github Pull Requests and we actively welcome them. To submit your pull request, follow the steps below: 8 | 9 | ## Pull Requests 10 | 11 | 1. Fork the repo and create your featured branch. 12 | 2. If you've added code that should be tested, add tests. 13 | 3. Make sure your code lints. 14 | 4. Issue that pull request! 15 | 5. Specify what you changed in details when you are doing pull request. 16 | 17 | Note: Any contributions you make will be under the MIT Software License and your submissions are understood to be under the same that covers the project. Please reach out to the team if you have any questions. 18 | 19 | ## Issues 20 | 21 | We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue. 22 | 23 | ## Coding Style 24 | 25 | * 2 spaces for indentation rather than tabs 26 | * 80 character line length 27 | * Run `npm run lint` to conform to our lint rules 28 | 29 | ## License 30 | 31 | By contributing, you agree that your contributions will be licensed under Keebuild's Mozilla Public License Version 2.0. 32 | 33 | ### References 34 | 35 | This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/master/CONTRIBUTING.md) -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | const { webpack } = require('webpack'); 4 | 5 | module.exports = { 6 | mode: process.env.NODE_ENV, 7 | entry: path.resolve(__dirname, './client/index.js'), 8 | output: { 9 | path: path.resolve(__dirname, './build'), 10 | filename: 'bundle.js', 11 | publicPath: '/' 12 | }, 13 | devServer: { 14 | static: { 15 | directory: path.resolve(__dirname, './build'), 16 | publicPath: '/', 17 | }, 18 | proxy: { 19 | '/api':'http://localhost:3000', 20 | }, 21 | compress: false, 22 | host: 'localhost', 23 | port: 8080, 24 | hot: true, 25 | historyApiFallback:true, 26 | }, 27 | plugins: [new HtmlWebpackPlugin({ template: './client/index.html' })], 28 | module: { 29 | rules: [ 30 | // babel rules 31 | { 32 | test: /\.jsx?/, 33 | exclude: /(node_modules)/, 34 | use: { 35 | loader: 'babel-loader', 36 | options: { 37 | presets: ['@babel/preset-env', '@babel/preset-react'], 38 | } 39 | } 40 | }, 41 | // css rules 42 | { 43 | test: /\.s[ac]ss$/i, 44 | use: ['style-loader', 'css-loader', 'sass-loader'] 45 | }, 46 | { 47 | test: /\.png$/, 48 | use: [ 49 | { 50 | loader: 'url-loader', 51 | options: { 52 | mimetype: 'image/png' 53 | } 54 | } 55 | ] 56 | } 57 | ] 58 | } 59 | }; -------------------------------------------------------------------------------- /server/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const path = require('path'); 4 | const cors = require('cors'); 5 | const PORT = process.env.PORT || 3000; 6 | const buildRouter = require('./routes/build.js'); 7 | 8 | app.use(cors()); 9 | app.use(express.json()); 10 | app.use(express.urlencoded({ extended: true })); 11 | 12 | // serve files on production mode webpack related 13 | if (process.env.NODE_ENV !== 'development') { 14 | app.use('/build', express.static(path.resolve(__dirname, '../build'))); 15 | app.get('/', (req, res) => { 16 | return res 17 | .status(200) 18 | .sendFile(path.resolve(__dirname, '../build/index.html')); 19 | }); 20 | } 21 | // serving html to localhost:3000 22 | app.get('/', (req,res,next)=>{ 23 | res.status(200).sendFile(path.join(__dirname, '/../client/index.html')); 24 | }); 25 | app.get('/whateverwewant', (req,res,next)=>{ 26 | res.status(200).sendFile(path.join(__dirname, '/../build/bundle.js')); 27 | }); 28 | 29 | app.use('/api', buildRouter); 30 | 31 | // catch all handler for all unknown routes 32 | app.use((req, res) => { 33 | res.status(404).send('404'); 34 | }); 35 | 36 | // global error handler catches all errors 37 | app.use((err, req, res, next) => { 38 | const defaultErr = { 39 | log: 'Express error handler caught unknown middleware error', 40 | status: 400, 41 | message: { err: 'An error occurred' }, 42 | }; 43 | const errorObj = Object.assign({}, defaultErr, err); 44 | console.log(errorObj.log); 45 | return res.status(errorObj.status).json(errorObj.message); 46 | }); 47 | 48 | app.listen(PORT, () => console.log(`Server listening on port: ${PORT}...`)); 49 | 50 | module.exports = app; 51 | -------------------------------------------------------------------------------- /client/components/HomePage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import '../scss/styles.scss'; 3 | import StartBuild from './StartBuild'; 4 | import SavedBuildsButton from './SavedBuildsButton'; 5 | import LogoutButton from './LogoutButton'; 6 | import { useSelector } from 'react-redux'; 7 | import { Link } from 'react-router-dom'; 8 | import keylogo from '../assets/keylogo.png'; 9 | 10 | 11 | const HomePage = () => { 12 | //Keebuilds home page, if the user is not logged in, the user will be told to login/signup 13 | const username = useSelector(state => state.setUser.username); 14 | const isLoggedIn = useSelector(state => state.setUser.isLoggedIn); 15 | 16 | if (isLoggedIn) { 17 | return ( 18 |
19 |
20 | 21 |

welcome {username} !

22 | 23 |
24 |

KEEBUILDS HOME_

25 | 26 |
27 | 28 |
29 |
30 |
31 |
32 | ); 33 | 34 | } else { 35 | 36 | return ( 37 | <> 38 |
39 |

please login to begin

40 |

KEEBUILDS

41 |
42 | start 43 |
44 | 45 | 46 | ); 47 | } 48 | }; 49 | 50 | export default HomePage; 51 | -------------------------------------------------------------------------------- /client/components/SavedKeebsPage.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import '../scss/styles.scss'; 3 | import axios from 'axios'; 4 | import SavedBuilds from './SavedBuilds'; 5 | import Button from '@mui/material/Button'; 6 | import { Link } from 'react-router-dom'; 7 | import { useSelector } from 'react-redux'; 8 | 9 | const fetchBuilds = async (username) => { 10 | //send username to db, display saved keyboards from user account 11 | const allBuilds = await axios.get(`/api/saved?username=${username}`); 12 | return allBuilds.data; 13 | }; 14 | 15 | const SavedKeebsPage = () => { 16 | const [builds, setBuilds] = React.useState([]); 17 | //if user is not logged in, tell user to login/signup 18 | //state pulled from redux toolkit 19 | const isLoggedIn = useSelector(state => state.setUser.isLoggedIn); 20 | const username = useSelector(state => state.setUser.username); 21 | 22 | const setter = () => { 23 | 24 | fetchBuilds(username) 25 | .then(response => { 26 | //if the fetch query response is not empty, display builds 27 | if(JSON.stringify(response) !== JSON.stringify(builds)) { 28 | setBuilds(response); 29 | } 30 | }); 31 | }; 32 | setter(); 33 | if (isLoggedIn) { 34 | return ( 35 |
36 | 37 | 38 | 39 |

Saved Builds

40 |
41 | 42 |
43 | ); 44 | } else { 45 | return ( 46 | <> 47 |

Your username is {username}

48 |

SAVED KEEBS PAGE

49 | 50 | 51 | ); 52 | } 53 | }; 54 | 55 | export default SavedKeebsPage; -------------------------------------------------------------------------------- /client/components/SavedBuilds.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import '../scss/styles.scss'; 3 | import Button from '@mui/material/Button'; 4 | import axios from 'axios'; 5 | import keyboard100 from '../assets/100keyboard.png'; 6 | import keyboard80 from '../assets/80keyboard.png'; 7 | import keyboard75 from '../assets/75keyboard.png'; 8 | import keyboard65 from '../assets/65keyboard.png'; 9 | import keyboard60 from '../assets/60keyboard.png'; 10 | 11 | 12 | const SavedBuilds = ({builds ,setter}) => { 13 | // retrieve id from parent component props, query database to delete at build_id 14 | const removeBox = (build_id) => { 15 | axios.delete(`/api/build?build_id=${build_id}`) 16 | .then(() =>{ 17 | setter(); 18 | }); 19 | }; 20 | 21 | const sizeImages = { 22 | '100%':keyboard100, 23 | 'TKL': keyboard80, 24 | '75%': keyboard75, 25 | '65%': keyboard65, 26 | '60%': keyboard60, 27 | }; 28 | 29 | const cards = []; 30 | for(const build of builds) { 31 | cards.push( 32 |
33 |
{build.name}
34 |
35 |
36 | 37 | 38 |
PCB: {build.pcb}
39 |
Plate: {build.plate}
40 |
Switch Type: {build.switch}
41 |
Keycaps: {build.keycap}
42 |
43 | 44 |
45 |
46 |
Size: {build.size}
47 | 48 |
49 |
50 |
51 | ); 52 | } 53 | return ( 54 |
55 | {cards} 56 |
57 | ); 58 | }; 59 | 60 | export default SavedBuilds; 61 | -------------------------------------------------------------------------------- /client/components/Signup.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import Button from '@mui/material/Button'; 3 | import { useNavigate } from 'react-router-dom'; 4 | import { useDispatch } from 'react-redux'; 5 | import { changeUserState, setUsername } from '../redux/userSlice'; 6 | import axios from "axios"; 7 | 8 | function Signup() { 9 | const [ message, setMessage ] = useState('Sign Up Here!'); 10 | const navigate = useNavigate(); 11 | const navToHome = () => navigate('/home'); 12 | const dispatch = useDispatch(); 13 | 14 | const handleSubmit = () => { 15 | axios.post('/api/signup', { 16 | username: document.getElementById('user1').value, 17 | password: document.getElementById('pass1').value 18 | }) 19 | .then(verdict => { 20 | if (verdict.data.isLogged) { //if user exists, navigate to homepage 21 | dispatch(changeUserState()); 22 | dispatch(setUsername(document.getElementById('user1').value)); 23 | return navToHome(); 24 | } else { //if user does not exist, display error message 25 | return setMessage('Entered username or password is invalid'); 26 | } 27 | }) 28 | .catch((err) => { 29 | console.log('Error in SignUp handleSubmit: ',err); 30 | return setMessage('Entered username or password is invalid'); 31 | }); 32 | }; 33 | 34 | return ( 35 |
36 |
37 |

{message}

38 |
39 | USERNAME:
40 | PASSWORD: 41 | 42 |
43 |

Already have an account? Login here

44 |
45 |
46 | ); 47 | } 48 | 49 | export default Signup; -------------------------------------------------------------------------------- /server/controllers/loginSignupController.js: -------------------------------------------------------------------------------- 1 | const loginSignupController = {}; 2 | const db = require('../models/keebuildsModel'); 3 | const bcrypt = require('bcrypt'); 4 | const SALT = 10; 5 | 6 | loginSignupController.getUser = async (req, res, next) => { 7 | const { username, password } = req.query; 8 | const command = `SELECT * FROM users WHERE username='${username}';`; 9 | try { 10 | const user = await db.query(command); 11 | if (user.rows.length) { 12 | //use bcrypt to compare hashes without salta 13 | const validPassword = await bcrypt.compare( 14 | password, 15 | user.rows[0].password 16 | ); 17 | res.locals.isLogged = { isLogged: validPassword }; 18 | return next(); 19 | } else { 20 | res.locals.isLogged = { isLogged: false }; 21 | return next(); 22 | } 23 | 24 | } catch (err) { 25 | return next({ log: 'Error in getUser middleware function' }); 26 | } 27 | 28 | }; 29 | 30 | loginSignupController.createUser = async (req, res, next) => { 31 | const { username, password } = req.body; 32 | const command = `SELECT username FROM users WHERE username='${username}';`; 33 | try { 34 | const user = await db.query(command); 35 | if (user.rows.length) { //Checks if database has username 36 | res.locals.isLogged = {isLogged: false }; 37 | return next(); 38 | } else { //Else database does not have username, creates newUser 39 | const salt = await bcrypt.genSalt(Number(SALT)); //hashing password via encrypting 40 | const hashPassword = await bcrypt.hash(password, salt); //you are sending the password. We are hashing password received from req.body with salt. 41 | const newUserCommand = `INSERT INTO users (username, password) VALUES ('${username}', '${hashPassword}');`; 42 | 43 | await db.query(newUserCommand); 44 | 45 | res.locals.isLogged = {isLogged: true }; 46 | return next(); 47 | } 48 | 49 | } catch (err) { 50 | return next({ log: 'Error in createUser middleware function' }); 51 | } 52 | 53 | }; 54 | 55 | module.exports = loginSignupController; 56 | -------------------------------------------------------------------------------- /client/components/Login.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable react/no-unescaped-entities */ 2 | import React, { useState } from 'react'; 3 | import { Box, Button, Avatar, TextField, Grid } from '@mui/material'; 4 | import { Link } from 'react-router-dom'; 5 | import { useNavigate } from 'react-router-dom'; 6 | import { useDispatch } from 'react-redux'; 7 | import { changeUserState, setUsername } from '../redux/userSlice'; 8 | 9 | function Login() { 10 | const [ message, setMessage ] = useState('Log in here!'); 11 | const navigate = useNavigate(); 12 | const navToHome = () => navigate('/home'); 13 | const dispatch = useDispatch(); 14 | 15 | const handleSubmit = () => { 16 | //send a fetch to the backend to authenticate user and the response will be a boolean 17 | fetch(`/api/login/?username=${document.getElementById('user1').value}&password=${document.getElementById('pass1').value}`) 18 | .then(response => response.json()) 19 | //true if user exists in database, false if user does not 20 | .then(verdict => { 21 | if (verdict.isLogged) { //if user exists, navigate to homepage 22 | //set username and isLoggedIn into redux state 23 | dispatch(changeUserState()); 24 | dispatch(setUsername(document.getElementById('user1').value)); 25 | return navToHome(); 26 | } else { //if user does not exist, display error message 27 | return setMessage('Your username/password is incorrect'); 28 | } 29 | }) 30 | .catch(err => console.log(err)); 31 | }; 32 | 33 | return ( 34 |
35 |
36 |

{message}

37 | 38 |
39 | USERNAME:
40 | PASSWORD: 41 | 42 |
43 |

Don't have an account? Sign up here

44 |
45 |
46 | ); 47 | } 48 | 49 | export default Login; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "keebuilds", 3 | "version": "1.0.0", 4 | "description": "app to build the perfect mechanical keyboard!", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "NODE_ENV=production node server/server.js", 8 | "build": "NODE_ENV=production webpack", 9 | "dev": "NODE_ENV=development nodemon server/server.js & NODE_ENV=development webpack serve --open ", 10 | "test": "jest" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/Red-Capped-Keyswitch/keebuilds.git" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC", 19 | "bugs": { 20 | "url": "https://github.com/Red-Capped-Keyswitch/keebuilds/issues" 21 | }, 22 | "homepage": "https://github.com/Red-Capped-Keyswitch/keebuilds#readme", 23 | "devDependencies": { 24 | "@babel/core": "^7.18.13", 25 | "@babel/preset-env": "^7.18.10", 26 | "@babel/preset-react": "^7.18.6", 27 | "@hot-loader/react-dom": "^17.0.2", 28 | "axios": "^0.27.2", 29 | "babel-jest": "^29.0.1", 30 | "babel-loader": "^8.2.5", 31 | "bcrypt": "^5.0.1", 32 | "css-loader": "^6.7.1", 33 | "eslint": "^7.12.1", 34 | "eslint-config-airbnb": "^19.0.4", 35 | "eslint-plugin-react": "^7.21.5", 36 | "html-webpack-plugin": "^5.5.0", 37 | "jest": "^29.0.2", 38 | "node-sass": "^7.0.1", 39 | "nodemon": "^2.0.19", 40 | "pg": "^8.8.0", 41 | "react-router-dom": "^6.3.0", 42 | "sass-loader": "^13.0.2", 43 | "style-loader": "^3.3.1", 44 | "supertest": "^6.2.4", 45 | "url-loader": "^4.1.1", 46 | "webpack": "^5.74.0", 47 | "webpack-cli": "^4.10.0", 48 | "webpack-dev-server": "^4.10.1" 49 | }, 50 | "dependencies": { 51 | "@emotion/react": "^11.10.4", 52 | "@emotion/styled": "^11.10.4", 53 | "@material-ui/core": "^4.12.4", 54 | "@material-ui/icons": "^4.11.3", 55 | "@mui/material": "^5.10.3", 56 | "@reduxjs/toolkit": "^1.8.5", 57 | "cors": "^2.8.5", 58 | "fontsource-roboto": "^4.0.0", 59 | "jest-environment-jsdom": "^29.0.2", 60 | "react": "^17.0.2", 61 | "react-dom": "^17.0.2", 62 | "react-hot-loader": "^4.13.0", 63 | "react-redux": "^8.0.2", 64 | "regenerator-runtime": "^0.13.9" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /.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 | 106 | .cache/ 107 | coverage/ 108 | dist/* 109 | !dist/index.html 110 | node_modules/ 111 | *.log 112 | 113 | # OS generated files 114 | .DS_Store 115 | .DS_Store? 116 | ._* 117 | .Spotlight-V100 118 | .Trashes 119 | ehthumbs.db 120 | Thumbs.db 121 | 122 | build/bundle.js 123 | build/index.html 124 | build/bundle.js.LICENSE.txt 125 | 126 | secrets.js -------------------------------------------------------------------------------- /server/controllers/keebuildsController.js: -------------------------------------------------------------------------------- 1 | const db = require('../models/keebuildsModel'); 2 | 3 | const errorCreator = (methodName, description) => ({ 4 | log: `Error occurred in keebuildsController.${methodName}.\nDescription: ${description}`, 5 | message: `Error occurred in keebuildsController.${methodName}. See server logs for more details.`, 6 | }); 7 | 8 | const keebuildsController = {}; 9 | 10 | keebuildsController.getBuildsForSession = (req, res, next) => { 11 | const query = ` 12 | SELECT 13 | case_type as size, 14 | switches as switch, 15 | users.user_id, 16 | build_name as name, 17 | case_type as size, 18 | pcb, 19 | keycaps as keycap, 20 | plate, 21 | build_id 22 | FROM userFavorites 23 | INNER JOIN users ON userFavorites.user_id = users.user_id 24 | WHERE username = $1 25 | ;`; 26 | const values = [req.query.username]; 27 | db.query(query, values) 28 | .then(response => { 29 | res.locals.builds = response.rows; 30 | return next(); 31 | }) 32 | .catch(err => { 33 | return next({ 34 | log: 'Express error in get builds for session middleware', 35 | status: 500, 36 | message: { 37 | err: 'An error occurred in get builds for session middleware', 38 | }, 39 | }); 40 | }); 41 | }; 42 | 43 | keebuildsController.createBuild = (req, res, next) => { 44 | const { name, size, pcb, plate, keycap, username } = req.body; 45 | const switches = req.body.switch; 46 | const values = [name, size, pcb, plate, switches, keycap, username]; 47 | const query = ` 48 | INSERT INTO userFavorites (build_name, user_id, case_type, pcb, plate, switches, keycaps) 49 | SELECT $1, user_id, $2, $3, $4, $5, $6 50 | FROM users 51 | WHERE username=$7 52 | ;`; 53 | db.query(query, values) 54 | .then(response => { 55 | return next(); 56 | }) 57 | .catch(err => { 58 | return next({ 59 | log: 'Express error caught in create build middleware', 60 | status: 400, 61 | message: { err: 'An error occurred in create build middleware' }, 62 | }); 63 | }); 64 | }; 65 | 66 | keebuildsController.deleteBuild = (req, res, next) => { 67 | const query = 'DELETE FROM userFavorites WHERE build_id=$1'; 68 | const values = [req.query.build_id]; 69 | db.query(query, values) 70 | .then(response => { 71 | return next(); 72 | }) 73 | .catch(() => errorCreator('deleteBuild', 'Failed to DELETE Build')); 74 | }; 75 | 76 | module.exports = keebuildsController; 77 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | mezhmichael@gmail.com 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. -------------------------------------------------------------------------------- /__tests__/server.test.js: -------------------------------------------------------------------------------- 1 | const app = require('../server/server'); 2 | const request = require('supertest'); 3 | 4 | beforeAll(done => { 5 | done() 6 | }); 7 | 8 | afterAll(done => { 9 | done(); 10 | }); 11 | 12 | describe('post-/api/signup', () => { 13 | 14 | test('should respond with a 201 status code', async () => { 15 | const response = await request(app).post('/api/signup').send({ 16 | username: 'username', 17 | password: 'password', 18 | }); 19 | expect(response.statusCode).toBe(201); 20 | }); 21 | 22 | test('content type header should specify json', async () => { 23 | const response = await request(app).post('/api/signup').send({ 24 | username: 'username', 25 | password: 'password', 26 | }); 27 | expect(response.headers['content-type']).toEqual( 28 | expect.stringContaining('json') 29 | ); 30 | }); 31 | 32 | test('response has isLogged property', async () => { 33 | const response = await request(app).post('/api/signup').send({ 34 | username: 'username', 35 | password: 'password', 36 | }); 37 | expect(response.text).toEqual(expect.stringContaining('isLogged')); 38 | }); 39 | 40 | 41 | 42 | test('username is an empty string', async () => { 43 | const response = await request(app).post('/api/signup').send({ 44 | username: '', 45 | password: 'password', 46 | }); 47 | expect(response.text).toEqual(expect.stringContaining('false')); 48 | }); 49 | 50 | test('password is an empty string', async () => { 51 | const response = await request(app).post('/api/signup').send({ 52 | username: 'username', 53 | password: '', 54 | }); 55 | expect(response.text).toEqual(expect.stringContaining('false')); 56 | }); 57 | 58 | test('username already exists', async () => { 59 | const response = await request(app).post('/api/signup').send({ 60 | username: 'dinosaur', 61 | password: 'password', 62 | }); 63 | expect(response.text).toEqual(expect.stringContaining('false')); 64 | }); 65 | }); 66 | 67 | 68 | describe('GET /api/login', () => { 69 | 70 | test('response is in json format', async () => { 71 | const username = 'dinosaur'; 72 | const password = '123'; 73 | const response = await request(app).get( 74 | `/api/login?username=${username}&password=${password}` 75 | ); 76 | expect(response.headers['content-type']).toEqual( 77 | expect.stringContaining('json') 78 | ); 79 | }); 80 | test('response has inLogged property', async () => { 81 | const username = 'dinosaur'; 82 | const password = '123'; 83 | const response = await request(app).get( 84 | `/api/login?username=${username}&password=${password}` 85 | ); 86 | expect(response.text).toEqual(expect.stringContaining('isLogged')); 87 | }); 88 | 89 | 90 | 91 | test('username and password are valid', async () => { 92 | //database contains username and password 93 | //responds with logged in = true state 94 | const username = 'dinosaur'; 95 | const password = '123'; 96 | const response = await request(app).get( 97 | `/api/login?username=${username}&password=${password}` 98 | ); 99 | expect(response.text).toEqual(expect.stringContaining('true')); 100 | }); 101 | 102 | test('password is empty', async () => { 103 | //database contains username and password 104 | //responds with logged in = true state 105 | const username = 'dinosaur'; 106 | const password = ''; 107 | const response = await request(app).get( 108 | `/api/login?username=${username}&password=${password}` 109 | ); 110 | expect(response.text).toEqual(expect.stringContaining('false')); 111 | }); 112 | test('username is empty', async () => { 113 | //database contains username and password 114 | //responds with logged in = true state 115 | const username = ''; 116 | const password = '123'; 117 | const response = await request(app).get( 118 | `/api/login?username=${username}&password=${password}` 119 | ); 120 | expect(response.text).toEqual(expect.stringContaining('false')); 121 | }); 122 | }); 123 | 124 | 125 | describe('POST /api/build', () => { 126 | 127 | test('responds with status code 201', async () => { 128 | const response = await request(app).post('/api/build').send({ 129 | size: '75%', 130 | pcb: 'traditional', 131 | plate: 'aluminum', 132 | switch: 'clicky', 133 | keycap: 'pbt', 134 | name: 'test_build', 135 | username: 'dinosaur', 136 | }); 137 | expect(response.statusCode).toBe(201); 138 | }); 139 | 140 | }); 141 | 142 | 143 | describe('GET /api/saved', () => { 144 | 145 | test('should respond with a 200 status code', async () => { 146 | const response = await request(app) 147 | .get('/api/saved?username=dinosaur') 148 | 149 | expect(response.statusCode).toBe(200) 150 | }) 151 | 152 | test('response should be in json format', async () => { 153 | const response = await request(app) 154 | .get('/api/saved?username=dinosaur') 155 | 156 | expect(response.headers['content-type']).toEqual( 157 | expect.stringContaining('json') 158 | ); 159 | }) 160 | 161 | test('response should have a property builds', async () => { 162 | const response = await request(app) 163 | .get('/api/saved?username=dinosaur') 164 | 165 | expect(response.text).toEqual(expect.stringContaining('size', 'switch', 'user_id', 'name', 'pcb', 'keycap', 'plate', 'build_id')); 166 | }) 167 | 168 | }) 169 | 170 | // describe('delete builds', () => { 171 | // beforeEach(async done => { 172 | // const response = await request(app).post('/api/build').send({ 173 | // size: '75%', 174 | // pcb: 'traditional', 175 | // plate: 'aluminum', 176 | // switch: 'clicky', 177 | // keycap: 'pbt', 178 | // name: 'test_build', 179 | // username: 'dinosaur', 180 | // }); 181 | // //somehow save the build_id from response 182 | // done() 183 | // }); 184 | 185 | 186 | // test('should respond with 200 status code', async() => { 187 | // const resposne = await request(app) 188 | // .delete('/api/build').send({ 189 | // build_id: '', 190 | // }) 191 | // }) 192 | 193 | // test('should delete existing build', async() => { 194 | 195 | // }) 196 | // }) -------------------------------------------------------------------------------- /client/scss/styles.scss: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap'); 2 | @import url('https://fonts.googleapis.com/css2?family=Gloria+Hallelujah&family=Press+Start+2P&display=swap'); 3 | @import url('https://fonts.googleapis.com/css2?family=Concert+One&display=swap'); 4 | @import url('https://fonts.googleapis.com/css2?family=Orbitron&display=swap'); 5 | @import url('https://fonts.googleapis.com/css2?family=Baloo+2&family=Gochi+Hand&family=Rock+Salt&display=swap'); 6 | @import url('https://fonts.googleapis.com/css2?family=Turret+Road:wght@300&display=swap'); 7 | @import url('https://fonts.googleapis.com/css2?family=Walter+Turncoat&display=swap'); 8 | @import url('https://fonts.googleapis.com/css2?family=Swanky+and+Moo+Moo&display=swap'); 9 | @import url('https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap'); 10 | @import url('https://fonts.googleapis.com/css2?family=Shadows+Into+Light&display=swap'); 11 | @import url('https://fonts.googleapis.com/css2?family=Amatic+SC&display=swap'); 12 | @import url('https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap'); 13 | 14 | *{ 15 | font-family: 'Silkscreen', cursive; 16 | } 17 | 18 | body{ 19 | margin: 0; 20 | background-color: lightsteelblue; 21 | } 22 | #root{ 23 | width: 100%; 24 | height: 100% 25 | } 26 | #root > div{ 27 | width: 100%; 28 | height: 100% 29 | } 30 | 31 | #inroot{ 32 | width: 100%; 33 | height: 100%; 34 | display: flex; 35 | flex-direction: column; 36 | align-items: center; 37 | } 38 | 39 | 40 | .center { 41 | display: flex; 42 | justify-content: center; 43 | align-items: center; 44 | height: 60%; 45 | } 46 | 47 | img { 48 | display: flex; 49 | align-items: center; 50 | justify-content: center; 51 | height: 200px; 52 | top: -220px; 53 | left: 90px; 54 | } 55 | 56 | h1 { 57 | justify-content: center; 58 | display: flex; 59 | align-items: center; 60 | color: rgb(65, 91, 152); 61 | font-size: 125px; 62 | margin-block-end: 0; 63 | margin-block-start: 0; 64 | } 65 | 66 | .name { 67 | color: rgb(65, 91, 152); 68 | font-weight: bold; 69 | } 70 | 71 | .size { 72 | display: block; 73 | position: relative; 74 | } 75 | 76 | .savedBuildsContainer{ 77 | display: flex; 78 | justify-content: center; 79 | align-items: center; 80 | } 81 | 82 | .removeButton{ 83 | // float: right; 84 | margin-right: 0; 85 | } 86 | 87 | .savedBuilds { 88 | justify-content: center; 89 | align-items: center; 90 | color: black; 91 | width:1300px; 92 | display: grid; 93 | grid-template-columns: 1fr 1fr; 94 | grid-gap: 20px; 95 | } 96 | 97 | .buildBox { 98 | border: 1px solid black; 99 | text-align: center; 100 | white-space: initial; 101 | font-size: 25px; 102 | word-break: break-all; 103 | height: 250px; 104 | font-family: 'Architects Daughter', cursive; 105 | } 106 | 107 | @keyframes gradient { 108 | 0% { 109 | background-position: 0% 50%; 110 | } 111 | 50% { 112 | background-position: 100% 50%; 113 | } 114 | 100% { 115 | background-position: 0% 50%; 116 | } 117 | } 118 | 119 | .buildBox:hover{ 120 | background: linear-gradient(-45deg, #ee7752, #be356a, #23a6d5, #23d5ab); 121 | background-size: 200% 200%; 122 | animation: gradient 5s ease infinite; 123 | box-shadow: 10px 10px 2px 1px rgba(0, 0, 255, .2); 124 | transform: scale(1.1); 125 | } 126 | 127 | .staricon{ 128 | animation: rotate 2s linear infinite; 129 | display:inline-block; 130 | color: rgb(209, 242, 180); 131 | font-size: 90%; 132 | text-shadow: 6px 9px 8px #dab47f; 133 | border: 4px; 134 | } 135 | .bothDivs{ 136 | display: flex; 137 | justify-content: space-evenly; 138 | 139 | } 140 | 141 | @keyframes rotate { 142 | from{transform:rotateY(0deg)} 143 | 144 | to {transform:rotateY(360deg)} 145 | 146 | } 147 | 148 | .toto { 149 | animation: rotate 6s linear infinite; 150 | display:inline-block; 151 | } 152 | 153 | .landingLoginButton{ 154 | border: 2px solid rgb(235, 177, 177); 155 | border-radius: 15px; 156 | background-color: rgb(209, 242, 180); 157 | padding: 4px 35px; 158 | color:rgb(88, 66, 66); 159 | font-family:'Courier New', Courier, monospace; 160 | text-decoration: none; 161 | margin: 4px; 162 | box-shadow: 10px 10px 2px 1px hsla(240, 100%, 50%, 0.2); 163 | } 164 | .landingLoginButton:hover{ 165 | background-color: #cefcec; 166 | color: white; 167 | 168 | } 169 | 170 | .landingLogo{ 171 | color: rgb(44, 64, 110); 172 | font-family: 'Press Start 2P', cursive; 173 | text-shadow: 6px 9px 8px #dab47f; 174 | font-size: 200%; 175 | } 176 | .loginLink{ 177 | text-decoration: none; 178 | color: #5b5449; 179 | text-shadow: 2px 2px 1px rgba(172, 172, 215, 0.974); 180 | } 181 | 182 | .loginLink:hover{ 183 | color: #dab47f; 184 | text-shadow: 4px 4px 1px rgba(0, 0, 255, .2); 185 | } 186 | .landingLogo2{ 187 | color: rgb(44, 64, 110); 188 | font-family: 'Press Start 2P', cursive; 189 | text-shadow: 6px 9px 8px #dab47f; 190 | font-size: 150%; 191 | } 192 | 193 | .landingLogo3{ 194 | color: rgb(44, 64, 110); 195 | } 196 | 197 | .logo { 198 | margin-left: 30px; 199 | margin-top: 80px; 200 | color: rgb(44, 64, 110); 201 | font-family: 'Press Start 2P', cursive; 202 | text-shadow: 10px 10px 8px #dab47f; 203 | display: flex; 204 | justify-content: center; 205 | align-items: center; 206 | } 207 | 208 | .startBuildButtonDiv { 209 | display: flex; 210 | flex-direction: column; 211 | justify-content: center; 212 | align-items: center; 213 | height: -50%; 214 | margin-top: 25px; 215 | } 216 | 217 | .savedBuildsButtonDiv { 218 | display: flex; 219 | justify-content: center; 220 | align-items: center; 221 | margin-top: 25px; 222 | } 223 | 224 | .savedBuildsButton{ 225 | a:link { text-decoration: none; }; 226 | a:visited { text-decoration: none; }; 227 | a:hover { text-decoration: none; }; 228 | a:active { text-decoration: none; }; 229 | } 230 | 231 | .homeholder{ 232 | a:link { text-decoration: none; }; 233 | a:visited { text-decoration: none; }; 234 | a:hover { text-decoration: none; }; 235 | a:active { text-decoration: none; }; 236 | } 237 | 238 | .logoutButtonDiv { 239 | display: flex; 240 | justify-content: center; 241 | align-items: center; 242 | margin-top: 25px; 243 | } 244 | 245 | .startBuild { 246 | display: flex; 247 | justify-content: center; 248 | align-items: center; 249 | position: relative; 250 | } 251 | 252 | .imageBox{ 253 | display: flex; 254 | flex-direction: column; 255 | justify-content: space-evenly; 256 | align-items: center; 257 | max-width: 100%; 258 | max-height: 100%; 259 | } 260 | 261 | .keebPics{ 262 | max-width: auto; 263 | max-height: auto; 264 | width: 200px; 265 | height: auto; 266 | 267 | } 268 | 269 | #keylogo{ 270 | margin-right: 80px ; 271 | margin-top: 20px; 272 | animation: rotate 10s linear infinite; 273 | } 274 | 275 | 276 | .logSection{ 277 | height:100%; 278 | display: flex; 279 | align-items: center; 280 | justify-content: center; 281 | } 282 | -------------------------------------------------------------------------------- /client/components/StartBuild.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import axios from 'axios'; 3 | import Button from '@mui/material/Button'; 4 | import Dialog from '@mui/material/Dialog'; 5 | import DialogContent from '@mui/material/DialogContent'; 6 | import DialogTitle from '@mui/material/DialogTitle'; 7 | import Box from '@mui/material/Box'; 8 | import Stepper from '@mui/material/Stepper'; 9 | import Step from '@mui/material/Step'; 10 | import StepLabel from '@mui/material/StepLabel'; 11 | import Typography from '@mui/material/Typography'; 12 | import { FormControlLabel } from '@mui/material'; 13 | import Radio from '@mui/material/Radio'; 14 | import RadioGroup from '@mui/material/RadioGroup'; 15 | import FormControl from '@mui/material/FormControl'; 16 | import FormLabel from '@mui/material/FormLabel'; 17 | import TextField from '@mui/material/TextField'; 18 | import '../scss/styles.scss'; 19 | import { useSelector } from 'react-redux'; 20 | 21 | // stepper labels 22 | const steps = ['Case', 'PCB', 'Plate', 'Switches', 'Keycaps', 'Build']; 23 | // radio button groups for each step 24 | const options = [ 25 | ['60%', '65%', '75%', 'TKL', '100%'], 26 | ['Hotswap', 'Traditional'], 27 | ['Polycarbonate', 'Aluminum', 'Brass'], 28 | ['Linear', 'Tactile', 'Clicky'], 29 | ['GMK', 'KAT', 'PBT'] 30 | ]; 31 | 32 | const StartBuild = () => { 33 | // saving state of selected build 34 | const [build, setBuild] = React.useState({ 35 | 0: '', 36 | 1: '', 37 | 2: '', 38 | 3: '', 39 | 4: '', 40 | 5: '' 41 | }); 42 | // state to open and close dialogue form 43 | const [open, setOpen] = React.useState(false); 44 | // state for current step user is on 45 | const [activeStep, setActiveStep] = React.useState(0); 46 | // state for selected value of each radio group 47 | const [value, setValue] = React.useState(''); 48 | // handles opening of dialogue form 49 | const handleClickOpen = () => setOpen(true); 50 | 51 | // handles closing of dialogue form 52 | const handleClose = () => { 53 | setOpen(false); 54 | setActiveStep(0); 55 | setValue(''); 56 | setBuild({ 57 | 0: '', 58 | 1: '', 59 | 2: '', 60 | 3: '', 61 | 4: '', 62 | 5: '' 63 | }); 64 | }; 65 | 66 | const handleNext = () => { 67 | // save current selected value to build state when clicking next 68 | setBuild({ 69 | ...build, 70 | [activeStep]: value.replace('\'', '\'\'') 71 | }); 72 | 73 | setValue(''); 74 | setActiveStep(activeStep + 1); 75 | }; 76 | const username = useSelector(state => state.setUser.username); 77 | // having post request in handleNext doesnt catch last keycap value since state is set once the handleNext function ends 78 | React.useEffect(() => { 79 | // check to have post request run only for completed select 80 | if (build[5] !== '') { 81 | axios 82 | .post('/api/build', { 83 | size: build[0], 84 | pcb: build[1], 85 | plate: build[2], 86 | switch: build[3], 87 | keycap: build[4], 88 | name: build[5], 89 | color: 'blue', 90 | session: 0, 91 | username: username 92 | }); 93 | 94 | // console log for testing post request 95 | // console.log('POST REQUEST: ', { 96 | // size: build[0], 97 | // pcb: build[1], 98 | // plate: build[2], 99 | // switches: build[3], 100 | // keycap: build[4], 101 | // name: build[5], 102 | // color: 'blue', 103 | // session: 0, 104 | // username: username 105 | // }); 106 | } 107 | // do not put check in parameter, will run with extra post request when build[5] changes back to '' 108 | }, [build[5]]); 109 | 110 | const handleBack = () => { 111 | setActiveStep(activeStep - 1); 112 | setValue(''); 113 | }; 114 | 115 | const handleReset = () => { 116 | // closes dialogue form when clicking "close" 117 | setOpen(false); 118 | setActiveStep(0); 119 | setValue(''); 120 | // resets state of build for new build 121 | setBuild({ 122 | 0: '', 123 | 1: '', 124 | 2: '', 125 | 3: '', 126 | 4: '', 127 | 5: '' 128 | }); 129 | }; 130 | 131 | // sets current value for selected radio button 132 | const handleChange = (event) => { 133 | setValue(event.target.value); 134 | }; 135 | 136 | const getContent = (activeStep) => { 137 | // renders radio buttons for each step 138 | if (activeStep !== 5) { 139 | const radios = []; 140 | for (let i = 0; i < options[activeStep].length; i++) { 141 | radios.push( 142 | } label={options[activeStep][i]}/> 143 | ); 144 | } 145 | return radios; 146 | } 147 | // renders input field for build name 148 | return ( 149 | 157 |
158 | 164 |
165 |
166 | ); 167 | }; 168 | 169 | 170 | return ( 171 |
172 | 173 | 174 | Create a new build 175 | 176 |
177 | 178 | 179 | {steps.map(label => { 180 | return ( 181 | 182 | {label} 183 | 184 | ); 185 | })} 186 | 187 | {activeStep === steps.length ? ( 188 | 189 | 190 | Your new build is saved! 191 | 192 | 193 | 194 | 195 | 196 | 197 | ) : ( 198 | 199 | 200 | 201 | {activeStep === 1 ? `Select ${steps[activeStep]}: ` : activeStep === 5 ? 'Name your build!' : `Select ${steps[activeStep].toLowerCase()}: `} 202 | 208 | {getContent(activeStep)} 209 | 210 | 211 | 212 | 213 | 221 | 222 | 225 | 226 | 227 | )} 228 | 229 |
230 |
231 |
232 |
233 | ); 234 | }; 235 | 236 | export default StartBuild; 237 | 238 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | --------------------------------------------------------------------------------