├── .gitignore ├── README.md ├── app.js ├── db.js ├── index.html ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Todo_Rest_CRUD_Application_JQuery_FetchAPI 2 | Make sure to change into directory and run "Npm install" to download modules 3 | 4 | Source Code for Todo Rest CRUD Application Tutorial found here: 5 | 6 | https://www.youtube.com/watch?v=U7vikICNygc&list=PLvTjg4siRgU1ucYFHJy1tkwFjf73D0fGa 7 | 8 | Noobcoder.com 9 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const bodyParser = require("body-parser"); 3 | const path = require('path'); 4 | const Joi = require('joi'); 5 | 6 | const db = require("./db"); 7 | const collection = "todo"; 8 | const app = express(); 9 | 10 | // schema used for data validation for our todo document 11 | const schema = Joi.object().keys({ 12 | todo : Joi.string().required() 13 | }); 14 | 15 | // parses json data sent to us by the user 16 | app.use(bodyParser.json()); 17 | 18 | // serve static html file to user 19 | app.get('/',(req,res)=>{ 20 | res.sendFile(path.join(__dirname,'index.html')); 21 | }); 22 | 23 | // read 24 | app.get('/getTodos',(req,res)=>{ 25 | // get all Todo documents within our todo collection 26 | // send back to user as json 27 | db.getDB().collection(collection).find({}).toArray((err,documents)=>{ 28 | if(err) 29 | console.log(err); 30 | else{ 31 | res.json(documents); 32 | } 33 | }); 34 | }); 35 | 36 | // update 37 | app.put('/:id',(req,res)=>{ 38 | // Primary Key of Todo Document we wish to update 39 | const todoID = req.params.id; 40 | // Document used to update 41 | const userInput = req.body; 42 | // Find Document By ID and Update 43 | db.getDB().collection(collection).findOneAndUpdate({_id : db.getPrimaryKey(todoID)},{$set : {todo : userInput.todo}},{returnOriginal : false},(err,result)=>{ 44 | if(err) 45 | console.log(err); 46 | else{ 47 | res.json(result); 48 | } 49 | }); 50 | }); 51 | 52 | 53 | //create 54 | app.post('/',(req,res,next)=>{ 55 | // Document to be inserted 56 | const userInput = req.body; 57 | 58 | // Validate document 59 | // If document is invalid pass to error middleware 60 | // else insert document within todo collection 61 | Joi.validate(userInput,schema,(err,result)=>{ 62 | if(err){ 63 | const error = new Error("Invalid Input"); 64 | error.status = 400; 65 | next(error); 66 | } 67 | else{ 68 | db.getDB().collection(collection).insertOne(userInput,(err,result)=>{ 69 | if(err){ 70 | const error = new Error("Failed to insert Todo Document"); 71 | error.status = 400; 72 | next(error); 73 | } 74 | else 75 | res.json({result : result, document : result.ops[0],msg : "Successfully inserted Todo!!!",error : null}); 76 | }); 77 | } 78 | }) 79 | }); 80 | 81 | 82 | 83 | //delete 84 | app.delete('/:id',(req,res)=>{ 85 | // Primary Key of Todo Document 86 | const todoID = req.params.id; 87 | // Find Document By ID and delete document from record 88 | db.getDB().collection(collection).findOneAndDelete({_id : db.getPrimaryKey(todoID)},(err,result)=>{ 89 | if(err) 90 | console.log(err); 91 | else 92 | res.json(result); 93 | }); 94 | }); 95 | 96 | // Middleware for handling Error 97 | // Sends Error Response Back to User 98 | app.use((err,req,res,next)=>{ 99 | res.status(err.status).json({ 100 | error : { 101 | message : err.message 102 | } 103 | }); 104 | }) 105 | 106 | 107 | db.connect((err)=>{ 108 | // If err unable to connect to database 109 | // End application 110 | if(err){ 111 | console.log('unable to connect to database'); 112 | process.exit(1); 113 | } 114 | // Successfully connected to database 115 | // Start up our Express Application 116 | // And listen for Request 117 | else{ 118 | app.listen(3000,()=>{ 119 | console.log('connected to database, app listening on port 3000'); 120 | }); 121 | } 122 | }); 123 | 124 | -------------------------------------------------------------------------------- /db.js: -------------------------------------------------------------------------------- 1 | const MongoClient = require("mongodb").MongoClient; 2 | const ObjectID = require('mongodb').ObjectID; 3 | // name of our database 4 | const dbname = "crud_mongodb"; 5 | // location of where our mongoDB database is located 6 | const url = "mongodb://localhost:27017"; 7 | // Options for mongoDB 8 | const mongoOptions = {useNewUrlParser : true}; 9 | 10 | const state = { 11 | db : null 12 | }; 13 | 14 | const connect = (cb) =>{ 15 | // if state is not NULL 16 | // Means we have connection already, call our CB 17 | if(state.db) 18 | cb(); 19 | else{ 20 | // attempt to get database connection 21 | MongoClient.connect(url,mongoOptions,(err,client)=>{ 22 | // unable to get database connection pass error to CB 23 | if(err) 24 | cb(err); 25 | // Successfully got our database connection 26 | // Set database connection and call CB 27 | else{ 28 | state.db = client.db(dbname); 29 | cb(); 30 | } 31 | }); 32 | } 33 | } 34 | 35 | // returns OBJECTID object used to 36 | const getPrimaryKey = (_id)=>{ 37 | return ObjectID(_id); 38 | } 39 | 40 | // returns database connection 41 | const getDB = ()=>{ 42 | return state.db; 43 | } 44 | 45 | module.exports = {getDB,connect,getPrimaryKey}; -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Todo Crud Application 12 | 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 | 21 | 22 | 23 |
24 | 25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
    33 | 34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 45 |
