From 7e8e8531379f948c76518b72bd6df6fe7c96ac5e Mon Sep 17 00:00:00 2001 From: pribylmartinnet Date: Wed, 23 Mar 2022 19:28:15 +0100 Subject: [PATCH] Included MongoDb to package.json --- controllers/topic.js | 12 ++-- db.js | 6 +- package-lock.json | 142 +++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 4 files changed, 153 insertions(+), 10 deletions(-) diff --git a/controllers/topic.js b/controllers/topic.js index b794c04..ab7240b 100644 --- a/controllers/topic.js +++ b/controllers/topic.js @@ -4,7 +4,7 @@ const db = require("../db") const router = express.Router() -router.get("/sum", function (req, res){ +router.get("/sum", function (req, res) { try { res.status(200).send(math.sum(Number(req.query.a), Number(req.query.b))) @@ -14,17 +14,15 @@ router.get("/sum", function (req, res){ }) - - -router.get("/", function (req, res){ +router.get("/", function (req, res) { db.run() res.status(200).send("Ahoj") }) -router.post("/", function (req, res){ +router.post("/", function (req, res) { try { let topic = req.body.topic - let desc = req.body.dexsription + let desc = req.body.dessription console.log(topic) res.status(201).send("A topic was created") } catch (err){ @@ -33,7 +31,7 @@ router.post("/", function (req, res){ }) -router.get("/:id", function (req, res){ +router.get("/:id", function (req, res) { try { let id = req.params.id console.log(id) diff --git a/db.js b/db.js index f25d35b..902554b 100644 --- a/db.js +++ b/db.js @@ -1,9 +1,10 @@ require('dotenv').config() -const { MongoClient } = require("mongodb"); +const { MongoClient } = require("mongodb") const client = new MongoClient(process.env.DB_CONN); async function run() { - try { + + try { // Connect the client to the server await client.connect(); // Establish and verify connection @@ -13,6 +14,7 @@ async function run() { // Ensures that the client will close when you finish/error await client.close(); } + } diff --git a/package-lock.json b/package-lock.json index 4b294b4..ddfb5a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,25 @@ "defer-to-connect": "^1.0.1" } }, + "@types/node": { + "version": "17.0.22", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/@types/node/-/node-17.0.22.tgz", + "integrity": "sha512-8FwbVoG4fy+ykY86XCAclKZDORttqE5/s7dyWZKLXTdv3vRy5HozBEinG5IqhvPXXzIZEcTVbuHlQEI6iuwcmw==" + }, + "@types/webidl-conversions": { + "version": "6.1.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz", + "integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q==" + }, + "@types/whatwg-url": { + "version": "8.2.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/@types/whatwg-url/-/whatwg-url-8.2.1.tgz", + "integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==", + "requires": { + "@types/node": "*", + "@types/webidl-conversions": "*" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/abbrev/-/abbrev-1.1.1.tgz", @@ -79,6 +98,11 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, "binary-extensions": { "version": "2.2.0", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -152,6 +176,23 @@ "fill-range": "^7.0.1" } }, + "bson": { + "version": "4.6.2", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/bson/-/bson-4.6.2.tgz", + "integrity": "sha512-VeJKHShcu1b/ugl0QiujlVuBepab714X9nNyBdA1kfekuDGecxgpTA2Z6nYbagrWFeiIyzSWIOzju3lhj+RNyQ==", + "requires": { + "buffer": "^5.6.0" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "bytes": { "version": "3.1.2", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/bytes/-/bytes-3.1.2.tgz", @@ -353,6 +394,11 @@ "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", "dev": true }, + "denque": { + "version": "2.0.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/denque/-/denque-2.0.1.tgz", + "integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==" + }, "depd": { "version": "1.1.2", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/depd/-/depd-1.1.2.tgz", @@ -621,6 +667,11 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, "ignore-by-default": { "version": "1.0.1", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/ignore-by-default/-/ignore-by-default-1.0.1.tgz", @@ -650,6 +701,11 @@ "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==", "dev": true }, + "ip": { + "version": "1.1.5", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -801,6 +857,12 @@ "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, "merge-descriptors": { "version": "1.0.1", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/merge-descriptors/-/merge-descriptors-1.0.1.tgz", @@ -850,6 +912,27 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, + "mongodb": { + "version": "4.4.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/mongodb/-/mongodb-4.4.1.tgz", + "integrity": "sha512-IAD3nFtCR4s22vi5qjqkCBnuyDDrOW8WVSSmgHquOvGaP1iTD+XpC5tr8wAUbZ2EeZkaswwBKQFHDvl4qYcKqQ==", + "requires": { + "bson": "^4.6.1", + "denque": "^2.0.1", + "mongodb-connection-string-url": "^2.5.2", + "saslprep": "^1.0.3", + "socks": "^2.6.2" + } + }, + "mongodb-connection-string-url": { + "version": "2.5.2", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.2.tgz", + "integrity": "sha512-tWDyIG8cQlI5k3skB6ywaEA5F9f5OntrKKsT/Lteub2zgwSUlhqEN2inGgBTm8bpYJf8QYBdA/5naz65XDpczA==", + "requires": { + "@types/whatwg-url": "^8.2.1", + "whatwg-url": "^11.0.0" + } + }, "ms": { "version": "2.1.3", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/ms/-/ms-2.1.3.tgz", @@ -989,6 +1072,11 @@ "once": "^1.3.1" } }, + "punycode": { + "version": "2.1.1", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, "pupa": { "version": "2.1.1", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/pupa/-/pupa-2.1.1.tgz", @@ -1085,6 +1173,15 @@ "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "saslprep": { + "version": "1.0.3", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/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.1", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/semver/-/semver-5.7.1.tgz", @@ -1167,6 +1264,29 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "smart-buffer": { + "version": "4.2.0", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==" + }, + "socks": { + "version": "2.6.2", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/socks/-/socks-2.6.2.tgz", + "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "requires": { + "ip": "^1.1.5", + "smart-buffer": "^4.2.0" + } + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, "statuses": { "version": "1.5.0", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/statuses/-/statuses-1.5.0.tgz", @@ -1236,6 +1356,14 @@ "nopt": "~1.0.10" } }, + "tr46": { + "version": "3.0.0", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "requires": { + "punycode": "^2.1.1" + } + }, "type-fest": { "version": "0.20.2", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/type-fest/-/type-fest-0.20.2.tgz", @@ -1332,6 +1460,20 @@ "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "webidl-conversions": { + "version": "7.0.0", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==" + }, + "whatwg-url": { + "version": "11.0.0", + "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "requires": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + } + }, "widest-line": { "version": "3.1.0", "resolved": "https://repo.plus4u.net/operatorGate/repository/npm/widest-line/-/widest-line-3.1.0.tgz", diff --git a/package.json b/package.json index f80fd74..2577ab6 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "dotenv": "^16.0.0", - "express": "^4.17.3" + "express": "^4.17.3", + "mongodb": "^4.4.1" } }