Initial Commit

This commit is contained in:
Rajarshee Chatterjee
2020-12-23 15:58:41 +05:30
commit 6c658870b3
5 changed files with 1851 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/node_modules
+39
View File
@@ -0,0 +1,39 @@
const express = require("express");
const cheerio = require("cheerio");
const request = require("request");
const router = express.Router();
const baseUrl = "https://boxnovel.com/";
router.get("/latest", (req, res) => {
let novels = [];
request(baseUrl, (err, response, body) => {
if (err) throw err;
$ = cheerio.load(body);
$(".page-item-detail").each(function (result) {
let novelName = null;
novelName = $(this).find("h5 > a").text();
novelCover = $(this).find("img").attr("src");
novelUrl = $(this)
.find("h5 > a")
.attr("href")
.replace(baseUrl + "novel/", "");
novel = {
novelName: novelName,
novelCover: novelCover,
novelUrl: novelUrl,
};
novels.push(novel);
});
res.json(novels);
});
});
module.exports = router;
+1769
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
{
"name": "lnreader-backend",
"version": "1.0.0",
"description": "Backend for LNReader",
"main": "server.js",
"scripts": {
"start": "nodemon server"
},
"author": "",
"license": "ISC",
"dependencies": {
"cheerio": "^1.0.0-rc.5",
"express": "^4.17.1",
"request": "^2.88.2"
},
"devDependencies": {
"nodemon": "^2.0.6"
}
}
+23
View File
@@ -0,0 +1,23 @@
const express = require("express");
const app = express();
app.use(
express.json({
extended: false,
})
);
app.get("/", (req, res) =>
res.json({
Author: "Rajarshee Chatterjee",
Version: "1.0.0",
Github: "https://github.com/rajarsheechatterjee/LNReader-backend",
})
);
app.use("/api/", require("./api/latest"));
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));