From 8f9afaf563f23de8abff0a2aa88cace1dad82a55 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Fri, 6 Oct 2017 10:40:07 -0500 Subject: [PATCH 01/15] git initialized --- package-lock.json | 566 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 566 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..35ba7c7 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,566 @@ +{ + "name": "custom-api", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", + "requires": { + "mime-types": "2.1.17", + "negotiator": "0.6.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "async": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz", + "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=", + "requires": { + "lodash": "4.17.4" + } + }, + "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.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.1", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.15" + } + }, + "bson": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz", + "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw=" + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "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.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "dotenv": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", + "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" + }, + "es6-promise": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", + "integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.1.tgz", + "integrity": "sha512-STB7LZ4N0L+81FJHGla2oboUHTk4PaN1RsOkoRh9OSeEKylvF5hwKYVX1xCLFaCT7MD0BNG/gX2WFMLqY6EMBw==", + "requires": { + "accepts": "1.3.4", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.1", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.0", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.2", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.1", + "serve-static": "1.13.1", + "setprototypeof": "1.1.0", + "statuses": "1.3.1", + "type-is": "1.6.15", + "utils-merge": "1.0.1", + "vary": "1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.1", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.15" + } + } + } + }, + "finalhandler": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.3.1", + "unpipe": "1.0.0" + } + }, + "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=" + }, + "hooks-fixed": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.0.tgz", + "integrity": "sha1-oB2JTVKsf2WZu7H2PfycQR33DLo=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.3.1" + }, + "dependencies": { + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", + "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "kareem": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz", + "integrity": "sha1-4+QQHZ3P3imXadr0tNtk2JXRdEg=" + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "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=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "requires": { + "mime-db": "1.30.0" + } + }, + "mongodb": { + "version": "2.2.31", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.31.tgz", + "integrity": "sha1-GUBEXGYeGSF7s7+CRdmFSq71SNs=", + "requires": { + "es6-promise": "3.2.1", + "mongodb-core": "2.1.15", + "readable-stream": "2.2.7" + } + }, + "mongodb-core": { + "version": "2.1.15", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.15.tgz", + "integrity": "sha1-hB9TuH//9MdFgYnDXIroJ+EWl2Q=", + "requires": { + "bson": "1.0.4", + "require_optional": "1.0.1" + } + }, + "mongoose": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.12.0.tgz", + "integrity": "sha1-ul3POxM4yEmC+XdMEMoEkxAs2DA=", + "requires": { + "async": "2.1.4", + "bson": "1.0.4", + "hooks-fixed": "2.0.0", + "kareem": "1.5.0", + "mongodb": "2.2.31", + "mpath": "0.3.0", + "mpromise": "0.5.5", + "mquery": "2.3.2", + "ms": "2.0.0", + "muri": "1.2.2", + "regexp-clone": "0.0.1", + "sliced": "1.0.1" + } + }, + "mpath": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.3.0.tgz", + "integrity": "sha1-elj3iem1/TyUUgY0FXlg8mvV70Q=" + }, + "mpromise": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz", + "integrity": "sha1-9bJCWddjrMIlewoMjG2Gb9UXMuY=" + }, + "mquery": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.2.tgz", + "integrity": "sha512-KXWMypZSvhCuqRtza+HMQZdYw7PfFBjBTFvP31NNAq0OX0/NTIgpcDpkWQ2uTxk6vGQtwQ2elhwhs+ZvCA8OaA==", + "requires": { + "bluebird": "3.5.1", + "debug": "2.6.9", + "regexp-clone": "0.0.1", + "sliced": "0.0.5" + }, + "dependencies": { + "sliced": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", + "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8=" + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "muri": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/muri/-/muri-1.2.2.tgz", + "integrity": "sha1-YxmBMmUNsIoEzHnM0A3Tia/SYxw=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "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" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "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=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "proxy-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", + "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.5.2" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + } + }, + "readable-stream": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz", + "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=", + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "regexp-clone": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", + "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk=" + }, + "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.4.1" + } + }, + "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.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + }, + "send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.1", + "destroy": "1.0.4", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.3.1" + } + }, + "serve-static": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", + "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", + "requires": { + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.1" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.17" + } + }, + "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=" + }, + "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=" + } + } +} From bd76c8a2a42f158510933d8dcc7a404a5b08b195 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Fri, 6 Oct 2017 12:10:16 -0500 Subject: [PATCH 02/15] deploying app to heroku with packages --- package-lock.json | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-lock.json b/package-lock.json index 35ba7c7..f72370b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -116,6 +116,11 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, + "ejs": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.5.7.tgz", + "integrity": "sha1-zIcsFoiArjxxiXYv1f/ACJbJUYo=" + }, "encodeurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", diff --git a/package.json b/package.json index 7027857..f137a0a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "body-parser": "^1.18.2", "dotenv": "^4.0.0", + "ejs": "^2.5.7", "express": "^4.16.1", "mongoose": "^4.12.0" } From 59c2cb37f4910d3abdfa217c39afd4f0d7dc2ca3 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Fri, 6 Oct 2017 14:40:49 -0500 Subject: [PATCH 03/15] adding fish --- server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 3978150..8823595 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,4 @@ -// dependencies +her// dependencies const express = require('express'); const bodyParser = require('body-parser'); @@ -11,10 +11,11 @@ app.use(bodyParser.json()); // you can add route handlers directly in this file like this: app.get('/', function(req, res) { res.json({ - message: 'Hello, world!', + message: 'Hello, fish!', type: 'greeting', time: new Date() }); + }); // or you can import route handlers from other files like this: const testRoutes = require('./routes/test'); From 5f9ad46d82259ff879bd5de259fbab35eb222ac7 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Fri, 6 Oct 2017 15:07:29 -0500 Subject: [PATCH 04/15] added fix, removed her typo --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 8823595..f5fabfe 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,4 @@ -her// dependencies +// dependencies const express = require('express'); const bodyParser = require('body-parser'); From 947a60f3f5585433301e81ad727645f9a182d3a5 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Fri, 6 Oct 2017 21:19:17 -0500 Subject: [PATCH 05/15] adding artist model and routes --- models/artist.js | 36 ++++++++++++++++++++++++++++++++++++ models/index.js | 16 +++++++++++----- models/test.js | 10 +++++----- routes/artist.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 21 +++++++++++++-------- 5 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 models/artist.js create mode 100644 routes/artist.js diff --git a/models/artist.js b/models/artist.js new file mode 100644 index 0000000..f81058d --- /dev/null +++ b/models/artist.js @@ -0,0 +1,36 @@ +const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page + +const ArtistSchema = new mongoose.Schema({ + userName: { type: String, require: true, unique: true }, + firstName: String, + lastName: String, + email: { type: String, require: true, unique: true }, + city: String, + bio: String + // Artworks: [{ + // type: mongoose.Schema.Types.ObjectId, + // ref: 'Art' + // }] +}) + + +// const ArtistSchema = new mongoose.Schema({ //2 how does my data look/get stored as a variable +// name: { +// type: String, +// required: cltrue +// }, +// count: { +// type: Number, +// default: 42 +// }, +// time: { +// type: Date, +// default: Date.now +// } +// }); + +const Artist = mongoose.model('Artist', ArtistSchema); // lets make a model a thing + +module.exports = { // lets export that model + Artist: Artist +} diff --git a/models/index.js b/models/index.js index 84420bf..4d14597 100644 --- a/models/index.js +++ b/models/index.js @@ -1,9 +1,14 @@ -const mongoose = require('mongoose'); -require('dotenv').config(); + + +const mongoose = require('mongoose'); //need dependeny mongoose +require('dotenv').config(); //need dot env because we connect db down here + + // TODO: include all model files here (and export models together below) const testModels = require('./test'); +const artistModels = require('./artist'); -// connect to Mongo DB +// connect to Mongo DB // processes from my .env failsafe db (why? just cuz..) mongoose.connection.openUri(process.env.MONGODB_URI || process.env.DB_CONN, {}, function(err, conn) { if (err) { console.log('Error connecting to Mongo DB.', err); @@ -12,7 +17,8 @@ mongoose.connection.openUri(process.env.MONGODB_URI || process.env.DB_CONN, {}, } }); -module.exports = { +module.exports = { // export this stuff so your server.js can see all the models. no // TODO: add references to all models here - Test: testModels.Test + Test: testModels.Test, + Artist: artistModels.Artist }; diff --git a/models/test.js b/models/test.js index f6e5c91..b72b142 100644 --- a/models/test.js +++ b/models/test.js @@ -1,9 +1,9 @@ -const mongoose = require('mongoose'); +const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page -const TestSchema = new mongoose.Schema({ +const TestSchema = new mongoose.Schema({ //2 how does my data look/get stored as a variable name: { type: String, - required: true + required: cltrue }, count: { type: Number, @@ -15,8 +15,8 @@ const TestSchema = new mongoose.Schema({ } }); -const Test = mongoose.model('Test', TestSchema); +const Test = mongoose.model('Test', TestSchema); // lets make a model a thing -module.exports = { +module.exports = { // lets export that model Test: Test } diff --git a/routes/artist.js b/routes/artist.js new file mode 100644 index 0000000..4832f72 --- /dev/null +++ b/routes/artist.js @@ -0,0 +1,48 @@ +//require models to connect data +const db = require('..models'); + +/*functions that handle data requests from routers on server.js +all go here */ +function getArtistItem(req, res) { + db.Artist.find({}, function(err,data) { + if (err) { + console.log('Error retrieving Artist items from DB.', err); + res.status(500).send('Internal server error'); + } else { + res.json(data); + } + }); +} + + +//export to make your data results available. +module.exports = { + getArtistItems: getArtistItems //, + //createArtistItem: createArtistItem +} + + + + + + +/* Remaining create / post functionality lets add this LAAAAAASSSST. + +function createTestItem(req, res) { + const newTestItem = db.Test({ + name: req.body.name, + count: req.body.count, + time: req.body.time, + }); + + newTestItem.save(function(err, data) { + if (err) { + console.log('Error saving test item to DB.', err); + res.status(500).send('Internal server error'); + } else { + res.status(201).json(data); + } + }); +} + +*/ diff --git a/server.js b/server.js index f5fabfe..fcc00d0 100644 --- a/server.js +++ b/server.js @@ -9,19 +9,24 @@ app.use(bodyParser.json()); // app routes // you can add route handlers directly in this file like this: -app.get('/', function(req, res) { - res.json({ - message: 'Hello, fish!', - type: 'greeting', - time: new Date() - }); +// app.get('/', function(req, res) { +// res.json({ +// message: 'Hello, fish!', +// type: 'greeting', +// time: new Date() +// }); +// }); -}); -// or you can import route handlers from other files like this: +// Test Controller const testRoutes = require('./routes/test'); app.get('/test', testRoutes.getTestItems); app.post('/test', testRoutes.createTestItem); +//Artist Controlller +const artistRoutes = requie('./routes/artist'); +app.get('/artist', artistRoutes.getArtistItems); +//any other artist functions added here. + // TODO: delete the above dummy routes and add your actual routes // start app From ad0fac65e06a36055a6d1791c24547dd0fd6e2ee Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Fri, 6 Oct 2017 21:20:55 -0500 Subject: [PATCH 06/15] fixing typos --- models/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/test.js b/models/test.js index b72b142..f5f7c27 100644 --- a/models/test.js +++ b/models/test.js @@ -3,7 +3,7 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to const TestSchema = new mongoose.Schema({ //2 how does my data look/get stored as a variable name: { type: String, - required: cltrue + required: true }, count: { type: Number, From 7904fe6176a2a81dae492d3c885d186749fd9e72 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Sat, 7 Oct 2017 11:16:46 -0500 Subject: [PATCH 07/15] updating app with models and routes for all database --- models/artist.js | 34 +++++++--------------------------- models/artwork.js | 16 ++++++++++++++++ models/index.js | 7 +++---- models/test.js | 15 +++------------ routes/artist.js | 45 ++++++++++++++++++++------------------------- routes/artwork.js | 38 ++++++++++++++++++++++++++++++++++++++ routes/test.js | 3 +-- server.js | 23 +++++++++++++---------- 8 files changed, 101 insertions(+), 80 deletions(-) create mode 100644 models/artwork.js create mode 100644 routes/artwork.js diff --git a/models/artist.js b/models/artist.js index f81058d..c4d1216 100644 --- a/models/artist.js +++ b/models/artist.js @@ -1,33 +1,13 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page const ArtistSchema = new mongoose.Schema({ - userName: { type: String, require: true, unique: true }, - firstName: String, - lastName: String, - email: { type: String, require: true, unique: true }, - city: String, - bio: String - // Artworks: [{ - // type: mongoose.Schema.Types.ObjectId, - // ref: 'Art' - // }] -}) - - -// const ArtistSchema = new mongoose.Schema({ //2 how does my data look/get stored as a variable -// name: { -// type: String, -// required: cltrue -// }, -// count: { -// type: Number, -// default: 42 -// }, -// time: { -// type: Date, -// default: Date.now -// } -// }); + firstName: String, + lastName: String, + portraitImg: String, + hometown: String, + bio: String + //artworks: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Artwork' }] +}); const Artist = mongoose.model('Artist', ArtistSchema); // lets make a model a thing diff --git a/models/artwork.js b/models/artwork.js new file mode 100644 index 0000000..b2a33b6 --- /dev/null +++ b/models/artwork.js @@ -0,0 +1,16 @@ +const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page + +const ArtworkSchema = new mongoose.Schema({ + artName: { type: String, required: true }, + imageUrl: { type: String, default: "" }, + tags: [{ type: String, default: "" }], + location: { type: String, default: ""}, + //Artist: ArtistSchema +}); + +const Artwork = mongoose.model('Artwork', ArtworkSchema); // lets make a model a thing + +module.exports = { // lets export that model + Artwork: Artwork +} + diff --git a/models/index.js b/models/index.js index 4d14597..be73010 100644 --- a/models/index.js +++ b/models/index.js @@ -1,12 +1,10 @@ - - const mongoose = require('mongoose'); //need dependeny mongoose require('dotenv').config(); //need dot env because we connect db down here - // TODO: include all model files here (and export models together below) const testModels = require('./test'); const artistModels = require('./artist'); +const artworkModels = require('./artwork'); // connect to Mongo DB // processes from my .env failsafe db (why? just cuz..) mongoose.connection.openUri(process.env.MONGODB_URI || process.env.DB_CONN, {}, function(err, conn) { @@ -20,5 +18,6 @@ mongoose.connection.openUri(process.env.MONGODB_URI || process.env.DB_CONN, {}, module.exports = { // export this stuff so your server.js can see all the models. no // TODO: add references to all models here Test: testModels.Test, - Artist: artistModels.Artist + Artist: artistModels.Artist, + Artwork: artworkModels.Artwork }; diff --git a/models/test.js b/models/test.js index f5f7c27..0cad59d 100644 --- a/models/test.js +++ b/models/test.js @@ -1,18 +1,9 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page const TestSchema = new mongoose.Schema({ //2 how does my data look/get stored as a variable - name: { - type: String, - required: true - }, - count: { - type: Number, - default: 42 - }, - time: { - type: Date, - default: Date.now - } + name: { type: String, required: true }, + count: { type: Number, default: 42 }, + time: { type: Date, default: Date.now } }); const Test = mongoose.model('Test', TestSchema); // lets make a model a thing diff --git a/routes/artist.js b/routes/artist.js index 4832f72..7649d2c 100644 --- a/routes/artist.js +++ b/routes/artist.js @@ -1,9 +1,9 @@ //require models to connect data -const db = require('..models'); +const db = require('../models'); /*functions that handle data requests from routers on server.js all go here */ -function getArtistItem(req, res) { +function getArtistItems(req, res) { db.Artist.find({}, function(err,data) { if (err) { console.log('Error retrieving Artist items from DB.', err); @@ -14,28 +14,17 @@ function getArtistItem(req, res) { }); } - -//export to make your data results available. -module.exports = { - getArtistItems: getArtistItems //, - //createArtistItem: createArtistItem -} - - - - - - -/* Remaining create / post functionality lets add this LAAAAAASSSST. - -function createTestItem(req, res) { - const newTestItem = db.Test({ - name: req.body.name, - count: req.body.count, - time: req.body.time, - }); - - newTestItem.save(function(err, data) { +function createArtistItem(req, res) { + const newArtistItem = db.Artist({ + firstName: req.body.firstName, + lastName: req.body.lastName, + portraitImg: req.body.portraitImg, + hometown: req.body.hometown, + bio: req.body.bio + //Artworks: req.body.Artworks + }); + + newArtistItem.save(function(err, data) { if (err) { console.log('Error saving test item to DB.', err); res.status(500).send('Internal server error'); @@ -45,4 +34,10 @@ function createTestItem(req, res) { }); } -*/ +//export to make your data results available. +module.exports = { + getArtistItems: getArtistItems, + createArtistItem: createArtistItem +} + + diff --git a/routes/artwork.js b/routes/artwork.js new file mode 100644 index 0000000..8b107bb --- /dev/null +++ b/routes/artwork.js @@ -0,0 +1,38 @@ +// this is an example file showing how you might define route handlers +const db = require('../models'); + +function getArtworkItems(req, res) { + db.Artwork.find({}, function(err, data) { + if (err) { + console.log('Error retrieving test items from DB.', err); + res.status(500).send('Internal server error'); + } else { + res.json(data); + } + }); +} + +function createArtworkItem(req, res) { + const newArtworkItem = db.Artwork({ + artworkName: req.body.artworkName, + imageUrl: req.body.imageUrl, + tags: [ ], + location: req.body.location + //Artist: ArtistSchema + }); + + newArtworkItem.save(function(err, data) { + if (err) { + console.log('Error saving test item to DB.', err); + res.status(500).send('Internal server error'); + } else { + res.status(201).json(data); + } + }); +} + +// functions are exported here so they can be referenced in server.js to respond to incoming requests +module.exports = { + getArtworkItems: getArtworkItems, + createArtworkItem: createArtworkItem +}; diff --git a/routes/test.js b/routes/test.js index b5f9646..a3f4432 100644 --- a/routes/test.js +++ b/routes/test.js @@ -1,5 +1,4 @@ // this is an example file showing how you might define route handlers - const db = require('../models'); function getTestItems(req, res) { @@ -33,5 +32,5 @@ function createTestItem(req, res) { // functions are exported here so they can be referenced in server.js to respond to incoming requests module.exports = { getTestItems: getTestItems, - createTestItem: createTestItem, + createTestItem: createTestItem }; diff --git a/server.js b/server.js index fcc00d0..9c79ff8 100644 --- a/server.js +++ b/server.js @@ -8,14 +8,11 @@ const port = process.env.PORT || 3000; app.use(bodyParser.json()); // app routes -// you can add route handlers directly in this file like this: -// app.get('/', function(req, res) { -// res.json({ -// message: 'Hello, fish!', -// type: 'greeting', -// time: new Date() -// }); -// }); +// req.query.nameoffield req.params.nameoffield + + +/* APP ROUTES +**************/ // Test Controller const testRoutes = require('./routes/test'); @@ -23,9 +20,15 @@ app.get('/test', testRoutes.getTestItems); app.post('/test', testRoutes.createTestItem); //Artist Controlller -const artistRoutes = requie('./routes/artist'); +const artistRoutes = require('./routes/artist'); app.get('/artist', artistRoutes.getArtistItems); -//any other artist functions added here. +app.post('/artist', artistRoutes.createArtistItem); + + +//Artwork controllers +const artworkRoutes = require('./routes/artwork'); +app.get('/artwork', artworkRoutes.getArtworkItems); +app.post('/artwork', artworkRoutes.createArtworkItem); // TODO: delete the above dummy routes and add your actual routes From 9d47fb489a94b8d7c34d905e69bcf7ba57db69c5 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Sat, 7 Oct 2017 11:35:55 -0500 Subject: [PATCH 08/15] establishing working get/post functionality to prod --- models/artist.js | 2 ++ routes/artist.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/models/artist.js b/models/artist.js index c4d1216..c85edd0 100644 --- a/models/artist.js +++ b/models/artist.js @@ -1,6 +1,8 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page const ArtistSchema = new mongoose.Schema({ + userName: { type: String, required: true, unique: true }, + email: { type: String, required: true, unique: true }, firstName: String, lastName: String, portraitImg: String, diff --git a/routes/artist.js b/routes/artist.js index 7649d2c..515897e 100644 --- a/routes/artist.js +++ b/routes/artist.js @@ -16,6 +16,8 @@ function getArtistItems(req, res) { function createArtistItem(req, res) { const newArtistItem = db.Artist({ + userName: req.body.userName, + email: req.body.email, firstName: req.body.firstName, lastName: req.body.lastName, portraitImg: req.body.portraitImg, From 9c07125fa42f37843efa089abb68398fd06145a8 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Sat, 7 Oct 2017 12:01:30 -0500 Subject: [PATCH 09/15] added search by Artist id params function --- routes/artist.js | 14 ++++++++++++++ server.js | 2 ++ 2 files changed, 16 insertions(+) diff --git a/routes/artist.js b/routes/artist.js index 515897e..fc162f5 100644 --- a/routes/artist.js +++ b/routes/artist.js @@ -14,6 +14,19 @@ function getArtistItems(req, res) { }); } + +function getArtistItem(req, res) { + db.Artist.findOne({_id: req.params.id}, function(err,data) { + if (err) { + console.log('Error retrieving specific artist from DB.', err); + res.status(500).send('Internal server error'); + } else { + res.json(data); + } + }); +}; + + function createArtistItem(req, res) { const newArtistItem = db.Artist({ userName: req.body.userName, @@ -39,6 +52,7 @@ function createArtistItem(req, res) { //export to make your data results available. module.exports = { getArtistItems: getArtistItems, + getArtistItem: getArtistItem, createArtistItem: createArtistItem } diff --git a/server.js b/server.js index 9c79ff8..f88da6b 100644 --- a/server.js +++ b/server.js @@ -22,9 +22,11 @@ app.post('/test', testRoutes.createTestItem); //Artist Controlller const artistRoutes = require('./routes/artist'); app.get('/artist', artistRoutes.getArtistItems); +app.get('/artist/:id', artistRoutes.getArtistItem); app.post('/artist', artistRoutes.createArtistItem); + //Artwork controllers const artworkRoutes = require('./routes/artwork'); app.get('/artwork', artworkRoutes.getArtworkItems); From fbe4be0ac903b5ad0e3f88c8f97ba594c971807d Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Sat, 7 Oct 2017 12:42:09 -0500 Subject: [PATCH 10/15] added all models and gets per each. havent yet created artwork data in the db --- routes/artwork.js | 13 +++++++++++++ server.js | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/routes/artwork.js b/routes/artwork.js index 8b107bb..bce719a 100644 --- a/routes/artwork.js +++ b/routes/artwork.js @@ -12,6 +12,18 @@ function getArtworkItems(req, res) { }); } + +function getArtworkItem(req, res) { + db.Artwork.findOne({_id: req.params.id}, function(err,data) { + if (err) { + console.log('Error retrieving specific artist from DB.', err); + res.status(500).send('Internal server error'); + } else { + res.json(data); + } + }); +} + function createArtworkItem(req, res) { const newArtworkItem = db.Artwork({ artworkName: req.body.artworkName, @@ -34,5 +46,6 @@ function createArtworkItem(req, res) { // functions are exported here so they can be referenced in server.js to respond to incoming requests module.exports = { getArtworkItems: getArtworkItems, + getArtworkItem: getArtworkItem, createArtworkItem: createArtworkItem }; diff --git a/server.js b/server.js index f88da6b..2e91094 100644 --- a/server.js +++ b/server.js @@ -25,11 +25,10 @@ app.get('/artist', artistRoutes.getArtistItems); app.get('/artist/:id', artistRoutes.getArtistItem); app.post('/artist', artistRoutes.createArtistItem); - - //Artwork controllers const artworkRoutes = require('./routes/artwork'); app.get('/artwork', artworkRoutes.getArtworkItems); +app.get('/artwork/:id', artworkRoutes.getArtworkItem); app.post('/artwork', artworkRoutes.createArtworkItem); // TODO: delete the above dummy routes and add your actual routes From 1ddb8e28ece255c0a8d1225f5ab47a31d8ceb642 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Mon, 9 Oct 2017 21:25:58 -0500 Subject: [PATCH 11/15] added update specific and delete specific functionality --- models/artist.js | 4 +++- models/artwork.js | 6 ++---- routes/artist.js | 17 +++++++++++++++-- routes/artwork.js | 17 ++++++++++++++++- server.js | 5 +++++ 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/models/artist.js b/models/artist.js index c85edd0..e1d95f8 100644 --- a/models/artist.js +++ b/models/artist.js @@ -8,7 +8,9 @@ const ArtistSchema = new mongoose.Schema({ portraitImg: String, hometown: String, bio: String - //artworks: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Artwork' }] + // Artwork: [{ + // type: mongoose.Schema.Types.ObjectId, + // ref: 'Artwork' }] }); const Artist = mongoose.model('Artist', ArtistSchema); // lets make a model a thing diff --git a/models/artwork.js b/models/artwork.js index b2a33b6..370a630 100644 --- a/models/artwork.js +++ b/models/artwork.js @@ -1,11 +1,10 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page const ArtworkSchema = new mongoose.Schema({ - artName: { type: String, required: true }, + artName: { type: String}, imageUrl: { type: String, default: "" }, tags: [{ type: String, default: "" }], - location: { type: String, default: ""}, - //Artist: ArtistSchema + location: { type: String, default: "" } }); const Artwork = mongoose.model('Artwork', ArtworkSchema); // lets make a model a thing @@ -13,4 +12,3 @@ const Artwork = mongoose.model('Artwork', ArtworkSchema); // lets make a model a module.exports = { // lets export that model Artwork: Artwork } - diff --git a/routes/artist.js b/routes/artist.js index fc162f5..8cd54ed 100644 --- a/routes/artist.js +++ b/routes/artist.js @@ -5,6 +5,7 @@ const db = require('../models'); all go here */ function getArtistItems(req, res) { db.Artist.find({}, function(err,data) { + if (err) { console.log('Error retrieving Artist items from DB.', err); res.status(500).send('Internal server error'); @@ -14,7 +15,6 @@ function getArtistItems(req, res) { }); } - function getArtistItem(req, res) { db.Artist.findOne({_id: req.params.id}, function(err,data) { if (err) { @@ -26,6 +26,18 @@ function getArtistItem(req, res) { }); }; +function updateArtistItem(req, res) { + db.Artist.findByIdAndUpdate(req.params.id, req.body, function (err, post) { + res.json(post); + }); +}; + +function deleteArtistItem(req, res) { + db.Artist.findByIdAndRemove(req.params.id, req.body, function (err, post) { + res.json(post); + }); + +} function createArtistItem(req, res) { const newArtistItem = db.Artist({ @@ -53,7 +65,8 @@ function createArtistItem(req, res) { module.exports = { getArtistItems: getArtistItems, getArtistItem: getArtistItem, + updateArtistItem: updateArtistItem, + deleteArtistItem: deleteArtistItem, createArtistItem: createArtistItem } - diff --git a/routes/artwork.js b/routes/artwork.js index bce719a..8eeb940 100644 --- a/routes/artwork.js +++ b/routes/artwork.js @@ -12,7 +12,6 @@ function getArtworkItems(req, res) { }); } - function getArtworkItem(req, res) { db.Artwork.findOne({_id: req.params.id}, function(err,data) { if (err) { @@ -24,6 +23,20 @@ function getArtworkItem(req, res) { }); } +function updateArtworkItem(req, res) { + db.Artwork.findByIdAndUpdate(req.params.id, req.body, function (err, post) { + res.json(post); + }); +}; + +function deleteArtworkItem(req, res) { + db.Artwork.findByIdAndRemove(req.params.id, req.body, function (err, post) { + res.json(post); + }); + +} + + function createArtworkItem(req, res) { const newArtworkItem = db.Artwork({ artworkName: req.body.artworkName, @@ -47,5 +60,7 @@ function createArtworkItem(req, res) { module.exports = { getArtworkItems: getArtworkItems, getArtworkItem: getArtworkItem, + updateArtworkItem: updateArtworkItem, + deleteArtworkItem: deleteArtworkItem, createArtworkItem: createArtworkItem }; diff --git a/server.js b/server.js index 2e91094..f864c95 100644 --- a/server.js +++ b/server.js @@ -24,12 +24,17 @@ const artistRoutes = require('./routes/artist'); app.get('/artist', artistRoutes.getArtistItems); app.get('/artist/:id', artistRoutes.getArtistItem); app.post('/artist', artistRoutes.createArtistItem); +app.put('/artist/:id', artistRoutes.updateArtistItem); +app.delete('/artist/:id', artistRoutes.deleteArtistItem); + //Artwork controllers const artworkRoutes = require('./routes/artwork'); app.get('/artwork', artworkRoutes.getArtworkItems); app.get('/artwork/:id', artworkRoutes.getArtworkItem); app.post('/artwork', artworkRoutes.createArtworkItem); +app.put('/artwork/:id', artworkRoutes.updateArtworkItem); +app.delete('/artwork/:id', artworkRoutes.deleteArtworkItem); // TODO: delete the above dummy routes and add your actual routes From 9b4372196c85ae053f814c1f39bd5cff78e038a2 Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Tue, 10 Oct 2017 20:33:30 -0500 Subject: [PATCH 12/15] adjustments to schema to narrow scope and provide README.md documentation --- README-lesson.md | 85 ++++++++++++++++++++++++ README.md | 162 +++++++++++++++++++++------------------------ docs/artistapi.svg | 2 + models/artist.js | 11 ++- models/artwork.js | 8 ++- routes/artist.js | 15 ++--- routes/artwork.js | 19 +++--- 7 files changed, 190 insertions(+), 112 deletions(-) create mode 100644 README-lesson.md create mode 100644 docs/artistapi.svg diff --git a/README-lesson.md b/README-lesson.md new file mode 100644 index 0000000..1c17588 --- /dev/null +++ b/README-lesson.md @@ -0,0 +1,85 @@ +# Personal API - Weekend Lab + +It's time to have some fun and play with the technologies you've learned in the past week. Your goal is to start your own API. + +Your API can be related to whatever you like, but its Mongo DB must have at least 2 schemas/models that are connected by reference. + +For example, if your API is for keeping track of various hotels, it would need to reference another type of object besides hotels. You might choose to provide more information about the cities your hotels are found in beyond a simple string like "Austin" or "Orlando". Your `City` schema/model could contain information about the city iself like city name, state, local attractions, and of course a list of related hotels connected by reference. + +### Your API should have: + +* Well-organized **JSON API** Endpoints +* The ability to **read** (`GET`) each type of resource **as a collection** +* The ability to **read** (`GET`) each type of resource **by specific ID** +* The ability to **create** (`POST`) a new resource of each type +* At least one **update** (`PUT`) endpoint +* At least one **delete** (`DELETE`) endpoint + +Try to start by completing the schema/model and implementing endpoints for only one type of resource and expand from there to include other schemas/models/endpoints. + +Fork and clone this repo. You can use the placeholder code in this repo as a starting point. + +## Step 0: Deploy to Heroku + +Before we start coding, let's prepare to deploy our API on Heroku so other developers can access our API from any computer. + +You can find full instructions here: [Deploying Express Apps to Heroku](https://github.com/SF-WDI-LABS/shared_modules/blob/master/how-to/heroku-mean-stack-deploy.md) + +As you continue to work on this project, you'll need to remember to push your changes to Heroku (just like you would with Github!): + +```bash +# git add changed-files +# git commit -m "detailed description of what I changed" +git push heroku master +heroku open +``` + +It's common for code to break "in production" even when it works fine "in development" on your computer (due to different environment variables, missing dependenies, etc). Do your best to debug! Let us know if you get stuck on deployment issues. + +## Step 1: Verify the Test Routes in Postman + +Since we're building a JSON API with no front-end (yet), Postman will come in handy for testing our work. + +Make sure you've **installed dependencies** and added a `.env` file with your **Mongo DB credentials**. Then **run the server** with the placeholder code. + +Use Postman to verify that the `GET /test` and `POST /test` endpoints work, confirming that our server can connect to our Mongo DB and complete operations on demand. For the `POST` endpoint, you can simply submit an object with a `name` property, and then it should appear in your next `GET /test` request: + +```json +{ + "name": "test item 1" +} +``` + +## Step 2: Build Your Main Schema/Model + +Next, go to the `models/` folder and add a new file for your main schema/model. For now we'll create it without a reference to any other schemas/models. + +Be sure to export the model from the file and then modify `models/index.js`. It should require the file you just created and then export the models from it so they can be used more directly while preparing responses for our routes. + +## Step 3: Create Your Primary Endpoints + +Now go to the `routes/` folder and create a new file to handle your endpoints for the primary model. It should contain function definitions for handling various endpoints (`GET`, `POST`, etc) related to your primary model. + +Start with the `GET` method for retrieving all matching resources. Then add a function for adding new resources (`POST`). Then add a function for retireving a specific resource by ID (`GET`, with path parameter). + +Make sure that for each function, you modify `server.js` to register the functions as endpoint/route handlers. + +## Step 4: Check Your Work in Postman + +Open up Postman with your new code running on `localhost`. Hit your new `GET` and `POST` endpoints a few times to verify everything is working as expected. + +If it's all working, add/commit your changes to git. Push to Github to backup your code. Push to Heroku so other people can use your newly created endpoints. + +Return to Postman and test again, making sure that your code is working "in production" on the URL Heroku provided for your API server. + +## Step 5: Add Your Other Schemas/Models/Endpoints + +Now it's time to expand on what you've done. Piece by piece, add the other schemas/models and endpoints you planned. + +Be sure to test your endpoints as you go in Postman. Also don't forget to commit your changes and deploy to Heroku from time to time. + +## Options for Extra Challenge + +- **Add even more schemas/models/enpoints.** Thinking of more detailed information is usually fairly easy, but the code to support it gets more difficult the more detail is added. +- **Add support for query parameters** to limit/filter responses on your endpoints that retrieve all resources in a collection. For example, you might limit items based on rating, time/date range, tags, etc. +- **Document all the endpoints of your API** in a markdown file. What does each endpoint do? How should a new user of your API get started? diff --git a/README.md b/README.md index 1c17588..12c7ae6 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,77 @@ -# Personal API - Weekend Lab - -It's time to have some fun and play with the technologies you've learned in the past week. Your goal is to start your own API. - -Your API can be related to whatever you like, but its Mongo DB must have at least 2 schemas/models that are connected by reference. - -For example, if your API is for keeping track of various hotels, it would need to reference another type of object besides hotels. You might choose to provide more information about the cities your hotels are found in beyond a simple string like "Austin" or "Orlando". Your `City` schema/model could contain information about the city iself like city name, state, local attractions, and of course a list of related hotels connected by reference. - -### Your API should have: - -* Well-organized **JSON API** Endpoints -* The ability to **read** (`GET`) each type of resource **as a collection** -* The ability to **read** (`GET`) each type of resource **by specific ID** -* The ability to **create** (`POST`) a new resource of each type -* At least one **update** (`PUT`) endpoint -* At least one **delete** (`DELETE`) endpoint - -Try to start by completing the schema/model and implementing endpoints for only one type of resource and expand from there to include other schemas/models/endpoints. - -Fork and clone this repo. You can use the placeholder code in this repo as a starting point. - -## Step 0: Deploy to Heroku - -Before we start coding, let's prepare to deploy our API on Heroku so other developers can access our API from any computer. - -You can find full instructions here: [Deploying Express Apps to Heroku](https://github.com/SF-WDI-LABS/shared_modules/blob/master/how-to/heroku-mean-stack-deploy.md) - -As you continue to work on this project, you'll need to remember to push your changes to Heroku (just like you would with Github!): - -```bash -# git add changed-files -# git commit -m "detailed description of what I changed" -git push heroku master -heroku open -``` - -It's common for code to break "in production" even when it works fine "in development" on your computer (due to different environment variables, missing dependenies, etc). Do your best to debug! Let us know if you get stuck on deployment issues. - -## Step 1: Verify the Test Routes in Postman - -Since we're building a JSON API with no front-end (yet), Postman will come in handy for testing our work. - -Make sure you've **installed dependencies** and added a `.env` file with your **Mongo DB credentials**. Then **run the server** with the placeholder code. - -Use Postman to verify that the `GET /test` and `POST /test` endpoints work, confirming that our server can connect to our Mongo DB and complete operations on demand. For the `POST` endpoint, you can simply submit an object with a `name` property, and then it should appear in your next `GET /test` request: - -```json -{ - "name": "test item 1" -} -``` - -## Step 2: Build Your Main Schema/Model - -Next, go to the `models/` folder and add a new file for your main schema/model. For now we'll create it without a reference to any other schemas/models. - -Be sure to export the model from the file and then modify `models/index.js`. It should require the file you just created and then export the models from it so they can be used more directly while preparing responses for our routes. - -## Step 3: Create Your Primary Endpoints - -Now go to the `routes/` folder and create a new file to handle your endpoints for the primary model. It should contain function definitions for handling various endpoints (`GET`, `POST`, etc) related to your primary model. - -Start with the `GET` method for retrieving all matching resources. Then add a function for adding new resources (`POST`). Then add a function for retireving a specific resource by ID (`GET`, with path parameter). - -Make sure that for each function, you modify `server.js` to register the functions as endpoint/route handlers. - -## Step 4: Check Your Work in Postman - -Open up Postman with your new code running on `localhost`. Hit your new `GET` and `POST` endpoints a few times to verify everything is working as expected. - -If it's all working, add/commit your changes to git. Push to Github to backup your code. Push to Heroku so other people can use your newly created endpoints. - -Return to Postman and test again, making sure that your code is working "in production" on the URL Heroku provided for your API server. - -## Step 5: Add Your Other Schemas/Models/Endpoints - -Now it's time to expand on what you've done. Piece by piece, add the other schemas/models and endpoints you planned. - -Be sure to test your endpoints as you go in Postman. Also don't forget to commit your changes and deploy to Heroku from time to time. - -## Options for Extra Challenge - -- **Add even more schemas/models/enpoints.** Thinking of more detailed information is usually fairly easy, but the code to support it gets more difficult the more detail is added. -- **Add support for query parameters** to limit/filter responses on your endpoints that retrieve all resources in a collection. For example, you might limit items based on rating, time/date range, tags, etc. -- **Document all the endpoints of your API** in a markdown file. What does each endpoint do? How should a new user of your API get started? +# Famous Artworks API + +The famous artworks API is a database driven JSON API that maps Famous artworks and their locations to data about the artist that created them. + + +## Heroku Hosted Solution +You can find the API hosted on heroku at the following url. + +https://damp-mesa-41370.herokuapp.com/README.md + +## API DATA MODEL +References are not created automatically with this version of the API. Therefore Reference keys in both Artist and Artwork must be added via a PUT on each model respectively. + + + + +## API End Points + + +### Get Artists +* method: GET +* path: https://damp-mesa-41370.herokuapp.com/artist +* description: returns a result of all current Artist Records as JSON. + +### Get A Specific Artist +* method: GET +* path: https://damp-mesa-41370.herokuapp.com/artist/<<_id here>> +* description: returns a result of a specific artist as JSON. + +### Create An Artist +* method: POST +* path: https://damp-mesa-41370.herokuapp.com/artist +* description: creates a new artist record, required input as JSON will include: +```{ + "firstName": "Artist's First Name here", + "lastName": "Artist's Last Name here", + "portraitImg": "http://www.hostedurlexample.com/artist-portrait.jpg", + "hometown": "City, State", + "bio": "artist bio typed here", + "Artwork": [""] +}``` + +### Delete a specific artist +* method: DELETE +* path: https://damp-mesa-41370.herokuapp.com/artist/<<_id here>>** +* description: recalls an existing Artwork record and removes it from the database. + + +### Get All Artworks +* method: GET +* path: https://damp-mesa-41370.herokuapp.com/artwork +* description: returns a result of all current Artwork Records as JSON. + +### Create An Artwork +* method: POST +* path: https://damp-mesa-41370.herokuapp.com/artwork +* description: creates a new artwork record, required input as JSON will include the following +```{ + "artName": "Mona Lisa", + "imageUrl": "https://upload.wikimedia.org/retouched.jpg", + "tags": [""], + "location": "Paris, France", + "artist": "" +}``` + +### Update A Specific Artwork +* method: PUT +* path: https://damp-mesa-41370.herokuapp.com/artwork/<<_id here>>** +* description: recalls an existing Artwork record and is able to update any specific value within it's schema. The following example will update the records location: +```{ + "location": "Barcelona, Spain" +}``` + +### Delete a specific artwork +* method: DELETE +* path: https://damp-mesa-41370.herokuapp.com/artwork/<<_id here>> +* description: recalls an existing Artwork record and removes it from the database. diff --git a/docs/artistapi.svg b/docs/artistapi.svg new file mode 100644 index 0000000..ac24eee --- /dev/null +++ b/docs/artistapi.svg @@ -0,0 +1,2 @@ + +
Artist
Artist
+ firstName: String
+ firstName: String
+ lastName: String
+ lastName: String
+ portraitImg: String
+ portraitImg: String
+ hometown: String
+ hometown: String
+ bio: String
+ bio: String
Artwork
Artwork
+ artName: String
+ artName: String
+ imgUrl: String
+ imgUrl: String
+ tags: Array of Strings
+ tags: Array of Strings
+ location: String
+ location: String
+ artist: String
+ artist: String
+ artworks: Array of Strings
+ artworks: Array of Strings
\ No newline at end of file diff --git a/models/artist.js b/models/artist.js index e1d95f8..474ac4e 100644 --- a/models/artist.js +++ b/models/artist.js @@ -1,16 +1,15 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page const ArtistSchema = new mongoose.Schema({ - userName: { type: String, required: true, unique: true }, - email: { type: String, required: true, unique: true }, firstName: String, lastName: String, portraitImg: String, hometown: String, - bio: String - // Artwork: [{ - // type: mongoose.Schema.Types.ObjectId, - // ref: 'Artwork' }] + bio: String, + artwork: [{ + type: mongoose.Schema.Types.ObjectId, + ref: 'Artwork', + default: 'noart' }] }); const Artist = mongoose.model('Artist', ArtistSchema); // lets make a model a thing diff --git a/models/artwork.js b/models/artwork.js index 370a630..28736d0 100644 --- a/models/artwork.js +++ b/models/artwork.js @@ -1,10 +1,14 @@ const mongoose = require('mongoose'); //dependency does the heavier lifting to do the stuff on this page const ArtworkSchema = new mongoose.Schema({ - artName: { type: String}, + artName: { type: String, default: ""}, imageUrl: { type: String, default: "" }, tags: [{ type: String, default: "" }], - location: { type: String, default: "" } + location: { type: String, default: "" }, + artist: { + type: mongoose.Schema.Types.ObjectId, + ref: 'Artist', + default: 'noartist' } }); const Artwork = mongoose.model('Artwork', ArtworkSchema); // lets make a model a thing diff --git a/routes/artist.js b/routes/artist.js index 8cd54ed..b79ef69 100644 --- a/routes/artist.js +++ b/routes/artist.js @@ -27,28 +27,25 @@ function getArtistItem(req, res) { }; function updateArtistItem(req, res) { - db.Artist.findByIdAndUpdate(req.params.id, req.body, function (err, post) { - res.json(post); + db.Artist.findByIdAndUpdate(req.params.id, req.body, function (err, data) { + res.json(data); }); }; function deleteArtistItem(req, res) { - db.Artist.findByIdAndRemove(req.params.id, req.body, function (err, post) { - res.json(post); + db.Artist.findByIdAndRemove(req.params.id, req.body, function (err, data) { + res.json(data); }); - } function createArtistItem(req, res) { const newArtistItem = db.Artist({ - userName: req.body.userName, - email: req.body.email, firstName: req.body.firstName, lastName: req.body.lastName, portraitImg: req.body.portraitImg, hometown: req.body.hometown, - bio: req.body.bio - //Artworks: req.body.Artworks + bio: req.body.bio, + artwork: [req.body.artwork] }); newArtistItem.save(function(err, data) { diff --git a/routes/artwork.js b/routes/artwork.js index 8eeb940..c2f61e6 100644 --- a/routes/artwork.js +++ b/routes/artwork.js @@ -24,26 +24,25 @@ function getArtworkItem(req, res) { } function updateArtworkItem(req, res) { - db.Artwork.findByIdAndUpdate(req.params.id, req.body, function (err, post) { - res.json(post); + db.Artwork.findByIdAndUpdate(req.params.id, req.body, function (err, data) { + res.json(data); }); }; function deleteArtworkItem(req, res) { - db.Artwork.findByIdAndRemove(req.params.id, req.body, function (err, post) { - res.json(post); + db.Artwork.findByIdAndRemove(req.params.id, req.body, function (err, data) { + res.json(data); }); - -} +}; function createArtworkItem(req, res) { const newArtworkItem = db.Artwork({ - artworkName: req.body.artworkName, + artName: req.body.artName, imageUrl: req.body.imageUrl, - tags: [ ], - location: req.body.location - //Artist: ArtistSchema + tags: [], + location: req.body.location, + artist: req.body.artist }); newArtworkItem.save(function(err, data) { From 601dc0ca443e110f67db89e8b8face6f7b29f5dd Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Tue, 10 Oct 2017 20:38:43 -0500 Subject: [PATCH 13/15] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 12c7ae6..3893706 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ The famous artworks API is a database driven JSON API that maps Famous artworks ## Heroku Hosted Solution -You can find the API hosted on heroku at the following url. - -https://damp-mesa-41370.herokuapp.com/README.md +You can find the API hosted on heroku at the following url. There is no front end layer for the API at this time, so the below End Points will assist in navigating it's database. +https://damp-mesa-41370.herokuapp.com/ ## API DATA MODEL References are not created automatically with this version of the API. Therefore Reference keys in both Artist and Artwork must be added via a PUT on each model respectively. From 1707dade4afb7e010d77cafdf9b42c9a2c9388ae Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Tue, 10 Oct 2017 20:46:58 -0500 Subject: [PATCH 14/15] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3893706..8d80d99 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,9 @@ References are not created automatically with this version of the API. Therefore "hometown": "City, State", "bio": "artist bio typed here", "Artwork": [""] -}``` +} +``` + ### Delete a specific artist * method: DELETE @@ -66,6 +68,7 @@ References are not created automatically with this version of the API. Therefore * method: PUT * path: https://damp-mesa-41370.herokuapp.com/artwork/<<_id here>>** * description: recalls an existing Artwork record and is able to update any specific value within it's schema. The following example will update the records location: + ```{ "location": "Barcelona, Spain" }``` From 787bead2c7332a1ad6dd7c7478ec49234d86846c Mon Sep 17 00:00:00 2001 From: Jesse Lewis Date: Tue, 10 Oct 2017 20:47:44 -0500 Subject: [PATCH 15/15] Update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8d80d99..303a841 100644 --- a/README.md +++ b/README.md @@ -56,22 +56,26 @@ References are not created automatically with this version of the API. Therefore * method: POST * path: https://damp-mesa-41370.herokuapp.com/artwork * description: creates a new artwork record, required input as JSON will include the following -```{ +``` +{ "artName": "Mona Lisa", "imageUrl": "https://upload.wikimedia.org/retouched.jpg", "tags": [""], "location": "Paris, France", "artist": "" -}``` +} +``` ### Update A Specific Artwork * method: PUT * path: https://damp-mesa-41370.herokuapp.com/artwork/<<_id here>>** * description: recalls an existing Artwork record and is able to update any specific value within it's schema. The following example will update the records location: -```{ +``` +{ "location": "Barcelona, Spain" -}``` +} +``` ### Delete a specific artwork * method: DELETE