Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
365 commits
Select commit Hold shift + click to select a range
1fbeb1b
Add route for un-starring a trip
Feb 24, 2026
871f1aa
Add global state variable for determining if the trip is already star…
Feb 24, 2026
e0003db
Add patch request to unstar trip when clicking the star button, if th…
Feb 24, 2026
6502716
Add conditional styling of star button depending on if starred by user
Feb 24, 2026
03045ec
Merge pull request #20 from gabriellaberko/star-features
gabriellaberko Feb 24, 2026
6fb5619
make a component for an activity
Appilistus Feb 24, 2026
2cf1d6f
Merge pull request #21 from gabriellaberko/trip-detail-styling
Appilistus Feb 24, 2026
f6157b8
add json files and fix path to my trips page in navbar
Appilistus Feb 24, 2026
5c71ca3
Fix error in get route for starred trips
Feb 24, 2026
088bc04
Add isTripCreator as global state and add for conditional render of e…
Feb 24, 2026
7d5147b
Connect star button to the update star routes + make sure the state i…
Feb 24, 2026
521b526
add activity icons
Appilistus Feb 24, 2026
55d96fe
Merge branch 'main' into icons
Appilistus Feb 24, 2026
9ec3c75
Merge pull request #22 from gabriellaberko/icons
Appilistus Feb 24, 2026
93297e3
fix activity card styling
Appilistus Feb 24, 2026
ed8db4d
Merge pull request #23 from gabriellaberko/my-trips-styling
Appilistus Feb 24, 2026
4fd89e0
Update datatype for creator in TripInterface + update states for trip…
Feb 25, 2026
b498d9a
Create a page component for my favorites + fix routing and menu links
Feb 25, 2026
ff50a59
add route for update trip privacy
sandrahagevall Feb 25, 2026
a3fd35f
Add fetch function to retrieve the user's favorite trips + Move loadi…
Feb 25, 2026
b9f8f0d
Update TripDetails page with the global states for loading and error
Feb 25, 2026
cb13e95
Add hook for handling isTripCreator and IsStarredByUser so it can han…
Feb 25, 2026
85593c5
Populate object for the field creator in /my and /my/starred routes t…
Feb 25, 2026
7f8c3c5
Positioning of StarBtn
Feb 25, 2026
53a7ae3
add toggle for private/public in tripsdetailpage. Will also add emoji…
sandrahagevall Feb 25, 2026
53adf0d
install and add dnd-kit
Appilistus Feb 25, 2026
dedc1b6
Update svg for star button
Feb 25, 2026
d4f2a55
Merge pull request #24 from gabriellaberko/feature-favorites
gabriellaberko Feb 25, 2026
20203b5
update toggle in tripsdetailpage
sandrahagevall Feb 25, 2026
2fa6cdf
remove console.log
sandrahagevall Feb 25, 2026
51dca6e
make activity draggable
Appilistus Feb 25, 2026
f93ae9d
fix dnd
Appilistus Feb 25, 2026
aca1aae
fix main button
Appilistus Feb 25, 2026
5a73f7f
Merge branch 'main' into trips-detail-styling
Appilistus Feb 25, 2026
f43aa30
Merge pull request #26 from gabriellaberko/trips-detail-styling
Appilistus Feb 25, 2026
1ce30e1
Revert "Trips detail styling"
Appilistus Feb 25, 2026
8097344
Merge pull request #27 from gabriellaberko/revert-26-trips-detail-sty…
Appilistus Feb 25, 2026
8e4d1ac
Merge branch 'main' into private-public-route
sandrahagevall Feb 25, 2026
dcff466
Merge pull request #25 from gabriellaberko/private-public-route
sandrahagevall Feb 25, 2026
2d5d3e7
remove two values from interface TripState that was left from the merge
sandrahagevall Feb 25, 2026
8090670
create new branch
Appilistus Feb 26, 2026
36308c5
Merge branch 'main' into new-trip-detail-styling
Appilistus Feb 26, 2026
e2ecdfc
Merge pull request #28 from gabriellaberko/new-trip-detail-styling
Appilistus Feb 26, 2026
c3ebd24
install dnd kit
Appilistus Feb 26, 2026
65f9f9b
update in tripdetailspage
Appilistus Feb 26, 2026
f78176a
update tripstore
Appilistus Feb 26, 2026
e729d59
update mainbtn
Appilistus Feb 26, 2026
c690cf4
update interface
Appilistus Feb 26, 2026
11c6cd3
update tripdetailspage
Appilistus Feb 26, 2026
c4747a2
update activity
Appilistus Feb 26, 2026
e11a215
update daycard
Appilistus Feb 26, 2026
3f4911e
update activity
Appilistus Feb 26, 2026
6d7db6b
fix code in tripsdetailpage for the missing toggle of private-public
sandrahagevall Feb 26, 2026
dadef09
remove mainbtn in tripsgrid since we already had it in tripdetailspage
sandrahagevall Feb 26, 2026
da16e66
add route for update trip image and update the route for post a new t…
sandrahagevall Feb 26, 2026
e2c7db9
Merge pull request #31 from gabriellaberko/image-upload
sandrahagevall Feb 26, 2026
c236d0f
add route to move activity
Appilistus Feb 26, 2026
67f2ecf
add small changes for the route to move activity
Appilistus Feb 26, 2026
b76ff68
Merge pull request #32 from gabriellaberko/dnd-route
Appilistus Feb 27, 2026
b819ac5
update cityimage model for fetching citys, and add a new route for ci…
sandrahagevall Feb 27, 2026
6e0ea08
Fix navigation for your own profile page
Feb 27, 2026
ee036a1
fix functionality for starring a trip in explore page
sandrahagevall Feb 27, 2026
249ca6a
Add fetchMyTrips function to TripStore to be accessed also from UserP…
Feb 27, 2026
0efe51f
Add route to get a user's public trips + reorder the GET routes to pr…
Feb 27, 2026
e2b9c99
fix styling for ExploreTripCard and add .populate on star route so th…
sandrahagevall Feb 27, 2026
8112488
add .populate in unstar route
sandrahagevall Feb 27, 2026
b334207
Merge pull request #33 from gabriellaberko/upload-image
sandrahagevall Feb 27, 2026
9bd730a
Remove starredTrips field for User model because of duplication with …
Feb 27, 2026
31cee48
saved changes in trip-card for removal later
sandrahagevall Feb 27, 2026
eb5de7c
Merge pull request #34 from gabriellaberko/trip-card-edit
sandrahagevall Feb 27, 2026
30ad250
Add routes for follow and unfollow a user
Feb 27, 2026
c75d43a
Add function for fetching public trips from user of the profile page …
Feb 27, 2026
3169ded
Add GET routes for followers- and following lists of a user
Feb 28, 2026
cc17374
Create FollowListPage for displaying followers- or following list of …
Feb 28, 2026
085db82
Add patch request function to handle both follow/and unfollow + Condi…
Feb 28, 2026
1cf3307
create publichomepage
Appilistus Mar 1, 2026
234167a
update global styles
Appilistus Mar 1, 2026
9ddf91b
update global styles
Appilistus Mar 1, 2026
6928a67
Display creator's username of public trip with navigation to their pr…
Mar 2, 2026
168c951
Merge branch 'main' into feature-follow
gabriellaberko Mar 2, 2026
67c6b38
Merge pull request #35 from gabriellaberko/feature-follow
gabriellaberko Mar 2, 2026
6585f60
Fix merge issues
Mar 2, 2026
97ba17d
Merge fix
Mar 2, 2026
099b1fb
Merge fix
gabriellaberko Mar 2, 2026
ea47fa4
add navigate to MyTripCard to redirect to tripsdetailpage when click …
sandrahagevall Mar 2, 2026
fbaf3e8
Change out fetchMyTrips to global state function in MyTripsPage
Mar 2, 2026
9fb57b5
update profile links and change the order of the contents
Appilistus Mar 2, 2026
c1a441b
Merge pull request #37 from gabriellaberko/public-home
Appilistus Mar 2, 2026
7f9920b
Change out states to global states in Explore page + Fix TS errors
Mar 2, 2026
af583ee
Create loading, error and empty state components
Mar 2, 2026
286f5e6
add route for uploadImage, and update CreateTripForm with fetch funct…
sandrahagevall Mar 2, 2026
5e19ee6
add tripdard
Appilistus Mar 2, 2026
ebdece9
Merge pull request #38 from gabriellaberko/public-home-page
Appilistus Mar 2, 2026
bd46659
Change out all error, loading and empty state code to the state compo…
Mar 2, 2026
80d9f01
Refactor buttons and improve CreateTripForm styling
sandrahagevall Mar 2, 2026
a38b70c
add comment to interfaces BtnProps, and Update MainBtn to extend Butt…
sandrahagevall Mar 2, 2026
7263ce4
Merge pull request #39 from gabriellaberko/img-upload
sandrahagevall Mar 2, 2026
7ae0966
Add test animation for explore page
Mar 2, 2026
d5bd77f
Remove edit possibilities of username + Clean code on profile page
Mar 2, 2026
2773f3c
Remove code for updating username in backend
Mar 2, 2026
8619be9
remove spacing in createtripform
sandrahagevall Mar 2, 2026
60c41f2
Merge pull request #40 from gabriellaberko/createtripform-styling
sandrahagevall Mar 2, 2026
26ed08a
Merge pull request #41 from gabriellaberko/states-and-clean-up
gabriellaberko Mar 2, 2026
029c97f
Add EmptyState component in explore page
Mar 2, 2026
7a1c70c
add queries to get/
sandrahagevall Mar 2, 2026
5770254
add fetchPublicTtrips in tripstore, and implement it in explorePage a…
sandrahagevall Mar 2, 2026
1badb0b
Add avatarUrl in server responses for the routes + Set avatarUrl as g…
Mar 2, 2026
974afcb
add route to update ativity
Appilistus Mar 2, 2026
146b1c3
Merge pull request #42 from gabriellaberko/x-buttons
Appilistus Mar 2, 2026
f714f1f
add delete icon on day card
Appilistus Mar 2, 2026
751d4bb
Merge pull request #43 from gabriellaberko/day-x-button
Appilistus Mar 2, 2026
d8aa161
Update follow list page with avatar
Mar 2, 2026
22c51bb
Minor styling on MyTripsPage
Mar 2, 2026
05daa00
Add missing changes in backend to commit for avatar
Mar 2, 2026
debad83
Merge pull request #44 from gabriellaberko/feature-profile
gabriellaberko Mar 2, 2026
88e198b
add trash icon and delete functionality in trip card
Appilistus Mar 2, 2026
a676080
Merge pull request #45 from gabriellaberko/delete-trip
Appilistus Mar 2, 2026
c550b83
stycky navbar
Appilistus Mar 2, 2026
5050403
Merge pull request #46 from gabriellaberko/sticky-navbar
Appilistus Mar 2, 2026
dada8fa
add limit to get all trips route to only show the 5 most liked trips …
sandrahagevall Mar 2, 2026
7827cf0
Merge pull request #47 from gabriellaberko/authHomePage
sandrahagevall Mar 2, 2026
78e5895
Display creator's avatar + Minor styling on TripDetails page
Mar 3, 2026
3e18139
Minor styling changes
Mar 3, 2026
ead0547
implement colors
Appilistus Mar 3, 2026
8a03d02
Merge pull request #48 from gabriellaberko/implement-colors
Appilistus Mar 3, 2026
257a1a9
Remove env files from repository
sandrahagevall Mar 3, 2026
c4ef8b2
Remove env files from repository
sandrahagevall Mar 3, 2026
6ed3e98
add comment for tripdetailspage
sandrahagevall Mar 3, 2026
81883b9
Merge pull request #49 from gabriellaberko/homepage-auth
sandrahagevall Mar 3, 2026
e616dcc
Add start script in package json
Mar 3, 2026
4f42a60
Change build script in package json
Mar 3, 2026
6e96229
Add route for uploading profile picture to folder in Cloudinary
Mar 3, 2026
998b035
add route for feed from followed users
sandrahagevall Mar 3, 2026
ff6f8f9
Add route for deleting the profile image
Mar 3, 2026
6f04827
Fix bug in AuthStore that sets undefined value for avatarUrl in loca…
Mar 3, 2026
d6f0d65
Add navigation on click on avatar in navbar
Mar 3, 2026
837a607
change the color of texts and buttons
Appilistus Mar 3, 2026
749eea6
Merge pull request #50 from gabriellaberko/implement-colors2
Appilistus Mar 3, 2026
7d66a73
Add functionality for uploading profile picture on the frontend
Mar 3, 2026
c319853
Fix UI for image upload
Mar 3, 2026
5bea6c4
Add button and functionality for removing profile image
Mar 3, 2026
cbabdf9
Change to grey icon
Mar 3, 2026
3dcc669
Merge pull request #51 from gabriellaberko/feature-profile-avatar
gabriellaberko Mar 3, 2026
608e358
Remove duplication of avatar in follow list page
Mar 3, 2026
8be68fe
Only render avatar edit button if owner of profile
Mar 3, 2026
2e30fee
add fetchfeedtrips in tripstore, and functionality in authomepage. Al…
sandrahagevall Mar 3, 2026
966a735
Change back to black image upload icon
Mar 3, 2026
516cce9
change styling for AuthHomePage
sandrahagevall Mar 3, 2026
04d4225
make trash/pencil icons invisible when it's other user's trip
Appilistus Mar 3, 2026
546cb7a
Merge pull request #53 from gabriellaberko/dnd-bug
Appilistus Mar 3, 2026
1c5021c
Merge branch 'main' into home-auth
sandrahagevall Mar 3, 2026
d801251
Merge pull request #52 from gabriellaberko/home-auth
sandrahagevall Mar 3, 2026
6b17f8d
fix star/unstar in authhomepage
sandrahagevall Mar 3, 2026
5ce11e5
Merge pull request #54 from gabriellaberko/star-authhomepage
sandrahagevall Mar 3, 2026
dce5775
Add description to trip schema
Mar 3, 2026
77f0567
Add description to POST route for a new trip
Mar 3, 2026
16dd269
Add description to trip interface
Mar 3, 2026
240208e
debug dnd
Appilistus Mar 3, 2026
e6fabaf
Merge pull request #55 from gabriellaberko/dnd-bug2
Appilistus Mar 3, 2026
966d213
Add description to when creating a new trip
Mar 3, 2026
2698a37
add img to MyTripCard. And small adjustment to the carousel in Explor…
sandrahagevall Mar 3, 2026
0f20585
add icons in mobile navbar
Appilistus Mar 3, 2026
34d00a9
Fix small bug of not passing the property avatarUrl when calling the …
Mar 3, 2026
8ec348f
Merge pull request #56 from gabriellaberko/navbar-icons
Appilistus Mar 3, 2026
4ff0acf
Add description to explore trip card
Mar 3, 2026
ad38dc9
responsiveness in the activity form
Appilistus Mar 3, 2026
ab95b3e
make createTripForm responsive
Appilistus Mar 3, 2026
f008e7f
Merge pull request #57 from gabriellaberko/form-responsiveness
Appilistus Mar 3, 2026
eb99752
Add description in TripDetailsPage
Mar 3, 2026
1c8b9d2
Add functionality to update trip description for trip owner
Mar 3, 2026
662e041
Add existing description if there is one as default in editing text area
Mar 3, 2026
f73360b
Change button text depending on if there is a description text set al…
Mar 3, 2026
542fcb3
Merge branch 'main' into feature-description
gabriellaberko Mar 3, 2026
7892194
Merge pull request #58 from gabriellaberko/feature-description
gabriellaberko Mar 3, 2026
d10de82
Add route to update trip description
Mar 3, 2026
1fbcb1f
Add trip description to my trip card
Mar 3, 2026
97ca241
Update buttons for edit profile in profile page
Mar 3, 2026
db802ba
Add space in logout in navbar
Mar 3, 2026
b97fb5a
change styling on mytripcard
sandrahagevall Mar 3, 2026
38b905a
Merge branch 'main' into image-mytripcard
sandrahagevall Mar 3, 2026
a7411b6
Merge pull request #59 from gabriellaberko/image-mytripcard
sandrahagevall Mar 3, 2026
87f49ff
fix styling of mytripcard
sandrahagevall Mar 3, 2026
4bebf2b
Merge pull request #60 from gabriellaberko/fix-mytripcard
sandrahagevall Mar 3, 2026
ffa8e2a
Only render add button for trip creator
Mar 4, 2026
e32b5ec
Styling and add trip image on TripDetailsPage
Mar 4, 2026
1f013a5
Add descriptive paragraph in hero section in public home page + More …
Mar 4, 2026
fcaa041
Minor styling changes in shadow
Mar 4, 2026
db4011d
Add some paragraphs to auth home page
Mar 4, 2026
a3c319d
Fix horizontal overflow and issue with responsiveness for trending ca…
Mar 4, 2026
111f199
Minor styling changes in create trip form
Mar 4, 2026
a51fddd
Update colors in navbar
Mar 4, 2026
0b01859
Change button sizes in profile page
Mar 4, 2026
90593f5
Add navigation to main CTA on public home page
Mar 4, 2026
ba82737
Add primary and secondary buttons
sandrahagevall Mar 4, 2026
f3c2919
change so the description field is reset after adding/changing descri…
sandrahagevall Mar 4, 2026
80a86a3
small styling adjusment in mytripcard
sandrahagevall Mar 4, 2026
763b42b
fix remove button on actiity
Appilistus Mar 4, 2026
782d9e5
Merge pull request #61 from gabriellaberko/remove-activity
Appilistus Mar 4, 2026
40ff96c
Merge pull request #62 from gabriellaberko/buttons
sandrahagevall Mar 4, 2026
715d02e
Add loading component to auth home page
Mar 4, 2026
1694dc8
Add fixed height to conent for vertical explore trip cards
Mar 4, 2026
ffe824d
Align feed with the text
Mar 4, 2026
bd066ff
Add margin to day grid
Mar 4, 2026
569001f
add userId as dependency when fetching trips on profile page
Mar 4, 2026
efe59ee
Add redirects file
Mar 4, 2026
4441037
Add error state component to auth home page
Mar 4, 2026
1ac6a2b
fix styling in mytripcard and fix accessibility issues with explorepage
sandrahagevall Mar 4, 2026
8d4ae39
Merge pull request #63 from gabriellaberko/styling-cards
sandrahagevall Mar 4, 2026
e60660e
delete hardcorded trip description on public trip card
Appilistus Mar 4, 2026
f7c6397
Add profile picture for Gabriella
Mar 4, 2026
5c82e72
Merge pull request #64 from gabriellaberko/fix-public-home
Appilistus Mar 4, 2026
701465a
add profile pic on public home page
Appilistus Mar 4, 2026
6d06838
change the color of lotti in explore page
Appilistus Mar 4, 2026
5c20fe2
Merge pull request #65 from gabriellaberko/lotti
Appilistus Mar 4, 2026
c9d4140
add img in public home page
sandrahagevall Mar 5, 2026
455fffa
Merge pull request #66 from gabriellaberko/img
sandrahagevall Mar 5, 2026
135e491
add profile pic in trip card on public home page
Appilistus Mar 5, 2026
c4c8a15
Merge pull request #67 from gabriellaberko/avatar
Appilistus Mar 5, 2026
8691a98
change color on signup button i publichomepage, and fix responsivenes…
sandrahagevall Mar 5, 2026
ac9b1c9
Merge branch 'main' into button-homepage
sandrahagevall Mar 5, 2026
dcc9d7a
Merge pull request #68 from gabriellaberko/button-homepage
sandrahagevall Mar 5, 2026
d1c19ce
fix bug in add activity functionality
Appilistus Mar 5, 2026
c67801a
Merge pull request #69 from gabriellaberko/add-activity
Appilistus Mar 5, 2026
3584717
change logo to appname
Appilistus Mar 5, 2026
3423e87
Merge pull request #70 from gabriellaberko/app-name
Appilistus Mar 5, 2026
3b44c0f
change the app name of tab
Appilistus Mar 5, 2026
e6056e5
change logo to the app name
Appilistus Mar 5, 2026
99bbf8f
add backbutton to followlistpage and tripsdetailpage. Also change aut…
sandrahagevall Mar 5, 2026
bc9e774
updated app.tsx after changes with modal
sandrahagevall Mar 5, 2026
80c5e64
Merge branch 'main' into back-button
sandrahagevall Mar 5, 2026
b79d7d4
Merge pull request #71 from gabriellaberko/back-button
sandrahagevall Mar 5, 2026
3898ca2
Add readme
Mar 6, 2026
6b66ec7
Fix formatting in README.md headings
gabriellaberko Mar 6, 2026
3efefce
Refactor README.md for improved formatting
gabriellaberko Mar 6, 2026
3a5e1dc
Add logo and favicon
Mar 6, 2026
f95978d
Change size of navatar
Mar 6, 2026
2a37fde
Improve button color for accessibility
Mar 6, 2026
e0f674f
Add readme changes
Mar 6, 2026
75f19ea
fix accessibility for the github and linkedin links
sandrahagevall Mar 6, 2026
58bd7c4
Merge pull request #72 from gabriellaberko/profile/homepage-acc
sandrahagevall Mar 6, 2026
2d81001
Change nav button text and boldness for accessibility
Mar 6, 2026
189d369
Fix problem with responsiveness of explore cards in feed section
Mar 6, 2026
24cd459
Add small fix for trending trips slider to prevent collapsing cards
Mar 6, 2026
0223bdd
Minor improvements on text alignment and size for hero section on pub…
Mar 7, 2026
f7b5876
Change size of logo
Mar 7, 2026
c7e96ba
Remove trip description headline
Mar 7, 2026
9e0022c
clean up code
sandrahagevall Mar 8, 2026
46ad18e
delete images that are not used
sandrahagevall Mar 8, 2026
cb17e0f
fix responsive design in button on publichomepage
sandrahagevall Mar 8, 2026
86eb942
Swap out images in scroll reveal on public home page to gifs
gabriellaberko Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ node_modules
.DS_Store
.env
.env.local
.env.development.local
.env.development
.env.test.local
.env.production.local
.env.production

