
Tripcoster
The entire cost of a trip to anywhere - βοΈ+ποΈ+π»
The app's been live a few weeks now - and it's gotten a lot of interest from the tech communities where I shared it - but this morning I checked my referral dashboard for flights and saw that someone made a booking using my referral!
I'll make β¬13 from it! :D
Originally I built Tripcoster.com with just a basic implementation of Vue.js. I love Vue so far, but now I need to re-think it, as the feature set is growing, and I need to be smarter about how I handle routing in the app (I want people to be able to share a specific destination/date range etc.
So now I'm making the frontend of the app its own Vue CLI project. I've been reading up on it, and there doesn't seem to be a 100% recommended way of doing this for production - so it's gonna be a bit of trial and error I imagine.
The standard seems to be making the frontend its own app, and maybe just send the /dist folder over into my backend app then to be served up in production. This is actually the exact approach I used for my last side project, mydevportfol.io. That was an Angular app, but it was the same idea.
Wish me luck, and if you've any good resources on this, holler at me. :)
4 Likes
13 Comments
13 Comments
-
3
Not sure what you're trying to accomplish. Do you want to have a full SPA with client side routing? Or do you want to have some server side stuff happening and on a few pages you want to let Vue handle the routing?
I have experience with Vue as I'm working with it everyday at my day job so let me know if you need some guidance.
-
1
Hey man,
I could use some guidance if you've got a minute! I've been working with Vue, Express, MongoDB, and Node for a side project but I'm having trouble understanding the best way to link the front end routing to the back end routing... take the login for example, when a user enters their credentials a post request is fired to the back-end where it handles the authentication, but then whats the best way to redirect the front-end based off of the results of the back-end?
Would you be able to explain how routing is supposed to work when you have a back-end? I'm loving the front end abilities that vue offers but I'm having trouble linking it all together!
-
2
There's a few ways to do it.
-
You can go the full server-side rendering route. This would mean that all routing is done on the server and you would need to set up Vue as a multi page app, which is easily possible with Vue Cli 3. So now for example the authentication would do a post request and then you redirect on the server to the relevant page if the request was successful.
-
Go the full SPA route. Authentication is the "hardest" challenge to tackle because you'd have to go with JSON web tokens and have token based authentication. Fortunately there's a lot of libraries for this. I know of Passport Js but I'm sure you can find many others. So now you handle all of the routing logic in the front end. So for the authentication, if the post request was successful you'd get back an auth token and you would redirect to the relevant page in the front-end.
I don't have that much experience with express but usually, when you authenticate server side, the server automatically sets an authentication cookie on the browser so it can track the user session. You could return that cookie when the login was successful and set it manually on the browser from the front-end. So you still have the full SPA it's just a different auth method.
I like the tokens approach a bit more though because then your server doesn't need to keep the user's state.
- Hybrid half-half monstrosity π. It's not that bad actually it just feels wrong to me.
Apart from authentication, I don't see why you would need server-side routing because everything else can be easily made as API calls instead of returning pages.
The way I would approach this is have an SPA with client routing for everything except the authentication. So whenever a user makes any request to one of the SPA routes, you redirect them login page if necessary, otherwise you just ignore it server side and let it be handled on the client.
For example say a user wants to navigate to /account/settings.
You would intercept that request server-side. Check if the user is authenticated. If not you redirect to the login page.After the post request is successful, you redirect to the URL of /account/settings but the html page you return is the SPA entry point. This way, when the SPA is loaded it will check the URL and go to the relevant client-side route.
-
-
1
I've used Vue.js quite a bit, mostly as embedded code (<script src="...") but also a handful of CLI apps. For the former, it has proven to be quite simple to handle both front-end and back-end navigation as natural hyperlinks. For the latter, I can't imagine implementing it in any way except exposing everything from the back-end as an API which can be consumed.
That being said, both approaches have proven to be very powerful.
-
-
1
Hey! Thanks! I actually only wrote this post as a sort of chronological update for myself so I can look back - kindof forgot it'd go public π
So for the first MVP I just imported vue from the cdn and had my own somewhat convoluted build process using gulp. I want to move over to vue cli because soon I'll want to start doing much more interesting stuff with the app like user accounts etc. So a more sane component structure would be great.
So the main thing is I want to be able to add routing like tripcoster.com/dub/vie/weekend/august/2019. So that someone can link directly to a search for Dublin - Vienna for a weekend in August. I know vue router can do that so I wanted to rebuild it with cli and a sane structure before going deeper into the realms of building everything myself from scratch in a non maintainable way.
Another thing I'll want to tackle soon is some server side rendering of stuff. I've vaguely heard that nuxt can do this?? But that's a little ways off for now I think.
Thank you for the reply tho ππ
-
2
Vue router should be really easy to include when scaffolding with vue cli, and it indeed can handle the requirements you described.
As for server-side rendering, you'd need an instance of Node js running somewhere on your server so it can actually process the javascript and render the page. You said its gonna be a problem in the future but it might be worth to at least make sure your prod env can run node js for now so you don't have to make the switch in the future when maybe you're locked in.
But yeah, Nuxt is the easiest option I think.
Good luck on your app!
-
-
-
2
You can definitely set up routes as you describe by adding vue-router to your project without having to rewrite the whole thing.
-
1
Yup I know about the router but I didn't want to be stacking stuff on top of a shaky foundation so I'm taking the opportunity to rewrite it as a vue cli app. Actually made fantastic progress last night after writing this post! Thanks for the link tho ππΌππΌ
-
-
2
This comment was deleted 5 years ago
-
2
I actually made fantastic progress after writing this so yeah, I think I do! πͺπΌπͺπΌ
-
I finally got Tripcoster to a point that it could be shown to the world. It's pretty basic - and the mobile experience is far from stellar, but she's live.
I posted to /r/webdev to share how I technically built it (a common trap for me - because I like sharing that type of content and it's safe).
What I SHOULD be doing is posting it in travel subreddits - but that's scary because they won't care what APIs I used or how I got my page to load fast. They'll give me hard feedback about the product. And how I may have done stuff wrong.
But that's the next step.
Here goes nothin.
1 Like
Comment
My girlfriend likes to travel. I like to know how much it's gonna cost for us to see the wonders that the world has to offer us. I like to plan out the trips, finding the best time of the year to go, and finding locations that are cheap to get to but great value for money.
I knew there were APIs out there that could give me all of this information. I just needed to glue them all together. The result is Tripcoster. :)
So far it's basic - only showing hostel accommodation.
In the future I'd like to add weather data, and data for how much things cost there like drinks or food.
Like
Comment
About
I don't like opening multiple tabs to try find the cost of a trip to a given destination. I want to know flights, accommodation and living costs for wherever I want to go






9 Comments
Nice, well done! The first of many I hope πIt's a pretty crowded market place (referrals based travel sites), I like the simplicity of your website at the moment, how do you plan to differentiate yourself and drive traffic to the site?
To be honest I'm not sure how I differentiate. Ive never seen an app that gives you the whole cost of a trip, so I guess that's a differentiator. Not 100% sure tho. Have you any ideas?
well, a lot of companies that lead with one service e.g. flight booking, then allow you to build out the whole trip during the checkout process. I like that yours shows both simultaneously for a change...arguably a differentiator. I guess you could/should add some price filters as the project develops and show how your prices compare to some similar sites (if you can get that sort of data). Do you know https://travelbird.com/ ? They are slightly more like package holiday focused, but that's essentially the end game for referrals sites when they want to increase their margins :)
Interesting! I was thinking that if the app got enough users and enough data, it could auto-generate "packages" based on some initial user inputs.
Marketing this is a real challenge for me at the mo. Not sure how to go about getting traffic right now
Probably too tough to get into pay per click battles with other referral sites on google?
Congrats Chip!
Thanks! π
Good start! Keep doing more! Congratulations!
Cheers! βΊοΈππΌ