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();