build

npm-debug.log*
yarn-debug.log*
yarn-error.log*

package-lock.json
package-lock.json
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
# Final Project
# Trippio ✈️ - A social travel planner app
Trippio is a fullstack travel planning web application where users can discover destinations, build and manage trip itineraries, and connect with other travellers. The project is built as a complete fullstack application with authentication, authorization, social features, and rich media support through custom image uploads and dynamic destination photos.
The frontend is built with React and TypeScript and communicates with a RESTful backend API to handle authentication, trip management, image handling, and social interactions in real time.

Replace this readme with your own information about your project.
# Live Site: https://trippio.netlify.app/

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
## Tech Stack
### Frontend
- React
- TypeScript
- Zustand for Global State Management
- Tailwind CSS
- REST API Integration

## The problem
### Backend
- Node.js & Express
- MongoDB
- Cloudinary (image storage)
- Unsplash API (destination imagery)

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?

## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
## Features
- Search and browse travel destinations
- Create, edit, and delete personal trip itineraries
- Upload custom trip images or fetch curated destination photos via Unsplash
- Images stored and served via Cloudinary
- Share trips publicly with other users
- Follow other users and explore their trips
- View and edit your personal profile
- Sign up & log in with persistent sessions
- Responsive design across desktop and mobile
- Error handling and loading states
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
12 changes: 12 additions & 0 deletions backend/express.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { User } from "./models/User";
import "express-serve-static-core";

