| @@ -1,8 +1,10 @@ | |||
| const express = require('express'); | |||
| var cors = require('cors'); | |||
| const app = express(); | |||
| // app.use(bodyParser.urlencoded({ extended: false })); | |||
| app.use(express.json()); | |||
| app.use(cors()); | |||
| // app.use(bodyParser.raw()); | |||
| // const cron = require('node-cron'); | |||
| @@ -121,6 +123,8 @@ app.get("/scrapes", (req, res) => { | |||
| }); | |||
| app.get("/scrapes/:id", (req, res) => { | |||
| const id = req.params.id; | |||
| //todo: get data from mongo | |||
| res.json(id); | |||
| }); | |||
| app.post("/scrapes/", (req, res) => { | |||
| @@ -130,6 +134,10 @@ app.post("/scrapes/", (req, res) => { | |||
| const beds = req.body.beds; | |||
| const type = req.body.type; | |||
| const lifestyle = req.body.lifestyle; | |||
| // query builder | |||
| //todo: save data into the database | |||
| res.json({ | |||
| id: 1, | |||
| location: location, | |||
| @@ -143,6 +151,8 @@ app.post("/scrapes/", (req, res) => { | |||
| }); | |||
| app.patch("/scrapes/:id/execute", (req, res) => { | |||
| 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); | |||
| }); | |||
| @@ -433,6 +433,15 @@ | |||
| "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", | |||
| "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": { | |||
| "version": "2.0.0", | |||
| "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", | |||
| @@ -1250,6 +1259,11 @@ | |||
| "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", | |||
| "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": { | |||
| "version": "2.3.0", | |||
| "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", | |||
| @@ -12,6 +12,7 @@ | |||
| "axios": "^0.21.1", | |||
| "body-parser": "^1.19.0", | |||
| "cheerio": "^1.0.0-rc.10", | |||
| "cors": "^2.8.5", | |||
| "express": "^4.17.1", | |||
| "http": "0.0.1-security", | |||
| "mongodb": "^3.6.9", | |||