├── mern-stack-client ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── src │ ├── reducers │ │ ├── index.js │ │ └── postMessage.js │ ├── setupTests.js │ ├── App.test.js │ ├── index.css │ ├── actions │ │ ├── store.js │ │ ├── api.js │ │ └── postMessage.js │ ├── index.js │ ├── App.css │ ├── components │ │ ├── useForm.js │ │ ├── PostMessageForm.js │ │ └── PostMessages.js │ ├── App.js │ ├── logo.svg │ └── serviceWorker.js ├── .gitignore ├── roughWorks.txt ├── package.json └── README.md ├── mern-stack-api ├── models │ └── postMessage.js ├── db.js ├── package.json ├── index.js ├── controllers │ └── postMessageController.js └── package-lock.json └── README.md /mern-stack-client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /mern-stack-client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodAffection/MERN-Stack-CRUD/master/mern-stack-client/public/favicon.ico -------------------------------------------------------------------------------- /mern-stack-client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodAffection/MERN-Stack-CRUD/master/mern-stack-client/public/logo192.png -------------------------------------------------------------------------------- /mern-stack-client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodAffection/MERN-Stack-CRUD/master/mern-stack-client/public/logo512.png -------------------------------------------------------------------------------- /mern-stack-client/src/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from "redux"; 2 | import { postMessage } from "./postMessage"; 3 | 4 | export const reducers = combineReducers({ 5 | postMessage 6 | }) -------------------------------------------------------------------------------- /mern-stack-api/models/postMessage.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | var PostMessage = mongoose.model('PostMessage', 4 | { 5 | title : {type:String}, 6 | message : {type:String}, 7 | },'postMessages') 8 | 9 | module.exports = { PostMessage} -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /mern-stack-client/src/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Roboto&display=swap'); 2 | 3 | body { 4 | margin: 0; 5 | font-family: 'Roboto'; 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 | -------------------------------------------------------------------------------- /mern-stack-api/db.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | mongoose.connect('mongodb://localhost:27017/postManagerDB',{useNewUrlParser:true,useUnifiedTopology:true}, 4 | err => { 5 | if (!err) 6 | console.log('Mongodb connection succeeded.') 7 | else 8 | console.log('Error while connecting MongoDB : ' + JSON.stringify(err, undefined, 2)) 9 | }) -------------------------------------------------------------------------------- /mern-stack-client/src/actions/store.js: -------------------------------------------------------------------------------- 1 | import { createStore, applyMiddleware, compose } from "redux"; 2 | import thunk from "redux-thunk"; 3 | import { reducers } from "../reducers"; 4 | 5 | 6 | export const store = createStore( 7 | reducers, 8 | compose( 9 | applyMiddleware(thunk), 10 | // window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() 11 | ) 12 | ) -------------------------------------------------------------------------------- /mern-stack-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mern-stack-api", 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": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "body-parser": "^1.19.0", 13 | "cors": "^2.8.5", 14 | "express": "^4.17.1", 15 | "mongoose": "^5.8.11" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /mern-stack-api/index.js: -------------------------------------------------------------------------------- 1 | require('./db') 2 | const express = require('express') 3 | const bodyParser = require('body-parser') 4 | const cors = require('cors') 5 | 6 | var postMessageRoutes = require('./controllers/postMessageController') 7 | 8 | 9 | var app = express() 10 | app.use(bodyParser.json()) 11 | app.use(cors({origin:'http://localhost:3000'})) 12 | app.listen(4000,()=>console.log('Server started at : 4000')) 13 | 14 | 15 | app.use('/postMessages',postMessageRoutes) -------------------------------------------------------------------------------- /mern-stack-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(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /mern-stack-client/src/actions/api.js: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | const baseUrl = 'http://localhost:4000/' 4 | 5 | export default { 6 | postMessage(url = baseUrl + 'postmessages/') { 7 | return { 8 | fetchAll: () => axios.get(url), 9 | fetchById: id => axios.get(url + id), 10 | create: newRecord => axios.post(url, newRecord), 11 | update: (id, updatedRecord) => axios.put(url + id, updatedRecord), 12 | delete: id => axios.delete(url + id) 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /mern-stack-client/roughWorks.txt: -------------------------------------------------------------------------------- 1 | App Structure 2 | ------------- 3 | 4 | ● src 5 | +---● actions 6 | | | 7 | | |-- api.js (handle all http request) 8 | | |-- postMessage.js (Redux actions & action creators) 9 | | |-- store.js (configure redux store) 10 | | 11 | +---● components 12 | | | 13 | | |--PostMessageForm.js (form operations) - child 14 | | |--PostMessages.js (list of records) - parent 15 | | |--useForm.js (handles common form opearations) 16 | | 17 | |---● reducers 18 | | | 19 | | |--postMessage.js 20 | | |--index.js 21 | | 22 | |-- App.js 23 | |-- index.js 24 | |-- index.css -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /mern-stack-client/src/components/useForm.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | 3 | const useForm = (initialFieldValues,setCurrentId) => { 4 | 5 | const [values, setValues] = useState(initialFieldValues) 6 | const [errors, setErrors] = useState({}) 7 | 8 | const handleInputChange = e => { 9 | const { name, value } = e.target 10 | setValues({ 11 | ...values, 12 | [name]: value 13 | }) 14 | } 15 | 16 | const resetForm =() =>{ 17 | setValues(initialFieldValues) 18 | setErrors({}) 19 | setCurrentId(0) 20 | } 21 | 22 | return { 23 | values, 24 | setValues, 25 | errors, 26 | setErrors, 27 | handleInputChange, 28 | resetForm 29 | }; 30 | } 31 | 32 | export default useForm; 33 | -------------------------------------------------------------------------------- /mern-stack-client/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import './App.css'; 3 | import { Provider } from "react-redux"; 4 | import PostMessages from "./components/PostMessages"; 5 | import { store } from "./actions/store"; 6 | import { Container, AppBar, Typography } from "@material-ui/core"; 7 | import ButterToast,{ POS_RIGHT,POS_TOP } from "butter-toast"; 8 | 9 | function App() { 10 | return ( 11 | 12 | 13 | 14 | 17 | Post Box 18 | 19 | 20 | 21 | 22 | 23 | 24 | ); 25 | } 26 | 27 | export default App; 28 | -------------------------------------------------------------------------------- /mern-stack-client/src/reducers/postMessage.js: -------------------------------------------------------------------------------- 1 | import { ACTION_TYPES } from "../actions/postMessage"; 2 | 3 | const initialState = { 4 | list: [] 5 | } 6 | //postMessage.list 7 | export const postMessage = (state = initialState, action) => { 8 | switch (action.type) { 9 | case ACTION_TYPES.FETCH_ALL: 10 | return { 11 | ...state, 12 | list: [...action.payload] 13 | } 14 | case ACTION_TYPES.CREATE: 15 | return { 16 | ...state, 17 | list: [...state.list, action.payload] 18 | } 19 | case ACTION_TYPES.UPDATE: 20 | return { 21 | ...state, 22 | list: state.list.map(x => x._id == action.payload._id ? action.payload : x) 23 | } 24 | 25 | case ACTION_TYPES.DELETE: 26 | return { 27 | ...state, 28 | list:state.list.filter(x => x._id != action.payload) 29 | } 30 | 31 | default: 32 | return state; 33 | } 34 | } -------------------------------------------------------------------------------- /mern-stack-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mern-stack-client", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.9.2", 7 | "@material-ui/icons": "^4.9.1", 8 | "@testing-library/jest-dom": "^4.2.4", 9 | "@testing-library/react": "^9.3.2", 10 | "@testing-library/user-event": "^7.1.2", 11 | "axios": "^0.19.2", 12 | "butter-toast": "^3.3.5", 13 | "react": "^16.12.0", 14 | "react-dom": "^16.12.0", 15 | "react-redux": "^7.1.3", 16 | "react-scripts": "3.3.1", 17 | "redux": "^4.0.5", 18 | "redux-thunk": "^2.3.0" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /mern-stack-client/src/actions/postMessage.js: -------------------------------------------------------------------------------- 1 | import api from "./api.js"; 2 | 3 | export const ACTION_TYPES = { 4 | CREATE: 'CREATE', 5 | UPDATE: 'UPDATE', 6 | DELETE: 'DELETE', 7 | FETCH_ALL: 'FETCH_ALL' 8 | } 9 | 10 | export const fetchAll = () => dispatch => { 11 | api.postMessage().fetchAll() 12 | .then(res => { 13 | dispatch({ 14 | type: ACTION_TYPES.FETCH_ALL, 15 | payload: res.data 16 | }) 17 | }) 18 | .catch(err => console.log(err)) 19 | 20 | } 21 | 22 | export const create = (data, onSuccess) => dispatch => { 23 | api.postMessage().create(data) 24 | .then(res =>{ 25 | dispatch({ 26 | type: ACTION_TYPES.CREATE, 27 | payload: res.data 28 | }) 29 | onSuccess() 30 | }) 31 | .catch(err => console.log(err)) 32 | } 33 | 34 | export const update = (id,data, onSuccess) => dispatch => { 35 | api.postMessage().update(id,data) 36 | .then(res =>{ 37 | dispatch({ 38 | type: ACTION_TYPES.UPDATE, 39 | payload: res.data 40 | }) 41 | onSuccess() 42 | }) 43 | .catch(err => console.log(err)) 44 | } 45 | 46 | 47 | export const Delete = (id, onSuccess) => dispatch => { 48 | api.postMessage().delete(id) 49 | .then(res =>{ 50 | dispatch({ 51 | type: ACTION_TYPES.DELETE, 52 | payload: id 53 | }) 54 | onSuccess() 55 | }) 56 | .catch(err => console.log(err)) 57 | } -------------------------------------------------------------------------------- /mern-stack-api/controllers/postMessageController.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | var router = express.Router() 3 | var ObjectID = require('mongoose').Types.ObjectId 4 | 5 | 6 | var { PostMessage } = require('../models/postMessage') 7 | 8 | 9 | router.get('/', (req, res) => { 10 | PostMessage.find((err, docs) => { 11 | if (!err) res.send(docs) 12 | else console.log('Error while retrieving all records : ' + JSON.stringify(err, undefined, 2)) 13 | }) 14 | }) 15 | 16 | router.post('/', (req, res) => { 17 | var newRecord = new PostMessage({ 18 | title: req.body.title, 19 | message: req.body.message 20 | }) 21 | 22 | newRecord.save((err, docs) => { 23 | if (!err) res.send(docs) 24 | else console.log('Error while creating new record : ' + JSON.stringify(err, undefined, 2)) 25 | }) 26 | }) 27 | 28 | router.put('/:id', (req, res) => { 29 | if (!ObjectID.isValid(req.params.id)) 30 | return res.status(400).send('No record with given id : ' + req.params.id) 31 | 32 | var updatedRecord = { 33 | title: req.body.title, 34 | message: req.body.message 35 | } 36 | 37 | PostMessage.findByIdAndUpdate(req.params.id, { $set: updatedRecord },{new:true}, (err, docs) => { 38 | if (!err) res.send(docs) 39 | else console.log('Error while updating a record : ' + JSON.stringify(err, undefined, 2)) 40 | }) 41 | }) 42 | 43 | router.delete('/:id', (req, res) => { 44 | if (!ObjectID.isValid(req.params.id)) 45 | return res.status(400).send('No record with given id : ' + req.params.id) 46 | 47 | PostMessage.findByIdAndRemove(req.params.id, (err, docs) => { 48 | if (!err) res.send(docs) 49 | else console.log('Error while deleting a record : ' + JSON.stringify(err, undefined, 2)) 50 | }) 51 | }) 52 | 53 | 54 | module.exports = router -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MERN Stack CRUD Operations 2 | Implented MERN Stack CRUD Operations with React, Node.js, MongoDB and Express. 3 | 4 | ## Get the Code 5 | 6 | ``` 7 | $ git clone https://github.com/CodAffection/MERN-Stack-CRUD.git 8 | $ cd MERN-Stack-CRUD/mern-stack-client 9 | $ npm install 10 | ``` 11 | 12 | ## How it works ? 13 | 14 | :tv: Video tutorial on this same topic 15 | Url : https://youtu.be/HuXBuXf52vA 16 | 17 | Video Tutorial for Complete MERN Stack CRUD Operations 20 | 21 | 22 | | :bar_chart: | List of Tutorials | | :moneybag: | Support Us | 23 | |--------------------------:|:---------------------|---|---------------------:|:-------------------------------------| 24 | | Angular |http://bit.ly/2KQN9xF | |Paypal | https://goo.gl/bPcyXW | 25 | | Asp.Net Core |http://bit.ly/30fPDMg | |Amazon Affiliate | https://geni.us/JDzpE | 26 | | React |http://bit.ly/325temF | | 27 | | Python |http://bit.ly/2ws4utg | | :point_right: | Follow Us | 28 | | Node.js |https://goo.gl/viJcFs | |Website |http://www.codaffection.com | 29 | | Asp.Net MVC |https://goo.gl/gvjUJ7 | |YouTube |https://www.youtube.com/codaffection | 30 | | Flutter |https://bit.ly/3ggmmJz| |Facebook |https://www.facebook.com/codaffection | 31 | | Web API |https://goo.gl/itVayJ | |Twitter |https://twitter.com/CodAffection | 32 | | MEAN Stack |https://goo.gl/YJPPAH | | 33 | | C# Tutorial |https://goo.gl/s1zJxo | | 34 | | Asp.Net WebForm |https://goo.gl/GXC2aJ | | 35 | | C# WinForm |https://goo.gl/vHS9Hd | | 36 | | MS SQL |https://goo.gl/MLYS9e | | 37 | | Crystal Report |https://goo.gl/5Vou7t | | 38 | | CG Exercises in C Program |https://goo.gl/qEWJCs | | 39 | -------------------------------------------------------------------------------- /mern-stack-client/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mern-stack-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 | -------------------------------------------------------------------------------- /mern-stack-client/src/components/PostMessageForm.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { TextField, withStyles, Button } from "@material-ui/core"; 3 | import useForm from "./useForm"; 4 | import { connect } from "react-redux"; 5 | import * as actions from "../actions/postMessage"; 6 | import ButterToast, { Cinnamon } from "butter-toast"; 7 | import { AssignmentTurnedIn } from "@material-ui/icons"; 8 | 9 | const initialFieldValues = { 10 | title: '', 11 | message: '' 12 | } 13 | 14 | const styles = theme => ({ 15 | root: { 16 | '& .MuiTextField-root': { 17 | margin: theme.spacing(1) 18 | }, 19 | }, 20 | form: { 21 | display: 'flex', 22 | flexWrap: 'wrap', 23 | justifyContent: 'center' 24 | }, 25 | postBtn: { 26 | width: "50%" 27 | } 28 | }) 29 | 30 | const PostMessageForm = ({ classes, ...props }) => { 31 | 32 | useEffect(() => { 33 | if (props.currentId != 0){ 34 | setValues({ 35 | ...props.postMessageList.find(x => x._id == props.currentId) 36 | }) 37 | setErrors({}) 38 | } 39 | }, [props.currentId]) 40 | 41 | const validate = () => { 42 | let temp = { ...errors } 43 | temp.title = values.title ? "" : "This field is required." 44 | temp.message = values.message ? "" : "This field is required." 45 | setErrors({ 46 | ...temp 47 | }) 48 | return Object.values(temp).every(x => x == "") 49 | } 50 | 51 | var { 52 | values, 53 | setValues, 54 | errors, 55 | setErrors, 56 | handleInputChange, 57 | resetForm 58 | } = useForm(initialFieldValues,props.setCurrentId) 59 | 60 | const handleSubmit = e => { 61 | e.preventDefault() 62 | const onSuccess = () => { 63 | ButterToast.raise({ 64 | content: } 68 | /> 69 | }) 70 | resetForm() 71 | } 72 | if (validate()) { 73 | if (props.currentId == 0) 74 | props.createPostMessage(values, onSuccess) 75 | else 76 | props.updatePostMessage(props.currentId, values, onSuccess) 77 | } 78 | } 79 | 80 | return ( 81 |
83 | 92 | 103 | 110 | 111 | ); 112 | } 113 | 114 | 115 | const mapStateToProps = state => ({ 116 | postMessageList: state.postMessage.list 117 | }) 118 | 119 | const mapActionToProps = { 120 | createPostMessage: actions.create, 121 | updatePostMessage: actions.update 122 | } 123 | 124 | 125 | export default connect(mapStateToProps, mapActionToProps)(withStyles(styles)(PostMessageForm)); -------------------------------------------------------------------------------- /mern-stack-client/src/components/PostMessages.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState, Fragment } from "react"; 2 | import { connect } from "react-redux"; 3 | import * as actions from "../actions/postMessage"; 4 | import { Grid, Paper, withStyles, List, ListItem, ListItemText, Typography, Divider, Button } from "@material-ui/core"; 5 | import PostMessageForm from "./PostMessageForm"; 6 | import ButterToast, { Cinnamon } from "butter-toast"; 7 | import { DeleteSweep } from "@material-ui/icons"; 8 | 9 | const styles = theme => ({ 10 | paper: { 11 | margin: theme.spacing(3), 12 | padding: theme.spacing(2) 13 | }, 14 | smMargin: { 15 | margin: theme.spacing(1) 16 | }, 17 | actionDiv: { 18 | textAlign: "center" 19 | } 20 | }) 21 | 22 | const PostMessages = ({ classes, ...props }) => { 23 | //const {classes, ...props} = props 24 | const [currentId, setCurrentId] = useState(0) 25 | 26 | useEffect(() => { 27 | props.fetchAllPostMessages() 28 | }, [])//DidMount 29 | 30 | const onDelete = id => { 31 | const onSuccess = () => { 32 | ButterToast.raise({ 33 | content: } 37 | /> 38 | }) 39 | } 40 | if (window.confirm('Are you sure to delete this record?')) 41 | props.deletePostMessage(id,onSuccess) 42 | } 43 | 44 | 45 | return ( 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | { 56 | props.postMessageList.map((record, index) => { 57 | return ( 58 | 59 | 60 | 61 | 62 | {record.title} 63 | 64 |
65 | {record.message} 66 |
67 |
68 | 73 | 78 |
79 |
80 |
81 | 82 |
83 | ) 84 | }) 85 | } 86 |
87 |
88 |
89 |
90 | ); 91 | } 92 | 93 | const mapStateToProps = state => ({ 94 | postMessageList: state.postMessage.list 95 | }) 96 | 97 | const mapActionToProps = { 98 | fetchAllPostMessages: actions.fetchAll, 99 | deletePostMessage: actions.Delete 100 | } 101 | 102 | export default connect(mapStateToProps, mapActionToProps)(withStyles(styles)(PostMessages)); 103 | -------------------------------------------------------------------------------- /mern-stack-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.then(registration => { 134 | registration.unregister(); 135 | }); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /mern-stack-api/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mern-stack-api", 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 | "bluebird": { 22 | "version": "3.5.1", 23 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", 24 | "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" 25 | }, 26 | "body-parser": { 27 | "version": "1.19.0", 28 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", 29 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", 30 | "requires": { 31 | "bytes": "3.1.0", 32 | "content-type": "~1.0.4", 33 | "debug": "2.6.9", 34 | "depd": "~1.1.2", 35 | "http-errors": "1.7.2", 36 | "iconv-lite": "0.4.24", 37 | "on-finished": "~2.3.0", 38 | "qs": "6.7.0", 39 | "raw-body": "2.4.0", 40 | "type-is": "~1.6.17" 41 | } 42 | }, 43 | "bson": { 44 | "version": "1.1.3", 45 | "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz", 46 | "integrity": "sha512-TdiJxMVnodVS7r0BdL42y/pqC9cL2iKynVwA0Ho3qbsQYr428veL3l7BQyuqiw+Q5SqqoT0m4srSY/BlZ9AxXg==" 47 | }, 48 | "bytes": { 49 | "version": "3.1.0", 50 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", 51 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" 52 | }, 53 | "content-disposition": { 54 | "version": "0.5.3", 55 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", 56 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", 57 | "requires": { 58 | "safe-buffer": "5.1.2" 59 | } 60 | }, 61 | "content-type": { 62 | "version": "1.0.4", 63 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 64 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 65 | }, 66 | "cookie": { 67 | "version": "0.4.0", 68 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", 69 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" 70 | }, 71 | "cookie-signature": { 72 | "version": "1.0.6", 73 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 74 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 75 | }, 76 | "cors": { 77 | "version": "2.8.5", 78 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 79 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 80 | "requires": { 81 | "object-assign": "^4", 82 | "vary": "^1" 83 | } 84 | }, 85 | "debug": { 86 | "version": "2.6.9", 87 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 88 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 89 | "requires": { 90 | "ms": "2.0.0" 91 | } 92 | }, 93 | "depd": { 94 | "version": "1.1.2", 95 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 96 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 97 | }, 98 | "destroy": { 99 | "version": "1.0.4", 100 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 101 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 102 | }, 103 | "ee-first": { 104 | "version": "1.1.1", 105 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 106 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 107 | }, 108 | "encodeurl": { 109 | "version": "1.0.2", 110 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 111 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 112 | }, 113 | "escape-html": { 114 | "version": "1.0.3", 115 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 116 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 117 | }, 118 | "etag": { 119 | "version": "1.8.1", 120 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 121 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 122 | }, 123 | "express": { 124 | "version": "4.17.1", 125 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", 126 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", 127 | "requires": { 128 | "accepts": "~1.3.7", 129 | "array-flatten": "1.1.1", 130 | "body-parser": "1.19.0", 131 | "content-disposition": "0.5.3", 132 | "content-type": "~1.0.4", 133 | "cookie": "0.4.0", 134 | "cookie-signature": "1.0.6", 135 | "debug": "2.6.9", 136 | "depd": "~1.1.2", 137 | "encodeurl": "~1.0.2", 138 | "escape-html": "~1.0.3", 139 | "etag": "~1.8.1", 140 | "finalhandler": "~1.1.2", 141 | "fresh": "0.5.2", 142 | "merge-descriptors": "1.0.1", 143 | "methods": "~1.1.2", 144 | "on-finished": "~2.3.0", 145 | "parseurl": "~1.3.3", 146 | "path-to-regexp": "0.1.7", 147 | "proxy-addr": "~2.0.5", 148 | "qs": "6.7.0", 149 | "range-parser": "~1.2.1", 150 | "safe-buffer": "5.1.2", 151 | "send": "0.17.1", 152 | "serve-static": "1.14.1", 153 | "setprototypeof": "1.1.1", 154 | "statuses": "~1.5.0", 155 | "type-is": "~1.6.18", 156 | "utils-merge": "1.0.1", 157 | "vary": "~1.1.2" 158 | } 159 | }, 160 | "finalhandler": { 161 | "version": "1.1.2", 162 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", 163 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", 164 | "requires": { 165 | "debug": "2.6.9", 166 | "encodeurl": "~1.0.2", 167 | "escape-html": "~1.0.3", 168 | "on-finished": "~2.3.0", 169 | "parseurl": "~1.3.3", 170 | "statuses": "~1.5.0", 171 | "unpipe": "~1.0.0" 172 | } 173 | }, 174 | "forwarded": { 175 | "version": "0.1.2", 176 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 177 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 178 | }, 179 | "fresh": { 180 | "version": "0.5.2", 181 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 182 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 183 | }, 184 | "http-errors": { 185 | "version": "1.7.2", 186 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", 187 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", 188 | "requires": { 189 | "depd": "~1.1.2", 190 | "inherits": "2.0.3", 191 | "setprototypeof": "1.1.1", 192 | "statuses": ">= 1.5.0 < 2", 193 | "toidentifier": "1.0.0" 194 | } 195 | }, 196 | "iconv-lite": { 197 | "version": "0.4.24", 198 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 199 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 200 | "requires": { 201 | "safer-buffer": ">= 2.1.2 < 3" 202 | } 203 | }, 204 | "inherits": { 205 | "version": "2.0.3", 206 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 207 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 208 | }, 209 | "ipaddr.js": { 210 | "version": "1.9.0", 211 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", 212 | "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" 213 | }, 214 | "kareem": { 215 | "version": "2.3.1", 216 | "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", 217 | "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==" 218 | }, 219 | "media-typer": { 220 | "version": "0.3.0", 221 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 222 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 223 | }, 224 | "memory-pager": { 225 | "version": "1.5.0", 226 | "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", 227 | "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", 228 | "optional": true 229 | }, 230 | "merge-descriptors": { 231 | "version": "1.0.1", 232 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 233 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 234 | }, 235 | "methods": { 236 | "version": "1.1.2", 237 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 238 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 239 | }, 240 | "mime": { 241 | "version": "1.6.0", 242 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 243 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" 244 | }, 245 | "mime-db": { 246 | "version": "1.43.0", 247 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", 248 | "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" 249 | }, 250 | "mime-types": { 251 | "version": "2.1.26", 252 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", 253 | "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", 254 | "requires": { 255 | "mime-db": "1.43.0" 256 | } 257 | }, 258 | "mongodb": { 259 | "version": "3.4.1", 260 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.4.1.tgz", 261 | "integrity": "sha512-juqt5/Z42J4DcE7tG7UdVaTKmUC6zinF4yioPfpeOSNBieWSK6qCY+0tfGQcHLKrauWPDdMZVROHJOa8q2pWsA==", 262 | "requires": { 263 | "bson": "^1.1.1", 264 | "require_optional": "^1.0.1", 265 | "safe-buffer": "^5.1.2", 266 | "saslprep": "^1.0.0" 267 | } 268 | }, 269 | "mongoose": { 270 | "version": "5.8.11", 271 | "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.8.11.tgz", 272 | "integrity": "sha512-Yz0leNEJsAtNtMTxTDEadacLWt58gaVeBVL3c1Z3vaBoc159aJqlf+T8jaL9mAdBxKndF5YWhh6Q719xac7cjA==", 273 | "requires": { 274 | "bson": "~1.1.1", 275 | "kareem": "2.3.1", 276 | "mongodb": "3.4.1", 277 | "mongoose-legacy-pluralize": "1.0.2", 278 | "mpath": "0.6.0", 279 | "mquery": "3.2.2", 280 | "ms": "2.1.2", 281 | "regexp-clone": "1.0.0", 282 | "safe-buffer": "5.1.2", 283 | "sift": "7.0.1", 284 | "sliced": "1.0.1" 285 | }, 286 | "dependencies": { 287 | "ms": { 288 | "version": "2.1.2", 289 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 290 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 291 | } 292 | } 293 | }, 294 | "mongoose-legacy-pluralize": { 295 | "version": "1.0.2", 296 | "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", 297 | "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" 298 | }, 299 | "mpath": { 300 | "version": "0.6.0", 301 | "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", 302 | "integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==" 303 | }, 304 | "mquery": { 305 | "version": "3.2.2", 306 | "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz", 307 | "integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==", 308 | "requires": { 309 | "bluebird": "3.5.1", 310 | "debug": "3.1.0", 311 | "regexp-clone": "^1.0.0", 312 | "safe-buffer": "5.1.2", 313 | "sliced": "1.0.1" 314 | }, 315 | "dependencies": { 316 | "debug": { 317 | "version": "3.1.0", 318 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 319 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 320 | "requires": { 321 | "ms": "2.0.0" 322 | } 323 | } 324 | } 325 | }, 326 | "ms": { 327 | "version": "2.0.0", 328 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 329 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 330 | }, 331 | "negotiator": { 332 | "version": "0.6.2", 333 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 334 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 335 | }, 336 | "object-assign": { 337 | "version": "4.1.1", 338 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 339 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 340 | }, 341 | "on-finished": { 342 | "version": "2.3.0", 343 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 344 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 345 | "requires": { 346 | "ee-first": "1.1.1" 347 | } 348 | }, 349 | "parseurl": { 350 | "version": "1.3.3", 351 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 352 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 353 | }, 354 | "path-to-regexp": { 355 | "version": "0.1.7", 356 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 357 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 358 | }, 359 | "proxy-addr": { 360 | "version": "2.0.5", 361 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", 362 | "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", 363 | "requires": { 364 | "forwarded": "~0.1.2", 365 | "ipaddr.js": "1.9.0" 366 | } 367 | }, 368 | "qs": { 369 | "version": "6.7.0", 370 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", 371 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" 372 | }, 373 | "range-parser": { 374 | "version": "1.2.1", 375 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 376 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" 377 | }, 378 | "raw-body": { 379 | "version": "2.4.0", 380 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", 381 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", 382 | "requires": { 383 | "bytes": "3.1.0", 384 | "http-errors": "1.7.2", 385 | "iconv-lite": "0.4.24", 386 | "unpipe": "1.0.0" 387 | } 388 | }, 389 | "regexp-clone": { 390 | "version": "1.0.0", 391 | "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", 392 | "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==" 393 | }, 394 | "require_optional": { 395 | "version": "1.0.1", 396 | "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", 397 | "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", 398 | "requires": { 399 | "resolve-from": "^2.0.0", 400 | "semver": "^5.1.0" 401 | } 402 | }, 403 | "resolve-from": { 404 | "version": "2.0.0", 405 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", 406 | "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" 407 | }, 408 | "safe-buffer": { 409 | "version": "5.1.2", 410 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 411 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 412 | }, 413 | "safer-buffer": { 414 | "version": "2.1.2", 415 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 416 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 417 | }, 418 | "saslprep": { 419 | "version": "1.0.3", 420 | "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", 421 | "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", 422 | "optional": true, 423 | "requires": { 424 | "sparse-bitfield": "^3.0.3" 425 | } 426 | }, 427 | "semver": { 428 | "version": "5.7.1", 429 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 430 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" 431 | }, 432 | "send": { 433 | "version": "0.17.1", 434 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", 435 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", 436 | "requires": { 437 | "debug": "2.6.9", 438 | "depd": "~1.1.2", 439 | "destroy": "~1.0.4", 440 | "encodeurl": "~1.0.2", 441 | "escape-html": "~1.0.3", 442 | "etag": "~1.8.1", 443 | "fresh": "0.5.2", 444 | "http-errors": "~1.7.2", 445 | "mime": "1.6.0", 446 | "ms": "2.1.1", 447 | "on-finished": "~2.3.0", 448 | "range-parser": "~1.2.1", 449 | "statuses": "~1.5.0" 450 | }, 451 | "dependencies": { 452 | "ms": { 453 | "version": "2.1.1", 454 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 455 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" 456 | } 457 | } 458 | }, 459 | "serve-static": { 460 | "version": "1.14.1", 461 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", 462 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", 463 | "requires": { 464 | "encodeurl": "~1.0.2", 465 | "escape-html": "~1.0.3", 466 | "parseurl": "~1.3.3", 467 | "send": "0.17.1" 468 | } 469 | }, 470 | "setprototypeof": { 471 | "version": "1.1.1", 472 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", 473 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" 474 | }, 475 | "sift": { 476 | "version": "7.0.1", 477 | "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", 478 | "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" 479 | }, 480 | "sliced": { 481 | "version": "1.0.1", 482 | "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", 483 | "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" 484 | }, 485 | "sparse-bitfield": { 486 | "version": "3.0.3", 487 | "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", 488 | "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", 489 | "optional": true, 490 | "requires": { 491 | "memory-pager": "^1.0.2" 492 | } 493 | }, 494 | "statuses": { 495 | "version": "1.5.0", 496 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 497 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" 498 | }, 499 | "toidentifier": { 500 | "version": "1.0.0", 501 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", 502 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" 503 | }, 504 | "type-is": { 505 | "version": "1.6.18", 506 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 507 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 508 | "requires": { 509 | "media-typer": "0.3.0", 510 | "mime-types": "~2.1.24" 511 | } 512 | }, 513 | "unpipe": { 514 | "version": "1.0.0", 515 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 516 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 517 | }, 518 | "utils-merge": { 519 | "version": "1.0.1", 520 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 521 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 522 | }, 523 | "vary": { 524 | "version": "1.1.2", 525 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 526 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 527 | } 528 | } 529 | } 530 | --------------------------------------------------------------------------------