// Extending the Request type to also include user (for TypeScript)
declare module "express-serve-static-core" {
interface Request {
user?: User;
}
}


export { };
34 changes: 34 additions & 0 deletions backend/middlewares/authMiddleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { User } from "../models/User";
import { Request, Response, NextFunction } from "express";


export const authenticateUser = async (req: Request, res: Response, next: NextFunction) => {
try {
const authHeader = req.header("Authorization");

if (!authHeader) {
return res.status(401).json({
message: "Missing Authorization header",
});
}

const accessToken = authHeader.replace("Bearer ", "");

const user = await User.findOne({ accessToken });

if (!user) {
return res.status(401).json({
message: "Authentication missing or invalid",
});
}

req.user = user;

next();
} catch (err) {
res.status(500).json({
message: "Internal server error",
error: err instanceof Error ? err.message : String(err)
});
}
};
25 changes: 25 additions & 0 deletions backend/middlewares/optionalAuthenticateUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { User } from "../models/User";
import { Request, Response, NextFunction } from "express";

export const optionalAuthenticateUser = async (req: Request, res: Response, next: NextFunction) => {
try {
const authHeader = req.header("Authorization");

if (!authHeader) {
return next();
}

const accessToken = authHeader.replace("Bearer ", "");

const user = await User.findOne({ accessToken });

if (user) {
req.user = user;
}

next();

} catch (err) {
next();
}
};
19 changes: 19 additions & 0 deletions backend/models/CityImage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import mongoose, { Schema } from "mongoose";

