From cd0f79226c6102759babc113a112db9c7b4ca0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDavid?= <“davejh76@gmail.com”> Date: Tue, 30 Jul 2019 09:09:45 -0400 Subject: [PATCH 1/4] start --- index.js | 15 ++ package-lock.json | 499 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 20 +- 3 files changed, 511 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 8cdc499..5e3d129 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,19 @@ +const express = require("express"); +const app = express(); + + +app.get("/", function(req, res) { + res.send("hello world"); +}); + + + + + + + app.listen(3000, () => console.log('app is running')) + // DO NOT REMOVE THIS LINE: module.exports = app diff --git a/package-lock.json b/package-lock.json index 108c402..57f252d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,15 @@ "@types/node": "*" } }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, "ansi-colors": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", @@ -62,12 +71,25 @@ "sprintf-js": "~1.0.2" } }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "requires": { + "lodash": "^4.17.11" + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -80,6 +102,28 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -96,6 +140,16 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "bson": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", + "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -218,6 +272,29 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, "cookiejar": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", @@ -253,7 +330,6 @@ "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, "requires": { "ms": "2.0.0" } @@ -288,18 +364,38 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", @@ -334,6 +430,11 @@ "is-symbol": "^1.0.2" } }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -346,6 +447,11 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, "execa": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", @@ -361,12 +467,63 @@ "strip-eof": "^1.0.0" } }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -402,6 +559,16 @@ "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==", "dev": true }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -482,6 +649,26 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -495,8 +682,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "invert-kv": { "version": "2.0.0", @@ -510,6 +696,11 @@ "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", "dev": true }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, "is-buffer": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", @@ -589,6 +780,11 @@ "esprima": "^4.0.0" } }, + "kareem": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.0.tgz", + "integrity": "sha512-6hHxsp9e6zQU8nXsP+02HGWXwTkOEw6IROhF2ZA28cYbUk4eJ6QbtZvdqZOdD9YPKghG3apk5eOCvs+tLl3lRg==" + }, "lcid": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", @@ -611,8 +807,7 @@ "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, "log-symbols": { "version": "2.2.0", @@ -651,6 +846,11 @@ } } }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, "mem": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", @@ -662,29 +862,36 @@ "p-is-promise": "^2.0.0" } }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", - "dev": true + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", - "dev": true + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { "version": "2.1.24", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "dev": true, "requires": { "mime-db": "1.40.0" } @@ -780,11 +987,94 @@ "xml": "^1.0.0" } }, + "mongodb": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.7.tgz", + "integrity": "sha512-2YdWrdf1PJgxcCrT1tWoL6nHuk6hCxhddAAaEh8QJL231ci4+P9FLyqopbTm2Z2sAU6mhCri+wd9r1hOcHdoMw==", + "requires": { + "mongodb-core": "3.2.7", + "safe-buffer": "^5.1.2" + } + }, + "mongodb-core": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.7.tgz", + "integrity": "sha512-WypKdLxFNPOH/Jy6i9z47IjG2wIldA54iDZBmHMINcgKOUcWJh8og+Wix76oGd7EyYkHJKssQ2FAOw5Su/n4XQ==", + "requires": { + "bson": "^1.1.1", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + } + }, + "mongoose": { + "version": "5.6.7", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.6.7.tgz", + "integrity": "sha512-42rbdZ9HLBbGjLvRSB4voqemgFkJTIyqSLLcJARKs1zdQzEJ3O77dWRllIy2bSo35GcY17ihEdoJX27pDqu3Mg==", + "requires": { + "async": "2.6.2", + "bson": "~1.1.1", + "kareem": "2.3.0", + "mongodb": "3.2.7", + "mongodb-core": "3.2.7", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.6.0", + "mquery": "3.2.1", + "ms": "2.1.2", + "regexp-clone": "1.0.0", + "safe-buffer": "5.1.2", + "sift": "7.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "mongoose-legacy-pluralize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", + "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" + }, + "mpath": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", + "integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==" + }, + "mquery": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.1.tgz", + "integrity": "sha512-kY/K8QToZWTTocm0U+r8rqcJCp5PRl6e8tPmoDs5OeSO3DInZE2rAL6AYH+V406JTo8305LdASOQcxRDqHojyw==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "^1.0.0", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, "nice-try": { "version": "1.0.5", @@ -845,6 +1135,14 @@ "es-abstract": "^1.5.1" } }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -907,6 +1205,11 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -925,6 +1228,11 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, "pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", @@ -937,6 +1245,15 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -950,8 +1267,23 @@ "qs": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", - "dev": true + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } }, "readable-stream": { "version": "2.3.6", @@ -968,6 +1300,11 @@ "util-deprecate": "~1.0.1" } }, + "regexp-clone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", + "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==" + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -980,17 +1317,81 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "^2.0.0", + "semver": "^5.1.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } }, "semver": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } }, "set-blocking": { "version": "2.0.0", @@ -998,6 +1399,11 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -1013,18 +1419,42 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, + "sift": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", + "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -1109,18 +1539,47 @@ "has-flag": "^3.0.0" } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/package.json b/package.json index c8c272c..dda1e47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "checkpoint-express-mongoose", "version": "1.0.0", - "description": "", + "description": "## Set Up", "main": "index.js", "scripts": { "test": "./node_modules/mocha/bin/mocha --exit test/*.js" @@ -9,11 +9,25 @@ "keywords": [], "author": "", "license": "ISC", - "dependencies": {}, + "dependencies": { + "express": "^4.17.1", + "mongoose": "^5.6.7" + }, "devDependencies": { "chai": "*", "chai-http": "^4.3.0", "mocha": "*", "mocha-junit-reporter": "*" - } + }, + "directories": { + "test": "test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/DJHUTCHINGS/checkpoint-express-mongoose-short.git" + }, + "bugs": { + "url": "https://github.com/DJHUTCHINGS/checkpoint-express-mongoose-short/issues" + }, + "homepage": "https://github.com/DJHUTCHINGS/checkpoint-express-mongoose-short#readme" } From 25c3b1d315c77e8a605763e293c040676c45358e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDavid?= <“davejh76@gmail.com”> Date: Tue, 30 Jul 2019 09:29:05 -0400 Subject: [PATCH 2/4] models possibly done --- controllers/notes.js | 0 controllers/users.js | 0 index.js | 10 +++++++--- models/Note.js | 10 +++++++++- models/User.js | 18 +++++++++++++++++- routes/notes.js | 23 +++++++++++++++++++++++ routes/users.js | 25 +++++++++++++++++++++++++ 7 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 controllers/notes.js create mode 100644 controllers/users.js create mode 100644 routes/notes.js create mode 100644 routes/users.js diff --git a/controllers/notes.js b/controllers/notes.js new file mode 100644 index 0000000..e69de29 diff --git a/controllers/users.js b/controllers/users.js new file mode 100644 index 0000000..e69de29 diff --git a/index.js b/index.js index 5e3d129..3f7b360 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,21 @@ const express = require("express"); +const parser = require('body-parser') const app = express(); +app.use(parser.urlencoded({extended: true})) +app.use(parser.json()) + +//temp app app.get("/", function(req, res) { + res.send("hello world"); + }); - - - app.listen(3000, () => console.log('app is running')) diff --git a/models/Note.js b/models/Note.js index 434378a..8f16e8c 100644 --- a/models/Note.js +++ b/models/Note.js @@ -1,5 +1,13 @@ const mongoose = require('../db/connection') -const noteSchema = new mongoose.Schema({}) +const noteSchema = new mongoose.Schema({ + title: String, + body: String, + author: [{ + type: Schema.Types.ObjectId, + ref: "User" + }] +}) module.exports = mongoose.model('Note', noteSchema) + diff --git a/models/User.js b/models/User.js index 7a0c8b7..d7cadd4 100644 --- a/models/User.js +++ b/models/User.js @@ -1,5 +1,21 @@ const mongoose = require('../db/connection') -const userSchema = new mongoose.Schema({}) +const userSchema = new mongoose.Schema({ + username: String, + email: String, + notes: [{ + type: Schema.Types.ObjectId, + ref: “Note” + }] +}) + + + + module.exports = mongoose.model('User', userSchema) + + + + + diff --git a/routes/notes.js b/routes/notes.js new file mode 100644 index 0000000..0eb947f --- /dev/null +++ b/routes/notes.js @@ -0,0 +1,23 @@ + + + + + + + + + +// const express = require("express"); +// const router = express.Router(); +// const myController = require("../controllers/todo.js"); + +// router.get("/", myController.index); +// router.get("/new", myController.new); +// router.post("/", myController.create); +// router.get("/:id", myController.show); +// router.get("/:id/edit", myController.edit); +// router.put("/:id", myController.update); +// router.destroy("/:id", myController.destroy); + +// module.exports = router; + diff --git a/routes/users.js b/routes/users.js new file mode 100644 index 0000000..0e15968 --- /dev/null +++ b/routes/users.js @@ -0,0 +1,25 @@ + + + + + + + + + + + +// const express = require("express"); +// const router = express.Router(); +// const myController = require("../controllers/todo.js"); + +// router.get("/", myController.index); +// router.get("/new", myController.new); +// router.post("/", myController.create); +// router.get("/:id", myController.show); +// router.get("/:id/edit", myController.edit); +// router.put("/:id", myController.update); +// router.destroy("/:id", myController.destroy); + +// module.exports = router; + From 28f97723c127a5d91e555c976d6dab3ee58ab647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDavid?= <“davejh76@gmail.com”> Date: Tue, 30 Jul 2019 09:57:48 -0400 Subject: [PATCH 3/4] more basic stuff set up --- controllers/notes.js | 49 ++++++++++++++++++++++++++++++++++++++++++++ controllers/users.js | 45 ++++++++++++++++++++++++++++++++++++++++ index.js | 13 ++++++++++++ models/Note.js | 4 ++-- package-lock.json | 14 +++++++++++++ package.json | 1 + routes/notes.js | 31 ++++++++++++++-------------- routes/users.js | 30 +++++++++++++-------------- 8 files changed, 154 insertions(+), 33 deletions(-) diff --git a/controllers/notes.js b/controllers/notes.js index e69de29..825461f 100644 --- a/controllers/notes.js +++ b/controllers/notes.js @@ -0,0 +1,49 @@ + +const { Note, User } = require("../models"); +//if needed +// const queryOptions = require("../utils/queryOptions"); + + +module.exports = { + index: function(req, res) { + // listing all of some stuff + }, + show: function(req, res) { + // displaying the data for a single something + } +}; + + + + + + + + +//probably not needed + + +// module.exports = { + // index: function(req, res) { + // // listing all of some stuff + // }, +// new: function(req, res) { +// // rending the form to create a new entry of some kind +// }, +// create: function(req, res) { +// // creating a new entry of something and saving it to the db +// }, + // show: function(req, res) { + // // displaying the data for a single something + // }, +// edit: function(req, res) { +// // rendering the form to update an existing something +// }, +// update: function(req, res) { +// // updating an entry/document/thing in the database +// }, +// destroy: function(req, res) { +// // deleting an entry/docuemt/something +// } +// }; + \ No newline at end of file diff --git a/controllers/users.js b/controllers/users.js index e69de29..8640878 100644 --- a/controllers/users.js +++ b/controllers/users.js @@ -0,0 +1,45 @@ + +const { Note, User } = require("../models"); +//if needed +// const queryOptions = require("../utils/queryOptions"); + +module.exports = { + index: function(req, res) { + // listing all of some stuff + }, + show: function(req, res) { + // displaying the data for a single something + } +}; + + + + + + + + +// module.exports = { +// index: function(req, res) { +// // listing all of some stuff +// }, +// new: function(req, res) { +// // rending the form to create a new entry of some kind +// }, +// create: function(req, res) { +// // creating a new entry of something and saving it to the db +// }, +// show: function(req, res) { +// // displaying the data for a single something +// }, +// edit: function(req, res) { +// // rendering the form to update an existing something +// }, +// update: function(req, res) { +// // updating an entry/document/thing in the database +// }, +// destroy: function(req, res) { +// // deleting an entry/docuemt/something +// } +// }; + \ No newline at end of file diff --git a/index.js b/index.js index 3f7b360..024e9c3 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const express = require("express"); const parser = require('body-parser') const app = express(); +const cors = require('cors') app.use(parser.urlencoded({extended: true})) app.use(parser.json()) @@ -13,7 +14,19 @@ app.get("/", function(req, res) { }); +app.use(cors()) +// possible first app - redirect to notes - -still crashes nodemon +// app.get("/", (req, res) => { +// res.redirect(“/routes/notes); +// }); + + + + +//not yet set up and not sure if needed +// app.use(“/notes", require("./routes/notes")); +// app.use(“/users", require("./routes/users")); app.listen(3000, () => console.log('app is running')) diff --git a/models/Note.js b/models/Note.js index 8f16e8c..b213f2b 100644 --- a/models/Note.js +++ b/models/Note.js @@ -3,10 +3,10 @@ const mongoose = require('../db/connection') const noteSchema = new mongoose.Schema({ title: String, body: String, - author: [{ + author: { type: Schema.Types.ObjectId, ref: "User" - }] + } }) module.exports = mongoose.model('Note', noteSchema) diff --git a/package-lock.json b/package-lock.json index 57f252d..5407966 100644 --- a/package-lock.json +++ b/package-lock.json @@ -307,6 +307,15 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -1107,6 +1116,11 @@ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", diff --git a/package.json b/package.json index dda1e47..511dc94 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "", "license": "ISC", "dependencies": { + "cors": "^2.8.5", "express": "^4.17.1", "mongoose": "^5.6.7" }, diff --git a/routes/notes.js b/routes/notes.js index 0eb947f..b91c213 100644 --- a/routes/notes.js +++ b/routes/notes.js @@ -1,23 +1,22 @@ +const express = require("express"); +const router = express.Router(); +const notesController = require("../controllers/notes.js"); +//to get list of all notes - - not yet set up +router.get("/notes", notesController.index); +//to get a note by ID - - not yet set up +router.get("/:noteId", notesController.show); +//these probably not needed +// router.get("/new", notesController.new); +// router.post("/", notesController.create); +// +// router.get("/:id/edit", notesController.edit); +// router.put("/:id", notesController.update); +// router.destroy("/:id", notesController.destroy); - - - -// const express = require("express"); -// const router = express.Router(); -// const myController = require("../controllers/todo.js"); - -// router.get("/", myController.index); -// router.get("/new", myController.new); -// router.post("/", myController.create); -// router.get("/:id", myController.show); -// router.get("/:id/edit", myController.edit); -// router.put("/:id", myController.update); -// router.destroy("/:id", myController.destroy); - -// module.exports = router; +module.exports = router; diff --git a/routes/users.js b/routes/users.js index 0e15968..8bebe98 100644 --- a/routes/users.js +++ b/routes/users.js @@ -1,25 +1,25 @@ +const express = require("express"); +const router = express.Router(); +const usersController = require("../controllers/users.js"); +//to get a list of all users - - not yet set up +router.get("/users", usersController.index); +//to get a user by ID - - not yet set up +router.get("/:uersId", notesController.show); +//these probably not needed +// router.get("/new", usersController.new); +// router.post("/", usersController.create); +// router.get("/:id", usersController.show); +// router.get("/:id/edit", usersController.edit); +// router.put("/:id", usersController.update); +// router.destroy("/:id", usersController.destroy); - - -// const express = require("express"); -// const router = express.Router(); -// const myController = require("../controllers/todo.js"); - -// router.get("/", myController.index); -// router.get("/new", myController.new); -// router.post("/", myController.create); -// router.get("/:id", myController.show); -// router.get("/:id/edit", myController.edit); -// router.put("/:id", myController.update); -// router.destroy("/:id", myController.destroy); - -// module.exports = router; +module.exports = router; From abe0dd1ad58d85cad1fb42b2de574d97e00ddea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDavid?= <“davejh76@gmail.com”> Date: Tue, 30 Jul 2019 10:28:13 -0400 Subject: [PATCH 4/4] close to basic set up --- controllers/notes.js | 44 ++++---------------------------------------- controllers/users.js | 36 ++---------------------------------- index.js | 16 ++++++++-------- models/Note.js | 3 ++- models/User.js | 7 ++----- routes/notes.js | 9 --------- routes/users.js | 13 +------------ 7 files changed, 19 insertions(+), 109 deletions(-) diff --git a/controllers/notes.js b/controllers/notes.js index 825461f..4a596aa 100644 --- a/controllers/notes.js +++ b/controllers/notes.js @@ -1,49 +1,13 @@ +const Note = require("../models/Note.js"); +// const User = require("../models.User.js"); -const { Note, User } = require("../models"); -//if needed -// const queryOptions = require("../utils/queryOptions"); module.exports = { index: function(req, res) { - // listing all of some stuff + res.send("hello world"); }, show: function(req, res) { - // displaying the data for a single something + res.send("hello world"); } }; - - - - - - - - -//probably not needed - - -// module.exports = { - // index: function(req, res) { - // // listing all of some stuff - // }, -// new: function(req, res) { -// // rending the form to create a new entry of some kind -// }, -// create: function(req, res) { -// // creating a new entry of something and saving it to the db -// }, - // show: function(req, res) { - // // displaying the data for a single something - // }, -// edit: function(req, res) { -// // rendering the form to update an existing something -// }, -// update: function(req, res) { -// // updating an entry/document/thing in the database -// }, -// destroy: function(req, res) { -// // deleting an entry/docuemt/something -// } -// }; - \ No newline at end of file diff --git a/controllers/users.js b/controllers/users.js index 8640878..ab9b4a9 100644 --- a/controllers/users.js +++ b/controllers/users.js @@ -5,41 +5,9 @@ const { Note, User } = require("../models"); module.exports = { index: function(req, res) { - // listing all of some stuff + res.send("hello world"); }, show: function(req, res) { - // displaying the data for a single something + res.send("hello world"); } }; - - - - - - - - -// module.exports = { -// index: function(req, res) { -// // listing all of some stuff -// }, -// new: function(req, res) { -// // rending the form to create a new entry of some kind -// }, -// create: function(req, res) { -// // creating a new entry of something and saving it to the db -// }, -// show: function(req, res) { -// // displaying the data for a single something -// }, -// edit: function(req, res) { -// // rendering the form to update an existing something -// }, -// update: function(req, res) { -// // updating an entry/document/thing in the database -// }, -// destroy: function(req, res) { -// // deleting an entry/docuemt/something -// } -// }; - \ No newline at end of file diff --git a/index.js b/index.js index 024e9c3..c359931 100644 --- a/index.js +++ b/index.js @@ -8,25 +8,25 @@ app.use(parser.json()) //temp app -app.get("/", function(req, res) { +// app.get("/", function(req, res) { - res.send("hello world"); +// res.send("hello world"); -}); +// }); app.use(cors()) // possible first app - redirect to notes - -still crashes nodemon -// app.get("/", (req, res) => { -// res.redirect(“/routes/notes); -// }); +app.get("/", (req, res) => { + res.redirect("/notes"); + }); //not yet set up and not sure if needed -// app.use(“/notes", require("./routes/notes")); -// app.use(“/users", require("./routes/users")); +app.get("/notes", require("./routes/notes.js")); +// app.use("/users", require("./routes/users")); app.listen(3000, () => console.log('app is running')) diff --git a/models/Note.js b/models/Note.js index b213f2b..d463310 100644 --- a/models/Note.js +++ b/models/Note.js @@ -1,4 +1,5 @@ const mongoose = require('../db/connection') +const Schema = mongoose.Schema; const noteSchema = new mongoose.Schema({ title: String, @@ -10,4 +11,4 @@ const noteSchema = new mongoose.Schema({ }) module.exports = mongoose.model('Note', noteSchema) - +// module.exports = noteSchema; diff --git a/models/User.js b/models/User.js index d7cadd4..aae93fa 100644 --- a/models/User.js +++ b/models/User.js @@ -1,4 +1,5 @@ const mongoose = require('../db/connection') +// const Schema = mongoose.Schema; const userSchema = new mongoose.Schema({ username: String, @@ -9,12 +10,8 @@ const userSchema = new mongoose.Schema({ }] }) - - - - module.exports = mongoose.model('User', userSchema) - +// module.exports = userSchema; diff --git a/routes/notes.js b/routes/notes.js index b91c213..ff2e749 100644 --- a/routes/notes.js +++ b/routes/notes.js @@ -9,14 +9,5 @@ router.get("/notes", notesController.index); //to get a note by ID - - not yet set up router.get("/:noteId", notesController.show); - -//these probably not needed -// router.get("/new", notesController.new); -// router.post("/", notesController.create); -// -// router.get("/:id/edit", notesController.edit); -// router.put("/:id", notesController.update); -// router.destroy("/:id", notesController.destroy); - module.exports = router; diff --git a/routes/users.js b/routes/users.js index 8bebe98..6ba21ea 100644 --- a/routes/users.js +++ b/routes/users.js @@ -7,19 +7,8 @@ const usersController = require("../controllers/users.js"); router.get("/users", usersController.index); //to get a user by ID - - not yet set up -router.get("/:uersId", notesController.show); +router.get("/:userId", notesController.show); - - -//these probably not needed - -// router.get("/new", usersController.new); -// router.post("/", usersController.create); -// router.get("/:id", usersController.show); -// router.get("/:id/edit", usersController.edit); -// router.put("/:id", usersController.update); -// router.destroy("/:id", usersController.destroy); - module.exports = router;