Skip to content

Commit

Permalink
fixed pagination, post sorting, and linkify
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulsittar committed Jan 7, 2024
1 parent d4539c3 commit 3b38b56
Show file tree
Hide file tree
Showing 135 changed files with 17,017 additions and 2,629 deletions.
2 changes: 1 addition & 1 deletion api/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


NODE_ENV=production
NODE_ENV=development

if (process.env.NODE_ENV === 'development') {
REACT_APP_PUBLIC_FOLDER = "https://127.0.0.1:8080/images/"
Expand Down
30 changes: 30 additions & 0 deletions api/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
"author": "Costin Gheorghe",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.1",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
"bcrypt": "^5.1.1",

"dotenv": "^16.3.1",
"ejs": "^2.6.1",
"express": "^4.18.2",
"express-fileupload": "^1.1.4",
"express-flash-messages": "^0.1.1",
"express-session": "^1.16.1",
"express-sslify": "^1.2.0",
"express-validator": "^5.3.1",
"helmet": "^4.6.0",
"http-proxy-middleware": "^2.0.6",
"express-validator": "^5.3.1",
"moment": "^2.24.0",
"mongodb": "^5.5.0",
"mongoose": "^5.12.14",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"nodemon": "^2.0.7",
"pug": "^2.0.3",
"request": "^2.88.0",
"path": "^0.12.7",
"pug": "^2.0.3",
"react-infinite-scroller": "^1.2.6",
"react-linkify": "^1.0.0-alpha",
"react-redux": "^8.0.7",
"react-scripts": "^5.0.1",
"request": "^2.88.0",
"util": "^0.12.5"
},
"devDependencies": {
Expand Down
32 changes: 32 additions & 0 deletions api/routes/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,38 @@ router.get('/timeline2/:userId', async(req, res) =>{
}
})

// get pagination posts
router.get('/timelinePag/:userId', async(req, res) =>{
console.log("hereherehereh");
console.log(req.query.page);
try {
let page = req.query.page //starts from 0
let posts= await getPostsPaginated(page)
if (posts && posts.length > 0) {
res.status(200).json(posts)
} else {
res.status(200).json(err);
console.log(res);
}

} catch(err) {
res.status(500).json(err);
}
})


//service
const getPostsPaginated = async (page) => {
let resultsPerPage = 10

return await Post.find({}).populate('Comment')
.sort({ createdAt: 'descending' })
.lean()
.limit(resultsPerPage)
.skip(page * resultsPerPage)
}


// all users
router.get('/timeline/:userId', async (req, res) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion client/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NODE_ENV=production
NODE_ENV=development

if (process.env.NODE_ENV === 'development') {
REACT_APP_PUBLIC_FOLDER = "https://127.0.0.1:8080/images/"
Expand Down
6 changes: 3 additions & 3 deletions client/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.ea07bca6.css",
"main.js": "/static/js/main.a97cdc53.js",
"main.js": "/static/js/main.c7444ebe.js",
"index.html": "/index.html",
"main.ea07bca6.css.map": "/static/css/main.ea07bca6.css.map",
"main.a97cdc53.js.map": "/static/js/main.a97cdc53.js.map"
"main.c7444ebe.js.map": "/static/js/main.c7444ebe.js.map"
},
"entrypoints": [
"static/css/main.ea07bca6.css",
"static/js/main.a97cdc53.js"
"static/js/main.c7444ebe.js"
]
}
2 changes: 1 addition & 1 deletion client/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="stylesheet" href="/assets/style.css"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><title>Basic Social App</title><script defer="defer" src="/static/js/main.a97cdc53.js"></script><link href="/static/css/main.ea07bca6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="stylesheet" href="/assets/style.css"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><title>Basic Social App</title><script defer="defer" src="/static/js/main.c7444ebe.js"></script><link href="/static/css/main.ea07bca6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
2 changes: 1 addition & 1 deletion client/node_modules/.cache/.eslintcache

Large diffs are not rendered by default.

Loading

0 comments on commit 3b38b56

Please sign in to comment.