From 3667eca5a4381954adc57e84e892666482937fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=ED=9D=AC?= Date: Sun, 25 Feb 2024 01:37:45 +0900 Subject: [PATCH] =?UTF-8?q?FEAT=20:=20=EB=AC=B4=ED=95=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A1=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server.js b/server.js index 8f177f4a..11007e1d 100644 --- a/server.js +++ b/server.js @@ -28,19 +28,9 @@ async function connectToMongoDB() { connectToMongoDB(); -const PAGE_SIZE = 3; - app.get('/article', async (req, res) => { - const pageNumber = req.query.pageNumber ? parseInt(req.query.pageNumber) : 1; - try { - const articles = await articleCollection - .find({}) - .sort({ _id: -1 }) // _id를 기준으로 역순으로 정렬 - .skip((pageNumber - 1) * PAGE_SIZE) - .limit(PAGE_SIZE) - .toArray(); - + const articles = await articleCollection.find({}).toArray(); res.json({ result: 'success', article: articles }); } catch (error) { console.error('Error fetching articles:', error); @@ -48,6 +38,16 @@ app.get('/article', async (req, res) => { } }); +app.get('/rank', async (req, res) => { + try { + const ranks = await rankCollection.find({}).toArray(); + res.json({ result: 'success', rank: ranks }); + } catch (error) { + console.error('Error fetching ranks:', error); + res.status(500).json({ result: 'error', message: 'Internal server error' }); + } +}); + app.get('/transfer', async (req, res) => { try { const transfers = await transferCollection.find({}).toArray();