| const express = require('express'); | const express = require('express'); | ||||
| var cors = require('cors'); | |||||
| const app = express(); | const app = express(); | ||||
| // app.use(bodyParser.urlencoded({ extended: false })); | // app.use(bodyParser.urlencoded({ extended: false })); | ||||
| app.use(express.json()); | app.use(express.json()); | ||||
| app.use(cors()); | |||||
| // app.use(bodyParser.raw()); | // app.use(bodyParser.raw()); | ||||
| // const cron = require('node-cron'); | // const cron = require('node-cron'); | ||||
| }); | }); | ||||
| app.get("/scrapes/:id", (req, res) => { | app.get("/scrapes/:id", (req, res) => { | ||||
| const id = req.params.id; | const id = req.params.id; | ||||
| //todo: get data from mongo | |||||
| res.json(id); | res.json(id); | ||||
| }); | }); | ||||
| app.post("/scrapes/", (req, res) => { | app.post("/scrapes/", (req, res) => { | ||||
| const beds = req.body.beds; | const beds = req.body.beds; | ||||
| const type = req.body.type; | const type = req.body.type; | ||||
| const lifestyle = req.body.lifestyle; | const lifestyle = req.body.lifestyle; | ||||
| // query builder | |||||
| //todo: save data into the database | |||||
| res.json({ | res.json({ | ||||
| id: 1, | id: 1, | ||||
| location: location, | location: location, | ||||
| }); | }); | ||||
| app.patch("/scrapes/:id/execute", (req, res) => { | app.patch("/scrapes/:id/execute", (req, res) => { | ||||
| const id = req.params.id; | const id = req.params.id; | ||||
| //todo: get scrape data from db | |||||
| //todo: mark scrape for execution in the job queue | |||||
| res.status(200).json(id); | res.status(200).json(id); | ||||
| }); | }); | ||||
| "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", | ||||
| "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" | ||||
| }, | }, | ||||
| "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" | |||||
| } | |||||
| }, | |||||
| "crypto-random-string": { | "crypto-random-string": { | ||||
| "version": "2.0.0", | "version": "2.0.0", | ||||
| "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", | "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", | ||||
| "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", | ||||
| "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" | "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" | ||||
| }, | }, | ||||
| "object-assign": { | |||||
| "version": "4.1.1", | |||||
| "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", | |||||
| "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" | |||||
| }, | |||||
| "on-finished": { | "on-finished": { | ||||
| "version": "2.3.0", | "version": "2.3.0", | ||||
| "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", |
| "axios": "^0.21.1", | "axios": "^0.21.1", | ||||
| "body-parser": "^1.19.0", | "body-parser": "^1.19.0", | ||||
| "cheerio": "^1.0.0-rc.10", | "cheerio": "^1.0.0-rc.10", | ||||
| "cors": "^2.8.5", | |||||
| "express": "^4.17.1", | "express": "^4.17.1", | ||||
| "http": "0.0.1-security", | "http": "0.0.1-security", | ||||
| "mongodb": "^3.6.9", | "mongodb": "^3.6.9", |