├── README.md ├── client ├── .gitignore ├── README.md ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt ├── src │ ├── App.css │ ├── App.js │ ├── components │ │ ├── EditTodo.js │ │ ├── InputTodo.js │ │ └── ListTodos.js │ ├── index.css │ └── index.js └── yarn.lock └── server ├── .gitignore ├── database.sql ├── db.js ├── index.js ├── package-lock.json └── package.json /README.md: -------------------------------------------------------------------------------- 1 | # pern-todo-app 2 | 3 | 4 | 5 | https://www.youtube.com/watch?v=ldYcgPKEZC8 6 | -------------------------------------------------------------------------------- /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/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 | ### `yarn 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 | ### `yarn 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 | ### `yarn 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 | ### `yarn 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 | ### `yarn 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/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "client", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "react": "^16.13.0", 10 | "react-dom": "^16.13.0", 11 | "react-scripts": "3.4.0" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ousecTic/pern-todo-app/feb4b26b1548081be471f77037370c0e9a364b73/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 24 | 33 | React App 34 | 35 | 36 | 37 |
38 | 48 | 53 | 58 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ousecTic/pern-todo-app/feb4b26b1548081be471f77037370c0e9a364b73/client/public/logo192.png -------------------------------------------------------------------------------- /client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ousecTic/pern-todo-app/feb4b26b1548081be471f77037370c0e9a364b73/client/public/logo512.png -------------------------------------------------------------------------------- /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/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /client/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /client/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from "react"; 2 | import "./App.css"; 3 | 4 | //components 5 | 6 | import InputTodo from "./components/InputTodo"; 7 | import ListTodos from "./components/ListTodos"; 8 | 9 | function App() { 10 | return ( 11 | 12 |
13 | 14 | 15 |
16 |
17 | ); 18 | } 19 | 20 | export default App; 21 | -------------------------------------------------------------------------------- /client/src/components/EditTodo.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useState } from "react"; 2 | 3 | const EditTodo = ({ todo }) => { 4 | const [description, setDescription] = useState(todo.description); 5 | 6 | //edit description function 7 | 8 | const updateDescription = async e => { 9 | e.preventDefault(); 10 | try { 11 | const body = { description }; 12 | const response = await fetch( 13 | `http://localhost:5000/todos/${todo.todo_id}`, 14 | { 15 | method: "PUT", 16 | headers: { "Content-Type": "application/json" }, 17 | body: JSON.stringify(body) 18 | } 19 | ); 20 | 21 | window.location = "/"; 22 | } catch (err) { 23 | console.error(err.message); 24 | } 25 | }; 26 | 27 | return ( 28 | 29 | 37 | 38 | {/* 39 | id = id10 40 | */} 41 | 90 | 91 | ); 92 | }; 93 | 94 | export default EditTodo; 95 | -------------------------------------------------------------------------------- /client/src/components/InputTodo.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useState } from "react"; 2 | 3 | const InputTodo = () => { 4 | const [description, setDescription] = useState(""); 5 | 6 | const onSubmitForm = async e => { 7 | e.preventDefault(); 8 | try { 9 | const body = { description }; 10 | const response = await fetch("http://localhost:5000/todos", { 11 | method: "POST", 12 | headers: { "Content-Type": "application/json" }, 13 | body: JSON.stringify(body) 14 | }); 15 | 16 | window.location = "/"; 17 | } catch (err) { 18 | console.error(err.message); 19 | } 20 | }; 21 | 22 | return ( 23 | 24 |

Pern Todo List

25 |
26 | setDescription(e.target.value)} 31 | /> 32 | 33 |
34 |
35 | ); 36 | }; 37 | 38 | export default InputTodo; 39 | -------------------------------------------------------------------------------- /client/src/components/ListTodos.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useEffect, useState } from "react"; 2 | 3 | import EditTodo from "./EditTodo"; 4 | 5 | const ListTodos = () => { 6 | const [todos, setTodos] = useState([]); 7 | 8 | //delete todo function 9 | 10 | const deleteTodo = async id => { 11 | try { 12 | const deleteTodo = await fetch(`http://localhost:5000/todos/${id}`, { 13 | method: "DELETE" 14 | }); 15 | 16 | setTodos(todos.filter(todo => todo.todo_id !== id)); 17 | } catch (err) { 18 | console.error(err.message); 19 | } 20 | }; 21 | 22 | const getTodos = async () => { 23 | try { 24 | const response = await fetch("http://localhost:5000/todos"); 25 | const jsonData = await response.json(); 26 | 27 | setTodos(jsonData); 28 | } catch (err) { 29 | console.error(err.message); 30 | } 31 | }; 32 | 33 | useEffect(() => { 34 | getTodos(); 35 | }, []); 36 | 37 | console.log(todos); 38 | 39 | return ( 40 | 41 | {" "} 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {/* 52 | 53 | 54 | 55 | */} 56 | {todos.map(todo => ( 57 | 58 | 59 | 62 | 70 | 71 | ))} 72 | 73 |
DescriptionEditDelete
JohnDoejohn@example.com
{todo.description} 60 | 61 | 63 | 69 |
74 |
75 | ); 76 | }; 77 | 78 | export default ListTodos; 79 | -------------------------------------------------------------------------------- /client/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /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 | 6 | ReactDOM.render(, document.getElementById("root")); 7 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /server/database.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE perntodo; 2 | 3 | CREATE TABLE todo( 4 | todo_id SERIAL PRIMARY KEY, 5 | description VARCHAR(255) 6 | ); -------------------------------------------------------------------------------- /server/db.js: -------------------------------------------------------------------------------- 1 | const Pool = require("pg").Pool; 2 | 3 | const pool = new Pool({ 4 | user: "postgres", 5 | password: "kthl8822", 6 | host: "localhost", 7 | port: 5432, 8 | database: "perntodo" 9 | }); 10 | 11 | module.exports = pool; 12 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const app = express(); 3 | const cors = require("cors"); 4 | const pool = require("./db"); 5 | 6 | //middleware 7 | app.use(cors()); 8 | app.use(express.json()); //req.body 9 | 10 | //ROUTES// 11 | 12 | //create a todo 13 | 14 | app.post("/todos", async (req, res) => { 15 | try { 16 | const { description } = req.body; 17 | const newTodo = await pool.query( 18 | "INSERT INTO todo (description) VALUES($1) RETURNING *", 19 | [description] 20 | ); 21 | 22 | res.json(newTodo.rows[0]); 23 | } catch (err) { 24 | console.error(err.message); 25 | } 26 | }); 27 | 28 | //get all todos 29 | 30 | app.get("/todos", async (req, res) => { 31 | try { 32 | const allTodos = await pool.query("SELECT * FROM todo"); 33 | res.json(allTodos.rows); 34 | } catch (err) { 35 | console.error(err.message); 36 | } 37 | }); 38 | 39 | //get a todo 40 | 41 | app.get("/todos/:id", async (req, res) => { 42 | try { 43 | const { id } = req.params; 44 | const todo = await pool.query("SELECT * FROM todo WHERE todo_id = $1", [ 45 | id 46 | ]); 47 | 48 | res.json(todo.rows[0]); 49 | } catch (err) { 50 | console.error(err.message); 51 | } 52 | }); 53 | 54 | //update a todo 55 | 56 | app.put("/todos/:id", async (req, res) => { 57 | try { 58 | const { id } = req.params; 59 | const { description } = req.body; 60 | const updateTodo = await pool.query( 61 | "UPDATE todo SET description = $1 WHERE todo_id = $2", 62 | [description, id] 63 | ); 64 | 65 | res.json("Todo was updated!"); 66 | } catch (err) { 67 | console.error(err.message); 68 | } 69 | }); 70 | 71 | //delete a todo 72 | 73 | app.delete("/todos/:id", async (req, res) => { 74 | try { 75 | const { id } = req.params; 76 | const deleteTodo = await pool.query("DELETE FROM todo WHERE todo_id = $1", [ 77 | id 78 | ]); 79 | res.json("Todo was deleted!"); 80 | } catch (err) { 81 | console.log(err.message); 82 | } 83 | }); 84 | 85 | app.listen(5000, () => { 86 | console.log("server has started on port 5000"); 87 | }); 88 | -------------------------------------------------------------------------------- /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 | "buffer-writer": { 39 | "version": "2.0.0", 40 | "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", 41 | "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==" 42 | }, 43 | "bytes": { 44 | "version": "3.1.0", 45 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", 46 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" 47 | }, 48 | "content-disposition": { 49 | "version": "0.5.3", 50 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", 51 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", 52 | "requires": { 53 | "safe-buffer": "5.1.2" 54 | } 55 | }, 56 | "content-type": { 57 | "version": "1.0.4", 58 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 59 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 60 | }, 61 | "cookie": { 62 | "version": "0.4.0", 63 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", 64 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" 65 | }, 66 | "cookie-signature": { 67 | "version": "1.0.6", 68 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 69 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 70 | }, 71 | "cors": { 72 | "version": "2.8.5", 73 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 74 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 75 | "requires": { 76 | "object-assign": "^4", 77 | "vary": "^1" 78 | } 79 | }, 80 | "debug": { 81 | "version": "2.6.9", 82 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 83 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 84 | "requires": { 85 | "ms": "2.0.0" 86 | } 87 | }, 88 | "depd": { 89 | "version": "1.1.2", 90 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 91 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 92 | }, 93 | "destroy": { 94 | "version": "1.0.4", 95 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 96 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 97 | }, 98 | "ee-first": { 99 | "version": "1.1.1", 100 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 101 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 102 | }, 103 | "encodeurl": { 104 | "version": "1.0.2", 105 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 106 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 107 | }, 108 | "escape-html": { 109 | "version": "1.0.3", 110 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 111 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 112 | }, 113 | "etag": { 114 | "version": "1.8.1", 115 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 116 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 117 | }, 118 | "express": { 119 | "version": "4.17.1", 120 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", 121 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", 122 | "requires": { 123 | "accepts": "~1.3.7", 124 | "array-flatten": "1.1.1", 125 | "body-parser": "1.19.0", 126 | "content-disposition": "0.5.3", 127 | "content-type": "~1.0.4", 128 | "cookie": "0.4.0", 129 | "cookie-signature": "1.0.6", 130 | "debug": "2.6.9", 131 | "depd": "~1.1.2", 132 | "encodeurl": "~1.0.2", 133 | "escape-html": "~1.0.3", 134 | "etag": "~1.8.1", 135 | "finalhandler": "~1.1.2", 136 | "fresh": "0.5.2", 137 | "merge-descriptors": "1.0.1", 138 | "methods": "~1.1.2", 139 | "on-finished": "~2.3.0", 140 | "parseurl": "~1.3.3", 141 | "path-to-regexp": "0.1.7", 142 | "proxy-addr": "~2.0.5", 143 | "qs": "6.7.0", 144 | "range-parser": "~1.2.1", 145 | "safe-buffer": "5.1.2", 146 | "send": "0.17.1", 147 | "serve-static": "1.14.1", 148 | "setprototypeof": "1.1.1", 149 | "statuses": "~1.5.0", 150 | "type-is": "~1.6.18", 151 | "utils-merge": "1.0.1", 152 | "vary": "~1.1.2" 153 | } 154 | }, 155 | "finalhandler": { 156 | "version": "1.1.2", 157 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", 158 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", 159 | "requires": { 160 | "debug": "2.6.9", 161 | "encodeurl": "~1.0.2", 162 | "escape-html": "~1.0.3", 163 | "on-finished": "~2.3.0", 164 | "parseurl": "~1.3.3", 165 | "statuses": "~1.5.0", 166 | "unpipe": "~1.0.0" 167 | } 168 | }, 169 | "forwarded": { 170 | "version": "0.1.2", 171 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 172 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 173 | }, 174 | "fresh": { 175 | "version": "0.5.2", 176 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 177 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 178 | }, 179 | "http-errors": { 180 | "version": "1.7.2", 181 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", 182 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", 183 | "requires": { 184 | "depd": "~1.1.2", 185 | "inherits": "2.0.3", 186 | "setprototypeof": "1.1.1", 187 | "statuses": ">= 1.5.0 < 2", 188 | "toidentifier": "1.0.0" 189 | } 190 | }, 191 | "iconv-lite": { 192 | "version": "0.4.24", 193 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 194 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 195 | "requires": { 196 | "safer-buffer": ">= 2.1.2 < 3" 197 | } 198 | }, 199 | "inherits": { 200 | "version": "2.0.3", 201 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 202 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 203 | }, 204 | "ipaddr.js": { 205 | "version": "1.9.1", 206 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 207 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" 208 | }, 209 | "media-typer": { 210 | "version": "0.3.0", 211 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 212 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 213 | }, 214 | "merge-descriptors": { 215 | "version": "1.0.1", 216 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 217 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 218 | }, 219 | "methods": { 220 | "version": "1.1.2", 221 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 222 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 223 | }, 224 | "mime": { 225 | "version": "1.6.0", 226 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 227 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" 228 | }, 229 | "mime-db": { 230 | "version": "1.43.0", 231 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", 232 | "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" 233 | }, 234 | "mime-types": { 235 | "version": "2.1.26", 236 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", 237 | "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", 238 | "requires": { 239 | "mime-db": "1.43.0" 240 | } 241 | }, 242 | "ms": { 243 | "version": "2.0.0", 244 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 245 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 246 | }, 247 | "negotiator": { 248 | "version": "0.6.2", 249 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 250 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 251 | }, 252 | "object-assign": { 253 | "version": "4.1.1", 254 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 255 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 256 | }, 257 | "on-finished": { 258 | "version": "2.3.0", 259 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 260 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 261 | "requires": { 262 | "ee-first": "1.1.1" 263 | } 264 | }, 265 | "packet-reader": { 266 | "version": "1.0.0", 267 | "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", 268 | "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" 269 | }, 270 | "parseurl": { 271 | "version": "1.3.3", 272 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 273 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 274 | }, 275 | "path-to-regexp": { 276 | "version": "0.1.7", 277 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 278 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 279 | }, 280 | "pg": { 281 | "version": "7.18.2", 282 | "resolved": "https://registry.npmjs.org/pg/-/pg-7.18.2.tgz", 283 | "integrity": "sha512-Mvt0dGYMwvEADNKy5PMQGlzPudKcKKzJds/VbOeZJpb6f/pI3mmoXX0JksPgI3l3JPP/2Apq7F36O63J7mgveA==", 284 | "requires": { 285 | "buffer-writer": "2.0.0", 286 | "packet-reader": "1.0.0", 287 | "pg-connection-string": "0.1.3", 288 | "pg-packet-stream": "^1.1.0", 289 | "pg-pool": "^2.0.10", 290 | "pg-types": "^2.1.0", 291 | "pgpass": "1.x", 292 | "semver": "4.3.2" 293 | } 294 | }, 295 | "pg-connection-string": { 296 | "version": "0.1.3", 297 | "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz", 298 | "integrity": "sha1-2hhHsglA5C7hSSvq9l1J2RskXfc=" 299 | }, 300 | "pg-int8": { 301 | "version": "1.0.1", 302 | "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", 303 | "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" 304 | }, 305 | "pg-packet-stream": { 306 | "version": "1.1.0", 307 | "resolved": "https://registry.npmjs.org/pg-packet-stream/-/pg-packet-stream-1.1.0.tgz", 308 | "integrity": "sha512-kRBH0tDIW/8lfnnOyTwKD23ygJ/kexQVXZs7gEyBljw4FYqimZFxnMMx50ndZ8In77QgfGuItS5LLclC2TtjYg==" 309 | }, 310 | "pg-pool": { 311 | "version": "2.0.10", 312 | "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.10.tgz", 313 | "integrity": "sha512-qdwzY92bHf3nwzIUcj+zJ0Qo5lpG/YxchahxIN8+ZVmXqkahKXsnl2aiJPHLYN9o5mB/leG+Xh6XKxtP7e0sjg==" 314 | }, 315 | "pg-types": { 316 | "version": "2.2.0", 317 | "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", 318 | "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", 319 | "requires": { 320 | "pg-int8": "1.0.1", 321 | "postgres-array": "~2.0.0", 322 | "postgres-bytea": "~1.0.0", 323 | "postgres-date": "~1.0.4", 324 | "postgres-interval": "^1.1.0" 325 | } 326 | }, 327 | "pgpass": { 328 | "version": "1.0.2", 329 | "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.2.tgz", 330 | "integrity": "sha1-Knu0G2BltnkH6R2hsHwYR8h3swY=", 331 | "requires": { 332 | "split": "^1.0.0" 333 | } 334 | }, 335 | "postgres-array": { 336 | "version": "2.0.0", 337 | "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", 338 | "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==" 339 | }, 340 | "postgres-bytea": { 341 | "version": "1.0.0", 342 | "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", 343 | "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" 344 | }, 345 | "postgres-date": { 346 | "version": "1.0.4", 347 | "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.4.tgz", 348 | "integrity": "sha512-bESRvKVuTrjoBluEcpv2346+6kgB7UlnqWZsnbnCccTNq/pqfj1j6oBaN5+b/NrDXepYUT/HKadqv3iS9lJuVA==" 349 | }, 350 | "postgres-interval": { 351 | "version": "1.2.0", 352 | "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", 353 | "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", 354 | "requires": { 355 | "xtend": "^4.0.0" 356 | } 357 | }, 358 | "proxy-addr": { 359 | "version": "2.0.6", 360 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", 361 | "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", 362 | "requires": { 363 | "forwarded": "~0.1.2", 364 | "ipaddr.js": "1.9.1" 365 | } 366 | }, 367 | "qs": { 368 | "version": "6.7.0", 369 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", 370 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" 371 | }, 372 | "range-parser": { 373 | "version": "1.2.1", 374 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 375 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" 376 | }, 377 | "raw-body": { 378 | "version": "2.4.0", 379 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", 380 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", 381 | "requires": { 382 | "bytes": "3.1.0", 383 | "http-errors": "1.7.2", 384 | "iconv-lite": "0.4.24", 385 | "unpipe": "1.0.0" 386 | } 387 | }, 388 | "safe-buffer": { 389 | "version": "5.1.2", 390 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 391 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 392 | }, 393 | "safer-buffer": { 394 | "version": "2.1.2", 395 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 396 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 397 | }, 398 | "semver": { 399 | "version": "4.3.2", 400 | "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", 401 | "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" 402 | }, 403 | "send": { 404 | "version": "0.17.1", 405 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", 406 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", 407 | "requires": { 408 | "debug": "2.6.9", 409 | "depd": "~1.1.2", 410 | "destroy": "~1.0.4", 411 | "encodeurl": "~1.0.2", 412 | "escape-html": "~1.0.3", 413 | "etag": "~1.8.1", 414 | "fresh": "0.5.2", 415 | "http-errors": "~1.7.2", 416 | "mime": "1.6.0", 417 | "ms": "2.1.1", 418 | "on-finished": "~2.3.0", 419 | "range-parser": "~1.2.1", 420 | "statuses": "~1.5.0" 421 | }, 422 | "dependencies": { 423 | "ms": { 424 | "version": "2.1.1", 425 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 426 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" 427 | } 428 | } 429 | }, 430 | "serve-static": { 431 | "version": "1.14.1", 432 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", 433 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", 434 | "requires": { 435 | "encodeurl": "~1.0.2", 436 | "escape-html": "~1.0.3", 437 | "parseurl": "~1.3.3", 438 | "send": "0.17.1" 439 | } 440 | }, 441 | "setprototypeof": { 442 | "version": "1.1.1", 443 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", 444 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" 445 | }, 446 | "split": { 447 | "version": "1.0.1", 448 | "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", 449 | "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", 450 | "requires": { 451 | "through": "2" 452 | } 453 | }, 454 | "statuses": { 455 | "version": "1.5.0", 456 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 457 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" 458 | }, 459 | "through": { 460 | "version": "2.3.8", 461 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", 462 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" 463 | }, 464 | "toidentifier": { 465 | "version": "1.0.0", 466 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", 467 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" 468 | }, 469 | "type-is": { 470 | "version": "1.6.18", 471 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 472 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 473 | "requires": { 474 | "media-typer": "0.3.0", 475 | "mime-types": "~2.1.24" 476 | } 477 | }, 478 | "unpipe": { 479 | "version": "1.0.0", 480 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 481 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 482 | }, 483 | "utils-merge": { 484 | "version": "1.0.1", 485 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 486 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 487 | }, 488 | "vary": { 489 | "version": "1.1.2", 490 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 491 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 492 | }, 493 | "xtend": { 494 | "version": "4.0.2", 495 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", 496 | "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" 497 | } 498 | } 499 | } 500 | -------------------------------------------------------------------------------- /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 | "author": "henry", 10 | "license": "ISC", 11 | "dependencies": { 12 | "cors": "^2.8.5", 13 | "express": "^4.17.1", 14 | "pg": "^7.18.2" 15 | } 16 | } 17 | --------------------------------------------------------------------------------