├── server ├── .gitignore ├── package.json ├── index.js └── package-lock.json ├── client ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── readme-files │ └── CYIr3wMAGw.gif ├── src │ ├── Square.js │ ├── setupTests.js │ ├── App.test.js │ ├── index.js │ ├── CountTime.js │ ├── Board.js │ ├── index.css │ ├── WinnersList.js │ ├── serviceWorker.js │ └── App.js ├── .gitignore ├── package.json └── README.md └── README.md /server/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | /node_modules 3 | /records.json 4 | .records.json -------------------------------------------------------------------------------- /client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/david35008/Tic-Tac-Toe-app-server-side-state/HEAD/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/david35008/Tic-Tac-Toe-app-server-side-state/HEAD/client/public/logo192.png -------------------------------------------------------------------------------- /client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/david35008/Tic-Tac-Toe-app-server-side-state/HEAD/client/public/logo512.png -------------------------------------------------------------------------------- /client/readme-files/CYIr3wMAGw.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/david35008/Tic-Tac-Toe-app-server-side-state/HEAD/client/readme-files/CYIr3wMAGw.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tic-tac-toe-React-Nodejs 2 | My first react project. 3 | 4 | Plan, design and implement server side state for the tic-tac-toe app. 5 | 6 | the gif: 7 | ![alt text](./client/readme-files/CYIr3wMAGw.gif) 8 | -------------------------------------------------------------------------------- /client/src/Square.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | function Square(props) { 4 | 5 | 6 | return ( 7 | 10 | ); 11 | } 12 | 13 | export default Square; -------------------------------------------------------------------------------- /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/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /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 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /client/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /client/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /client/src/CountTime.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | 3 | function CountTime({ setSeconds ,isActive, seconds }) { 4 | 5 | useEffect(() => { 6 | let interval = null; 7 | if (isActive) { 8 | interval = setInterval(() => { 9 | setSeconds(seconds => seconds + 1); 10 | }, 1000); 11 | } else if (!isActive && seconds !== 0) { 12 | clearInterval(interval); 13 | } 14 | return () => clearInterval(interval); 15 | }, [isActive, seconds]); 16 | 17 | return ( 18 |
19 | {`${seconds}s`} 20 |
21 | ) 22 | } 23 | 24 | export default CountTime; -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "client", 3 | "version": "0.1.0", 4 | "private": true, 5 | "proxy": "http://localhost:8080", 6 | "dependencies": { 7 | "@material-ui/core": "^4.11.0", 8 | "@testing-library/jest-dom": "^4.2.4", 9 | "@testing-library/react": "^9.5.0", 10 | "@testing-library/user-event": "^7.2.1", 11 | "axios": "^0.19.2", 12 | "react": "^16.13.1", 13 | "react-dom": "^16.13.1", 14 | "react-scripts": "3.4.3", 15 | "react-virtualized": "^9.22.2" 16 | }, 17 | "scripts": { 18 | "start": "react-scripts start", 19 | "build": "react-scripts build", 20 | "test": "react-scripts test", 21 | "eject": "react-scripts eject" 22 | }, 23 | "eslintConfig": { 24 | "extends": "react-app" 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /client/src/Board.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import Square from './Square'; 3 | 4 | function Board(props) { 5 | 6 | return ( 7 | 8 |
9 |
10 | props.onClick(0)} /> 12 | props.onClick(1)} /> 14 | props.onClick(2)} /> 16 |
17 |
18 | props.onClick(3)} /> 20 | props.onClick(4)} /> 22 | props.onClick(5)} /> 24 |
25 |
26 | props.onClick(6)} /> 28 | props.onClick(7)} /> 30 | props.onClick(8)} /> 32 |
33 |
34 | ); 35 | } 36 | 37 | export default Board; -------------------------------------------------------------------------------- /client/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: wheat; 3 | text-align: center; 4 | display: flex; 5 | flex-direction: column; 6 | justify-content: center; 7 | align-content: center; 8 | } 9 | 10 | .board-row:after { 11 | clear: both; 12 | content: ""; 13 | display: table; 14 | } 15 | 16 | .square { 17 | background: #fff; 18 | border: 1px solid #999; 19 | font-size: 80px; 20 | font-weight: bold; 21 | line-height: 10px; 22 | height: 80px; 23 | width: 80px; 24 | float: none; 25 | padding: 0px; 26 | padding-bottom: 24px; 27 | text-align: 0px; 28 | text-align: center; 29 | } 30 | 31 | .square:focus { 32 | outline: none; 33 | } 34 | 35 | .kbd-navigation .square:focus { 36 | background: #ddd; 37 | } 38 | 39 | .game { 40 | 41 | /* flex-direction: column; */ 42 | /* justify-content: space-around; */ 43 | 44 | } 45 | 46 | .game-area { 47 | display: flex; 48 | justify-content: space-around; 49 | /* width: 80%; */ 50 | /* margin: 0px auto 0px auto; */ 51 | } 52 | 53 | .game-board { 54 | margin-right: 95px; 55 | min-width: 240px; 56 | } 57 | /* .game-info { 58 | margin: auto; 59 | } */ 60 | 61 | .winnerList { 62 | text-align: left; 63 | min-width: 175px; 64 | } 65 | 66 | .status { 67 | border: 1px solid #000; 68 | width: 19%; 69 | margin: 5px auto 0px auto; 70 | font-size: 20px; 71 | background-color: lightcyan; 72 | } 73 | 74 | ol { 75 | list-style: none; 76 | } 77 | 78 | .modal { 79 | top: 30%; 80 | left: 30%; 81 | position: absolute; 82 | width: 400; 83 | background-color: white; 84 | border: 2px solid #000; 85 | padding: (2, 4, 3); 86 | } -------------------------------------------------------------------------------- /client/src/WinnersList.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { makeStyles } from '@material-ui/core/styles'; 3 | import List from '@material-ui/core/List'; 4 | import axios from 'axios'; 5 | import ListItem from '@material-ui/core/ListItem'; 6 | import ListItemText from '@material-ui/core/ListItemText'; 7 | import ListSubheader from '@material-ui/core/ListSubheader'; 8 | 9 | const useStyles = makeStyles((theme) => ({ 10 | root: { 11 | // width: '100%', 12 | maxWidth: 300, 13 | minWidth:245, 14 | backgroundColor: theme.palette.background.paper, 15 | // position: 'relative', 16 | overflow: 'auto', 17 | maxHeight: 300, 18 | }, 19 | listSection: { 20 | backgroundColor: 'inherit', 21 | }, 22 | ul: { 23 | backgroundColor: 'inherit', 24 | padding: 0, 25 | }, 26 | })); 27 | 28 | export default function WinnersList({ afterChangeRecordsList, setRecordsUpdated, recordsUpdated }) { 29 | const classes = useStyles(); 30 | if (afterChangeRecordsList.length === 0) { 31 | return (
) 32 | } 33 | return ( 34 | 35 |

Winner List

36 | 37 | { 38 | afterChangeRecordsList.map((winner, i) => ( 39 | 40 | 41 |
    42 |
  • {`Id: ${winner.id}`}
  • 43 |
  • {`Name: ${winner.winnerName}`}
  • 44 |
  • {`Date: ${winner.date}`}
  • 45 |
  • {`GameDuration: ${winner.gameDuration}`}
  • 46 |
47 |
48 | )) 49 | } 50 |
51 | ); 52 | } -------------------------------------------------------------------------------- /client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const fs = require('fs').promises; 3 | const app = express(); 4 | 5 | app.use(express.urlencoded({ extended: true })); 6 | app.use(express.json()); 7 | 8 | app.use('/', express.static('../client/build')); 9 | 10 | let historyMoves = { 11 | "boardHistory": [ 12 | { 13 | "squares": [ 14 | null, 15 | null, 16 | null, 17 | null, 18 | null, 19 | null, 20 | null, 21 | null, 22 | null 23 | ] 24 | } 25 | ], 26 | "stepNumber": 0, 27 | "xIsNext": true 28 | }; 29 | 30 | let seconds = {seconds: 0}; 31 | 32 | app.get("/api/v1/history", (req, res)=> { 33 | res.send(historyMoves); 34 | }); 35 | 36 | app.post("/api/v1/history", (req, res)=> { 37 | historyMoves = req.body 38 | res.send(historyMoves); 39 | }); 40 | 41 | app.put("/api/v1/history", (req, res)=> { 42 | seconds = req.body; 43 | res.send(seconds); 44 | }); 45 | 46 | app.get("/api/v1/records", async (req, res) => { 47 | const content = await fs.readFile('./records.json') 48 | const json = JSON.parse(content); 49 | res.send(json); 50 | }); 51 | 52 | app.post("/api/v1/records",async (req, res) => { 53 | const content = await fs.readFile('./records.json') 54 | let json = JSON.parse(content); 55 | if(json[0].winnerName == "no body") 56 | json = []; 57 | json.push(req.body) 58 | let message = JSON.stringify(json) 59 | await fs.writeFile('./records.json', message) 60 | res.send(json); 61 | 62 | }); 63 | 64 | app.delete("/api/v1/records", async (req,res) => { 65 | await fs.writeFile('./records.json', '[{"id":"1","winnerName":"no body","date":"never","gameDuration":"0"}]') 66 | res.send("deleteed") 67 | }) 68 | 69 | app.get('/', (req, res) => { 70 | res.send('hello'); 71 | }); 72 | 73 | app.listen(8080); -------------------------------------------------------------------------------- /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/App.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import Board from './Board'; 3 | import './index.css'; 4 | import axios from 'axios'; 5 | import Modal from '@material-ui/core/Modal'; 6 | import CountTime from './CountTime'; 7 | import WinnersList from "./WinnersList"; 8 | 9 | function App(props) { 10 | 11 | const [winnerName, setWinnerName] = useState(''); 12 | const [appearance, setAppearance] = useState(false); 13 | const [stepNumber, setStepNumber] = useState(0); 14 | const [xIsNext, setXIsNext] = useState(true); 15 | const [winnersList, setWinnersList] = useState(
  • helloe world
  • ); 16 | const [boardHistory, setBoardHistory] = useState([{ squares: Array(9).fill(null) }]); 17 | const [seconds, setSeconds] = useState(0); 18 | const [isActive, setIsActive] = useState(false); 19 | const [recordsUpdated, setRecordsUpdated] = useState('') 20 | const [afterChangeRecords, setAfterChangeRecords] = useState(['hello', 'you']) 21 | // const [ifRender, setIfRender] = useState(true); 22 | 23 | 24 | 25 | let status; 26 | const modalInText = ( 27 |
    28 |

    Add your name to the records:

    29 |

    write your name and press send

    30 | setWinnerName(capitalize(event.target.value))}> 31 | 32 |
    33 | ); 34 | 35 | let current = boardHistory[boardHistory.length - 1]; 36 | let winner = calculateWinner(current.squares); 37 | 38 | if (winner) { 39 | status = "Winner: " + winner; 40 | } else { 41 | status = "Next player: " + (xIsNext ? "X" : "O"); 42 | } 43 | 44 | const moves = boardHistory.map((step, move) => { 45 | const desc = move ? 46 | 'Go to move #' + move : 47 | 'Start new game'; 48 | return ( 49 |
  • 50 | 51 |
  • 52 | ); 53 | }); 54 | 55 | 56 | 57 | useEffect(() => { 58 | if (winner) { 59 | setIsActive(false); 60 | setAppearance(true); 61 | } else { 62 | setAppearance(false); 63 | } 64 | }, [winner]); 65 | 66 | 67 | 68 | useEffect(() => { 69 | const updateWinnerList = async () => { 70 | let afterChangeRecordsList = await axios.get('/api/v1/records') 71 | .then(res => res.data) 72 | .catch(error => error); 73 | setAfterChangeRecords(afterChangeRecordsList); 74 | let recordsListContainer = []; 75 | afterChangeRecordsList.forEach(element => { 76 | recordsListContainer.push( 77 |
  • 78 |
    Name: {element.winnerName}
    79 |
    Date: {element.date}
    80 |
    Game duration: {element.gameDuration}s
    81 |
  • 82 | ) 83 | }); 84 | setWinnersList(recordsListContainer) 85 | } 86 | updateWinnerList() 87 | 88 | }, []); 89 | 90 | useEffect(() => { 91 | const updateWinnerList = async () => { 92 | let afterChangeRecordsList = await axios.get('/api/v1/records') 93 | .then(res => res.data) 94 | .catch(error => error); 95 | setAfterChangeRecords(afterChangeRecordsList); 96 | let recordsListContainer = []; 97 | afterChangeRecordsList.forEach(element => { 98 | recordsListContainer.push( 99 |
  • 100 |
    Name: {element.winnerName}
    101 |
    Date: {element.date}
    102 |
    Game duration: {element.gameDuration}s
    103 |
  • 104 | ) 105 | }); 106 | setWinnersList(recordsListContainer) 107 | } 108 | updateWinnerList() 109 | 110 | }, [winner, recordsUpdated]); 111 | 112 | useEffect(() => { 113 | const loadData = async () => { 114 | const result = await axios.get(`/api/v1/history`); 115 | setBoardHistory(result.data.boardHistory); 116 | setStepNumber(result.data.stepNumber) 117 | setXIsNext(result.data.xIsNext) 118 | }; 119 | loadData(); 120 | }, []); 121 | 122 | const fetchData = async () => { 123 | const result = await axios.get(`/api/v1/history`); 124 | // const updatedSeconds = await axios.put(`/api/v1/history`, { seconds }) 125 | if (winner) { 126 | setIsActive(false); 127 | } else if (stepNumber > 0 && !winner) { setIsActive(true) } 128 | // setSeconds(updatedSeconds.data.seconds + 1) 129 | setBoardHistory(result.data.boardHistory); 130 | setStepNumber(result.data.stepNumber) 131 | setXIsNext(result.data.xIsNext) 132 | } 133 | 134 | // useEffect(() => { 135 | // setTimeout(() => { 136 | 137 | 138 | // setRecordsUpdated(recordsUpdated + 1); 139 | // }, 500) 140 | // }); 141 | 142 | useEffect(() => { 143 | let interval = null; 144 | if (!winner) { 145 | interval = setInterval(() => { 146 | fetchData(); 147 | }, 500); 148 | } 149 | }, [true]); 150 | 151 | 152 | const capitalize = (string) => { 153 | if (typeof string === typeof "") { 154 | let newString = string.charAt(0).toUpperCase() + string.slice(1); 155 | return newString 156 | } 157 | } 158 | 159 | const jumpTo = (step) => { 160 | let localSeconds = seconds 161 | if (step == 0) { setSeconds(0); localSeconds = 0 } 162 | serverHistoryHandler({ boardHistory: boardHistory.slice(0, step + 1), stepNumber: step, xIsNext: (step % 2) === 0, seconds: localSeconds }) 163 | } 164 | 165 | const formatDate = (date) => { 166 | const pad = (num) => { return ('00' + num).slice(-2) } 167 | let dateStr = date.getUTCFullYear() + '-' + 168 | pad(date.getUTCMonth() + 1) + '-' + 169 | pad(date.getUTCDate()) + ' ' + 170 | pad(date.getUTCHours() + 3) + ':' + 171 | pad(date.getUTCMinutes()) + ':' + 172 | pad(date.getUTCSeconds()); 173 | return dateStr; 174 | }; 175 | 176 | const handleClick = (i) => { 177 | setIsActive(true) 178 | current = boardHistory[boardHistory.length - 1]; 179 | let squares = current.squares.slice(); 180 | if (calculateWinner(squares) || squares[i]) { 181 | return; 182 | } 183 | squares[i] = xIsNext ? "x" : "o"; 184 | let cloneHistory = boardHistory.slice(); 185 | serverHistoryHandler({ boardHistory: boardHistory.concat([{ squares }]), stepNumber: cloneHistory.length, xIsNext: !xIsNext, seconds: seconds + 1 }) 186 | } 187 | 188 | const serverHistoryHandler = (infomation) => { 189 | return axios.post('/api/v1/history', infomation) 190 | .then(res => res.data) 191 | } 192 | 193 | const declareRecords = async () => { 194 | let recordsList = await axios.get('/api/v1/records') 195 | .then(res => res.data) 196 | .catch(error => error); 197 | let current = recordsList.length + 1; 198 | debugger 199 | if(recordsList[0].winnerName == "no body") { 200 | current = recordsList.length 201 | } 202 | let message = { 203 | "id": `${current}`, 204 | "winnerName": `${winnerName}`, 205 | "date": `${formatDate(new Date())}`, 206 | "gameDuration": `${seconds}` 207 | } 208 | let afterChangeRecordsList = await axios.post('/api/v1/records', message) 209 | .then(res => res.data) 210 | .catch(error => error); 211 | let recordsListContainer = []; 212 | afterChangeRecordsList.forEach(element => { 213 | recordsListContainer.push( 214 |
  • 215 |
    Name: {element.winnerName}
    216 |
    Date: {element.date}
    217 |
    Game duration: {element.gameDuration}s
    218 |
  • 219 | ) 220 | }); 221 | serverHistoryHandler({ boardHistory: [{ squares: Array(9).fill(null) }], stepNumber: 0, xIsNext: true, seconds: seconds }) 222 | setWinnersList(recordsListContainer) 223 | setAppearance(false); 224 | setSeconds(0); 225 | } 226 | 227 | function calculateWinner(squares) { 228 | const lines = [ 229 | [0, 1, 2], 230 | [3, 4, 5], 231 | [6, 7, 8], 232 | [0, 3, 6], 233 | [1, 4, 7], 234 | [2, 5, 8], 235 | [0, 4, 8], 236 | [2, 4, 6] 237 | ]; 238 | for (let i = 0; i < lines.length; i++) { 239 | const [a, b, c] = lines[i]; 240 | if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) { 241 | return squares[a]; 242 | } 243 | } 244 | return null; 245 | } 246 | 247 | return ( 248 |
    249 |

    Tic Tac Toe

    250 |

    Game timer:

    251 |
    {status}
    252 |
    253 | setAppearance(false)} 256 | aria-labelledby="simple-modal-title" 257 | aria-describedby="simple-modal-description" 258 | > 259 | {modalInText} 260 | 261 | {/* {typeof (winnersList) !== typeof ('') && 262 |
      263 | 264 | {winnersList}
    } */} 265 | 266 |
    267 | handleClick(i)} 270 | /> 271 |
    272 |
    273 | 274 |
      {moves}
    275 |
    276 | 277 |
    278 |
    279 | ); 280 | } 281 | 282 | export default App; -------------------------------------------------------------------------------- /server/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "accepts": { 8 | "version": "1.3.7", 9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", 10 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", 11 | "requires": { 12 | "mime-types": "~2.1.24", 13 | "negotiator": "0.6.2" 14 | } 15 | }, 16 | "array-flatten": { 17 | "version": "1.1.1", 18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 20 | }, 21 | "body-parser": { 22 | "version": "1.19.0", 23 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", 24 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", 25 | "requires": { 26 | "bytes": "3.1.0", 27 | "content-type": "~1.0.4", 28 | "debug": "2.6.9", 29 | "depd": "~1.1.2", 30 | "http-errors": "1.7.2", 31 | "iconv-lite": "0.4.24", 32 | "on-finished": "~2.3.0", 33 | "qs": "6.7.0", 34 | "raw-body": "2.4.0", 35 | "type-is": "~1.6.17" 36 | } 37 | }, 38 | "bytes": { 39 | "version": "3.1.0", 40 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", 41 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" 42 | }, 43 | "content-disposition": { 44 | "version": "0.5.3", 45 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", 46 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", 47 | "requires": { 48 | "safe-buffer": "5.1.2" 49 | } 50 | }, 51 | "content-type": { 52 | "version": "1.0.4", 53 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 54 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 55 | }, 56 | "cookie": { 57 | "version": "0.4.0", 58 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", 59 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" 60 | }, 61 | "cookie-signature": { 62 | "version": "1.0.6", 63 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 64 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 65 | }, 66 | "debug": { 67 | "version": "2.6.9", 68 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 69 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 70 | "requires": { 71 | "ms": "2.0.0" 72 | } 73 | }, 74 | "depd": { 75 | "version": "1.1.2", 76 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 77 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 78 | }, 79 | "destroy": { 80 | "version": "1.0.4", 81 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 82 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 83 | }, 84 | "ee-first": { 85 | "version": "1.1.1", 86 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 87 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 88 | }, 89 | "encodeurl": { 90 | "version": "1.0.2", 91 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 92 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 93 | }, 94 | "escape-html": { 95 | "version": "1.0.3", 96 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 97 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 98 | }, 99 | "etag": { 100 | "version": "1.8.1", 101 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 102 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 103 | }, 104 | "express": { 105 | "version": "4.17.1", 106 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", 107 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", 108 | "requires": { 109 | "accepts": "~1.3.7", 110 | "array-flatten": "1.1.1", 111 | "body-parser": "1.19.0", 112 | "content-disposition": "0.5.3", 113 | "content-type": "~1.0.4", 114 | "cookie": "0.4.0", 115 | "cookie-signature": "1.0.6", 116 | "debug": "2.6.9", 117 | "depd": "~1.1.2", 118 | "encodeurl": "~1.0.2", 119 | "escape-html": "~1.0.3", 120 | "etag": "~1.8.1", 121 | "finalhandler": "~1.1.2", 122 | "fresh": "0.5.2", 123 | "merge-descriptors": "1.0.1", 124 | "methods": "~1.1.2", 125 | "on-finished": "~2.3.0", 126 | "parseurl": "~1.3.3", 127 | "path-to-regexp": "0.1.7", 128 | "proxy-addr": "~2.0.5", 129 | "qs": "6.7.0", 130 | "range-parser": "~1.2.1", 131 | "safe-buffer": "5.1.2", 132 | "send": "0.17.1", 133 | "serve-static": "1.14.1", 134 | "setprototypeof": "1.1.1", 135 | "statuses": "~1.5.0", 136 | "type-is": "~1.6.18", 137 | "utils-merge": "1.0.1", 138 | "vary": "~1.1.2" 139 | } 140 | }, 141 | "finalhandler": { 142 | "version": "1.1.2", 143 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", 144 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", 145 | "requires": { 146 | "debug": "2.6.9", 147 | "encodeurl": "~1.0.2", 148 | "escape-html": "~1.0.3", 149 | "on-finished": "~2.3.0", 150 | "parseurl": "~1.3.3", 151 | "statuses": "~1.5.0", 152 | "unpipe": "~1.0.0" 153 | } 154 | }, 155 | "forwarded": { 156 | "version": "0.1.2", 157 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 158 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 159 | }, 160 | "fresh": { 161 | "version": "0.5.2", 162 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 163 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 164 | }, 165 | "http-errors": { 166 | "version": "1.7.2", 167 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", 168 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", 169 | "requires": { 170 | "depd": "~1.1.2", 171 | "inherits": "2.0.3", 172 | "setprototypeof": "1.1.1", 173 | "statuses": ">= 1.5.0 < 2", 174 | "toidentifier": "1.0.0" 175 | } 176 | }, 177 | "iconv-lite": { 178 | "version": "0.4.24", 179 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 180 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 181 | "requires": { 182 | "safer-buffer": ">= 2.1.2 < 3" 183 | } 184 | }, 185 | "inherits": { 186 | "version": "2.0.3", 187 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 188 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 189 | }, 190 | "ipaddr.js": { 191 | "version": "1.9.1", 192 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 193 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" 194 | }, 195 | "media-typer": { 196 | "version": "0.3.0", 197 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 198 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 199 | }, 200 | "merge-descriptors": { 201 | "version": "1.0.1", 202 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 203 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 204 | }, 205 | "methods": { 206 | "version": "1.1.2", 207 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 208 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 209 | }, 210 | "mime": { 211 | "version": "1.6.0", 212 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 213 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" 214 | }, 215 | "mime-db": { 216 | "version": "1.44.0", 217 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", 218 | "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" 219 | }, 220 | "mime-types": { 221 | "version": "2.1.27", 222 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", 223 | "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", 224 | "requires": { 225 | "mime-db": "1.44.0" 226 | } 227 | }, 228 | "ms": { 229 | "version": "2.0.0", 230 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 231 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 232 | }, 233 | "negotiator": { 234 | "version": "0.6.2", 235 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 236 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 237 | }, 238 | "on-finished": { 239 | "version": "2.3.0", 240 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 241 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 242 | "requires": { 243 | "ee-first": "1.1.1" 244 | } 245 | }, 246 | "parseurl": { 247 | "version": "1.3.3", 248 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 249 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 250 | }, 251 | "path-to-regexp": { 252 | "version": "0.1.7", 253 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 254 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 255 | }, 256 | "proxy-addr": { 257 | "version": "2.0.6", 258 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", 259 | "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", 260 | "requires": { 261 | "forwarded": "~0.1.2", 262 | "ipaddr.js": "1.9.1" 263 | } 264 | }, 265 | "qs": { 266 | "version": "6.7.0", 267 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", 268 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" 269 | }, 270 | "range-parser": { 271 | "version": "1.2.1", 272 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 273 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" 274 | }, 275 | "raw-body": { 276 | "version": "2.4.0", 277 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", 278 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", 279 | "requires": { 280 | "bytes": "3.1.0", 281 | "http-errors": "1.7.2", 282 | "iconv-lite": "0.4.24", 283 | "unpipe": "1.0.0" 284 | } 285 | }, 286 | "safe-buffer": { 287 | "version": "5.1.2", 288 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 289 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 290 | }, 291 | "safer-buffer": { 292 | "version": "2.1.2", 293 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 294 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 295 | }, 296 | "send": { 297 | "version": "0.17.1", 298 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", 299 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", 300 | "requires": { 301 | "debug": "2.6.9", 302 | "depd": "~1.1.2", 303 | "destroy": "~1.0.4", 304 | "encodeurl": "~1.0.2", 305 | "escape-html": "~1.0.3", 306 | "etag": "~1.8.1", 307 | "fresh": "0.5.2", 308 | "http-errors": "~1.7.2", 309 | "mime": "1.6.0", 310 | "ms": "2.1.1", 311 | "on-finished": "~2.3.0", 312 | "range-parser": "~1.2.1", 313 | "statuses": "~1.5.0" 314 | }, 315 | "dependencies": { 316 | "ms": { 317 | "version": "2.1.1", 318 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 319 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" 320 | } 321 | } 322 | }, 323 | "serve-static": { 324 | "version": "1.14.1", 325 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", 326 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", 327 | "requires": { 328 | "encodeurl": "~1.0.2", 329 | "escape-html": "~1.0.3", 330 | "parseurl": "~1.3.3", 331 | "send": "0.17.1" 332 | } 333 | }, 334 | "setprototypeof": { 335 | "version": "1.1.1", 336 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", 337 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" 338 | }, 339 | "statuses": { 340 | "version": "1.5.0", 341 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 342 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" 343 | }, 344 | "toidentifier": { 345 | "version": "1.0.0", 346 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", 347 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" 348 | }, 349 | "type-is": { 350 | "version": "1.6.18", 351 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 352 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 353 | "requires": { 354 | "media-typer": "0.3.0", 355 | "mime-types": "~2.1.24" 356 | } 357 | }, 358 | "unpipe": { 359 | "version": "1.0.0", 360 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 361 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 362 | }, 363 | "utils-merge": { 364 | "version": "1.0.1", 365 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 366 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 367 | }, 368 | "vary": { 369 | "version": "1.1.2", 370 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 371 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 372 | } 373 | } 374 | } 375 | --------------------------------------------------------------------------------