웹팩 설정으로 인한 불필요한 파일 제거

This commit is contained in:
ByungyeonKim
2021-11-15 00:29:18 +09:00
parent ef52f978ad
commit 4a7cdf5ef3
2 changed files with 0 additions and 63 deletions

View File

@@ -1,11 +0,0 @@
const express = require('express');
const app = express();
const port = 3000;
const router = require('./src/api/router');
app.use('/api', router);
app.use(express.static('public'));
app.listen(port, () =>
console.log(`zum_hub의 서버가 http://localhost:${port}에 열렸습니다. 🌿`)
);

View File

@@ -1,52 +0,0 @@
const express = require('express');
const router = express.Router();
const axios = require('axios');
const cheerio = require('cheerio');
const fs = require('fs');
router.get('/best', (req, res) => {
const best = JSON.parse(
fs.readFileSync('./public/data/best.json', 'utf8')
);
res.json(best);
});
router.get('/content/:category', (req, res) => {
const param = req.params.category;
const category = JSON.parse(
fs.readFileSync(`./public/data/${param}.json`, 'utf8')
);
res.json(category);
});
router.get('/detail/:url', (req, res) => {
const getHtml = async () => {
const url = req.params.url.replace(/ /g, '/');
try {
return await axios.get(url);
} catch (error) {
console.error(error);
}
};
getHtml()
.then((html) => {
const $ = cheerio.load(html.data);
const data = {
title: $('div.article_header > div > div > h2').text(),
category: $(
'div.article_header > div > div > p.top > strong'
).html(),
mainContents: $('div.article.d_article').html(),
mediaName: $('#btn_media').text(),
};
return data;
})
.then((result) => res.send(result));
});
module.exports = router;