Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code formatting #18

Merged
merged 4 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
const _express = require('express');
const _express = require("express");
const _app = _express();
const _bodyParser = require('body-parser');
const _httpClient = require('./services/http-client');
const _steamScraper = require('./services/steam-scraper');
const _logger = require('./services/logger');
const _bodyParser = require("body-parser");
const _httpClient = require("./services/http-client");
const _steamScraper = require("./services/steam-scraper");
const _logger = require("./services/logger");

const PORT = process.env.PORT || 8080;

function main() {
_app.use(_express.static('public'));
_app.use(_bodyParser.urlencoded({ extended: false }))
_app.use(_express.static("public"));
_app.use(_bodyParser.urlencoded({ extended: false }));
_app.use(_bodyParser.json());

_app.post('/api/app-scrape', async (req, res) => {
_app.post("/api/app-scrape", async (req, res) => {
let appUrl = req.body.url;

let appPageHtml;
try {
appPageHtml = await _httpClient.get(appUrl);
} catch (error) {
_logger.error(error);
res.status(500).json({ message: "Error retrieving page HTML." })
res.status(500).json({ message: "Error retrieving page HTML." });
return;
}

Expand All @@ -40,19 +40,21 @@ function main() {
}
});

_app.post('/api/search-scrape', async (req, res) => {
_app.post("/api/search-scrape", async (req, res) => {
let searchUrl = req.body.url;
let searchPageHtml;
try {
searchPageHtml = await _httpClient.get(searchUrl);
} catch (error) {
_logger.error(error);
res.status(500).json({ message: "Error retrieving page HTML." })
res.status(500).json({ message: "Error retrieving page HTML." });
return;
}

try {
let searchPageData = _steamScraper.getSearchPageData(searchPageHtml);
let searchPageData = _steamScraper.getSearchPageData(
searchPageHtml
);
res.status(200).json(searchPageData);
return;
} catch (error) {
Expand All @@ -62,14 +64,14 @@ function main() {
}
});

_app.post('/api/search-app-scrape', async (req, res) => {
_app.post("/api/search-app-scrape", async (req, res) => {
let appUrl = req.body.url;
let appPageHtml;
try {
appPageHtml = await _httpClient.get(appUrl);
} catch (error) {
_logger.error(error);
res.status(500).json({ message: "Error retrieving page HTML." })
res.status(500).json({ message: "Error retrieving page HTML." });
return;
}

Expand Down
76 changes: 38 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"name": "vr-game-deals-tools",
"version": "1.0.0",
"description": "Tools for r/vrgamedeals",
"main": "app.js",
"scripts": {
"start": "node app.js",
"start-pm2": "pm2 start process.json",
"dev": "nodemon app.js"
},
"keywords": [
"deals",
"game",
"reality",
"virtual",
"vr",
"vrgamedeals"
],
"author": "Kevin Novak",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"cheerio": "1.0.0-rc.3",
"express": "4.17.1",
"pm2": "^3.5.1",
"request": "2.88.0",
"request-promise": "4.2.4"
},
"devDependencies": {
"nodemon": "^1.19.4"
},
"homepage": "https://github.com/KevinNovak/vrgamedeals-Tools#readme",
"repository": {
"type": "git",
"url": "https://github.com/KevinNovak/vrgamedeals-Tools.git"
},
"bugs": {
"url": "https://github.com/KevinNovak/vrgamedeals-Tools/issues"
}
"name": "vr-game-deals-tools",
"version": "1.0.0",
"description": "Tools for r/vrgamedeals",
"main": "app.js",
"scripts": {
"start": "node app.js",
"start-pm2": "pm2 start process.json",
"dev": "nodemon app.js"
},
"keywords": [
"deals",
"game",
"reality",
"virtual",
"vr",
"vrgamedeals"
],
"author": "Kevin Novak",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"cheerio": "1.0.0-rc.3",
"express": "4.17.1",
"pm2": "^3.5.1",
"request": "2.88.0",
"request-promise": "4.2.4"
},
"devDependencies": {
"nodemon": "^1.19.4"
},
"homepage": "https://github.com/KevinNovak/vrgamedeals-Tools#readme",
"repository": {
"type": "git",
"url": "https://github.com/KevinNovak/vrgamedeals-Tools.git"
},
"bugs": {
"url": "https://github.com/KevinNovak/vrgamedeals-Tools/issues"
}
}
2 changes: 1 addition & 1 deletion process.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"log_date_format": "YYYY-MM-DD HH:mm:ss"
}
]
}
}
Loading