46 |
47 |
48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 193 | 194 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongodb_crud", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "accepts": { 8 | "version": "1.3.5", 9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", 10 | "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", 11 | "requires": { 12 | "mime-types": "~2.1.18", 13 | "negotiator": "0.6.1" 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.18.3", 23 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", 24 | "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", 25 | "requires": { 26 | "bytes": "3.0.0", 27 | "content-type": "~1.0.4", 28 | "debug": "2.6.9", 29 | "depd": "~1.1.2", 30 | "http-errors": "~1.6.3", 31 | "iconv-lite": "0.4.23", 32 | "on-finished": "~2.3.0", 33 | "qs": "6.5.2", 34 | "raw-body": "2.3.3", 35 | "type-is": "~1.6.16" 36 | } 37 | }, 38 | "bson": { 39 | "version": "1.1.0", 40 | "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.0.tgz", 41 | "integrity": "sha512-9Aeai9TacfNtWXOYarkFJRW2CWo+dRon+fuLZYJmvLV3+MiUp0bEI6IAZfXEIg7/Pl/7IWlLaDnhzTsD81etQA==" 42 | }, 43 | "bytes": { 44 | "version": "3.0.0", 45 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 46 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 47 | }, 48 | "content-disposition": { 49 | "version": "0.5.2", 50 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", 51 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" 52 | }, 53 | "content-type": { 54 | "version": "1.0.4", 55 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 56 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 57 | }, 58 | "cookie": { 59 | "version": "0.3.1", 60 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", 61 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" 62 | }, 63 | "cookie-signature": { 64 | "version": "1.0.6", 65 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 66 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 67 | }, 68 | "debug": { 69 | "version": "2.6.9", 70 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 71 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 72 | "requires": { 73 | "ms": "2.0.0" 74 | } 75 | }, 76 | "depd": { 77 | "version": "1.1.2", 78 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 79 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 80 | }, 81 | "destroy": { 82 | "version": "1.0.4", 83 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 84 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 85 | }, 86 | "ee-first": { 87 | "version": "1.1.1", 88 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 89 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 90 | }, 91 | "encodeurl": { 92 | "version": "1.0.2", 93 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 94 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 95 | }, 96 | "escape-html": { 97 | "version": "1.0.3", 98 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 99 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 100 | }, 101 | "etag": { 102 | "version": "1.8.1", 103 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 104 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 105 | }, 106 | "express": { 107 | "version": "4.16.4", 108 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", 109 | "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", 110 | "requires": { 111 | "accepts": "~1.3.5", 112 | "array-flatten": "1.1.1", 113 | "body-parser": "1.18.3", 114 | "content-disposition": "0.5.2", 115 | "content-type": "~1.0.4", 116 | "cookie": "0.3.1", 117 | "cookie-signature": "1.0.6", 118 | "debug": "2.6.9", 119 | "depd": "~1.1.2", 120 | "encodeurl": "~1.0.2", 121 | "escape-html": "~1.0.3", 122 | "etag": "~1.8.1", 123 | "finalhandler": "1.1.1", 124 | "fresh": "0.5.2", 125 | "merge-descriptors": "1.0.1", 126 | "methods": "~1.1.2", 127 | "on-finished": "~2.3.0", 128 | "parseurl": "~1.3.2", 129 | "path-to-regexp": "0.1.7", 130 | "proxy-addr": "~2.0.4", 131 | "qs": "6.5.2", 132 | "range-parser": "~1.2.0", 133 | "safe-buffer": "5.1.2", 134 | "send": "0.16.2", 135 | "serve-static": "1.13.2", 136 | "setprototypeof": "1.1.0", 137 | "statuses": "~1.4.0", 138 | "type-is": "~1.6.16", 139 | "utils-merge": "1.0.1", 140 | "vary": "~1.1.2" 141 | }, 142 | "dependencies": { 143 | "statuses": { 144 | "version": "1.4.0", 145 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 146 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 147 | } 148 | } 149 | }, 150 | "finalhandler": { 151 | "version": "1.1.1", 152 | "resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", 153 | "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", 154 | "requires": { 155 | "debug": "2.6.9", 156 | "encodeurl": "~1.0.2", 157 | "escape-html": "~1.0.3", 158 | "on-finished": "~2.3.0", 159 | "parseurl": "~1.3.2", 160 | "statuses": "~1.4.0", 161 | "unpipe": "~1.0.0" 162 | }, 163 | "dependencies": { 164 | "statuses": { 165 | "version": "1.4.0", 166 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 167 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 168 | } 169 | } 170 | }, 171 | "forwarded": { 172 | "version": "0.1.2", 173 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 174 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 175 | }, 176 | "fresh": { 177 | "version": "0.5.2", 178 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 179 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 180 | }, 181 | "hoek": { 182 | "version": "6.1.2", 183 | "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.2.tgz", 184 | "integrity": "sha512-6qhh/wahGYZHFSFw12tBbJw5fsAhhwrrG/y3Cs0YMTv2WzMnL0oLPnQJjv1QJvEfylRSOFuP+xCu+tdx0tD16Q==" 185 | }, 186 | "http-errors": { 187 | "version": "1.6.3", 188 | "resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", 189 | "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", 190 | "requires": { 191 | "depd": "~1.1.2", 192 | "inherits": "2.0.3", 193 | "setprototypeof": "1.1.0", 194 | "statuses": ">= 1.4.0 < 2" 195 | } 196 | }, 197 | "iconv-lite": { 198 | "version": "0.4.23", 199 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", 200 | "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", 201 | "requires": { 202 | "safer-buffer": ">= 2.1.2 < 3" 203 | } 204 | }, 205 | "inherits": { 206 | "version": "2.0.3", 207 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 208 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 209 | }, 210 | "ipaddr.js": { 211 | "version": "1.8.0", 212 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", 213 | "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" 214 | }, 215 | "isemail": { 216 | "version": "3.2.0", 217 | "resolved": "https://registry.npmjs.org/isemail/-/isemail-3.2.0.tgz", 218 | "integrity": "sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==", 219 | "requires": { 220 | "punycode": "2.x.x" 221 | } 222 | }, 223 | "joi": { 224 | "version": "14.3.0", 225 | "resolved": "https://registry.npmjs.org/joi/-/joi-14.3.0.tgz", 226 | "integrity": "sha512-0HKd1z8MWogez4GaU0LkY1FgW30vR2Kwy414GISfCU41OYgUC2GWpNe5amsvBZtDqPtt7DohykfOOMIw1Z5hvQ==", 227 | "requires": { 228 | "hoek": "6.x.x", 229 | "isemail": "3.x.x", 230 | "topo": "3.x.x" 231 | } 232 | }, 233 | "media-typer": { 234 | "version": "0.3.0", 235 | "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 236 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 237 | }, 238 | "memory-pager": { 239 | "version": "1.1.0", 240 | "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.1.0.tgz", 241 | "integrity": "sha512-Mf9OHV/Y7h6YWDxTzX/b4ZZ4oh9NSXblQL8dtPCOomOtZciEHxePR78+uHFLLlsk01A6jVHhHsQZZ/WcIPpnzg==", 242 | "optional": true 243 | }, 244 | "merge-descriptors": { 245 | "version": "1.0.1", 246 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 247 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 248 | }, 249 | "methods": { 250 | "version": "1.1.2", 251 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 252 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 253 | }, 254 | "mime": { 255 | "version": "1.4.1", 256 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", 257 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" 258 | }, 259 | "mime-db": { 260 | "version": "1.37.0", 261 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", 262 | "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" 263 | }, 264 | "mime-types": { 265 | "version": "2.1.21", 266 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", 267 | "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", 268 | "requires": { 269 | "mime-db": "~1.37.0" 270 | } 271 | }, 272 | "mongodb": { 273 | "version": "3.1.10", 274 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.10.tgz", 275 | "integrity": "sha512-Uml42GeFxhTGQVml1XQ4cD0o/rp7J2ROy0fdYUcVitoE7vFqEhKH4TYVqRDpQr/bXtCJVxJdNQC1ntRxNREkPQ==", 276 | "requires": { 277 | "mongodb-core": "3.1.9", 278 | "safe-buffer": "^5.1.2" 279 | } 280 | }, 281 | "mongodb-core": { 282 | "version": "3.1.9", 283 | "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.9.tgz", 284 | "integrity": "sha512-MJpciDABXMchrZphh3vMcqu8hkNf/Mi+Gk6btOimVg1XMxLXh87j6FAvRm+KmwD1A9fpu3qRQYcbQe4egj23og==", 285 | "requires": { 286 | "bson": "^1.1.0", 287 | "require_optional": "^1.0.1", 288 | "safe-buffer": "^5.1.2", 289 | "saslprep": "^1.0.0" 290 | } 291 | }, 292 | "ms": { 293 | "version": "2.0.0", 294 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 295 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 296 | }, 297 | "negotiator": { 298 | "version": "0.6.1", 299 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", 300 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" 301 | }, 302 | "on-finished": { 303 | "version": "2.3.0", 304 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 305 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 306 | "requires": { 307 | "ee-first": "1.1.1" 308 | } 309 | }, 310 | "parseurl": { 311 | "version": "1.3.2", 312 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", 313 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" 314 | }, 315 | "path": { 316 | "version": "0.12.7", 317 | "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", 318 | "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", 319 | "requires": { 320 | "process": "^0.11.1", 321 | "util": "^0.10.3" 322 | } 323 | }, 324 | "path-to-regexp": { 325 | "version": "0.1.7", 326 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 327 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 328 | }, 329 | "process": { 330 | "version": "0.11.10", 331 | "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", 332 | "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" 333 | }, 334 | "proxy-addr": { 335 | "version": "2.0.4", 336 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", 337 | "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", 338 | "requires": { 339 | "forwarded": "~0.1.2", 340 | "ipaddr.js": "1.8.0" 341 | } 342 | }, 343 | "punycode": { 344 | "version": "2.1.1", 345 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 346 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" 347 | }, 348 | "qs": { 349 | "version": "6.5.2", 350 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", 351 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" 352 | }, 353 | "range-parser": { 354 | "version": "1.2.0", 355 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", 356 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" 357 | }, 358 | "raw-body": { 359 | "version": "2.3.3", 360 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", 361 | "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", 362 | "requires": { 363 | "bytes": "3.0.0", 364 | "http-errors": "1.6.3", 365 | "iconv-lite": "0.4.23", 366 | "unpipe": "1.0.0" 367 | } 368 | }, 369 | "require_optional": { 370 | "version": "1.0.1", 371 | "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", 372 | "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", 373 | "requires": { 374 | "resolve-from": "^2.0.0", 375 | "semver": "^5.1.0" 376 | } 377 | }, 378 | "resolve-from": { 379 | "version": "2.0.0", 380 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", 381 | "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" 382 | }, 383 | "safe-buffer": { 384 | "version": "5.1.2", 385 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 386 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 387 | }, 388 | "safer-buffer": { 389 | "version": "2.1.2", 390 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 391 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 392 | }, 393 | "saslprep": { 394 | "version": "1.0.2", 395 | "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.2.tgz", 396 | "integrity": "sha512-4cDsYuAjXssUSjxHKRe4DTZC0agDwsCqcMqtJAQPzC74nJ7LfAJflAtC1Zed5hMzEQKj82d3tuzqdGNRsLJ4Gw==", 397 | "optional": true, 398 | "requires": { 399 | "sparse-bitfield": "^3.0.3" 400 | } 401 | }, 402 | "semver": { 403 | "version": "5.6.0", 404 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", 405 | "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" 406 | }, 407 | "send": { 408 | "version": "0.16.2", 409 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", 410 | "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", 411 | "requires": { 412 | "debug": "2.6.9", 413 | "depd": "~1.1.2", 414 | "destroy": "~1.0.4", 415 | "encodeurl": "~1.0.2", 416 | "escape-html": "~1.0.3", 417 | "etag": "~1.8.1", 418 | "fresh": "0.5.2", 419 | "http-errors": "~1.6.2", 420 | "mime": "1.4.1", 421 | "ms": "2.0.0", 422 | "on-finished": "~2.3.0", 423 | "range-parser": "~1.2.0", 424 | "statuses": "~1.4.0" 425 | }, 426 | "dependencies": { 427 | "statuses": { 428 | "version": "1.4.0", 429 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 430 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 431 | } 432 | } 433 | }, 434 | "serve-static": { 435 | "version": "1.13.2", 436 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", 437 | "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", 438 | "requires": { 439 | "encodeurl": "~1.0.2", 440 | "escape-html": "~1.0.3", 441 | "parseurl": "~1.3.2", 442 | "send": "0.16.2" 443 | } 444 | }, 445 | "setprototypeof": { 446 | "version": "1.1.0", 447 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", 448 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" 449 | }, 450 | "sparse-bitfield": { 451 | "version": "3.0.3", 452 | "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", 453 | "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", 454 | "optional": true, 455 | "requires": { 456 | "memory-pager": "^1.0.2" 457 | } 458 | }, 459 | "statuses": { 460 | "version": "1.5.0", 461 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 462 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" 463 | }, 464 | "topo": { 465 | "version": "3.0.3", 466 | "resolved": "https://registry.npmjs.org/topo/-/topo-3.0.3.tgz", 467 | "integrity": "sha512-IgpPtvD4kjrJ7CRA3ov2FhWQADwv+Tdqbsf1ZnPUSAtCJ9e1Z44MmoSGDXGk4IppoZA7jd/QRkNddlLJWlUZsQ==", 468 | "requires": { 469 | "hoek": "6.x.x" 470 | } 471 | }, 472 | "type-is": { 473 | "version": "1.6.16", 474 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", 475 | "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", 476 | "requires": { 477 | "media-typer": "0.3.0", 478 | "mime-types": "~2.1.18" 479 | } 480 | }, 481 | "unpipe": { 482 | "version": "1.0.0", 483 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 484 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 485 | }, 486 | "util": { 487 | "version": "0.10.4", 488 | "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", 489 | "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", 490 | "requires": { 491 | "inherits": "2.0.3" 492 | } 493 | }, 494 | "utils-merge": { 495 | "version": "1.0.1", 496 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 497 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 498 | }, 499 | "vary": { 500 | "version": "1.1.2", 501 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 502 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 503 | } 504 | } 505 | } 506 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongodb_crud", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "body-parser": "^1.18.3", 14 | "express": "^4.16.4", 15 | "joi": "^14.3.0", 16 | "mongodb": "^3.1.10", 17 | "path": "^0.12.7" 18 | } 19 | } 20 | --------------------------------------------------------------------------------