const cityImageSchema = new Schema({
city: {
type: String,
required: true,
unique: true,
trim: true,
lowercase: true
},
images: [
{
type: String,
required: true
}
]
});

export const CityImage = mongoose.model("CityImage", cityImageSchema);
65 changes: 65 additions & 0 deletions backend/models/Trip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import mongoose, { Schema } from "mongoose";

const activitySchema = new Schema({
name: {
type: String,
required: true
},
description: String,
category: String,
time: String,
googleMapLink: String
});


const daySchema = new Schema({
dayNumber: {
type: Number,
required: true
},
activities: [activitySchema]
});


const tripSchema = new Schema({
tripName: {
type: String,
trim: true
},
destination: {
type: String,
required: true
},
description: {
type: String,
default: ""
},
imageUrl: {
type: String,
default: ""
},
isCustomImage: {
type: Boolean,
default: false
},
days: [daySchema],
creator: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true
},
isPublic: {
type: Boolean,
default: true
},
starredBy: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "User"
}
]
},
{ timestamps: true }
);

export const Trip = mongoose.model("Trip", tripSchema);
47 changes: 47 additions & 0 deletions backend/models/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import mongoose, { Schema } from "mongoose";
import crypto from "crypto";

const userSchema = new Schema({
userName: {
type: String,
required: true,
unique: true,
trim: true,
},
email: {
type: String,
required: true,
unique: true,
lowercase: true,
},
password: {
type: String,
required: true,
},
bio: {
type: String,
default: "",
},
avatarUrl: {
type: String,
default: "",
},
isPublic: {
type: Boolean,
default: true,
},
followers: [{
type: mongoose.Schema.Types.ObjectId,
ref: "User",
}],
following: [{
type: mongoose.Schema.Types.ObjectId,
ref: "User",
}],
accessToken: {
type: String,
default: () => crypto.randomBytes(128).toString("hex"),
},
});

export const User = mongoose.model("User", userSchema);
24 changes: 20 additions & 4 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@
"version": "1.0.0",
"description": "Server part of final project",
"scripts": {
"start": "babel-node server.js",
"dev": "nodemon server.js --exec babel-node"
"start": "node dist/server.js",
"dev": "nodemon --watch . --exec ts-node server.ts",
"build": "tsc"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.17.9",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"bcrypt": "^6.0.0",
"cloudinary": "^2.9.0",
"cors": "^2.8.5",
"dotenv": "^17.2.4",
"express": "^4.17.3",
"mongoose": "^8.4.0",
"express-list-endpoints": "^7.1.1",
"mongodb": "^7.1.0",
"mongoose": "^8.23.0",
"multer": "^2.1.0",
"nodemon": "^3.0.1"
},
"devDependencies": {
"@types/bcrypt": "^6.0.0",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.6",
"@types/multer": "^2.0.0",
"@types/node": "^25.2.3",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
}
}
}
Loading