6 ms·
Show HN: Routerless
- madmaniak 9y agoTreat url as a store. Serialize to url and deserialize to objects.
- ZeroCool2u 9y agoI can't think of too many instances in which I would use this personally, but seems very useful for things like saving web game state.
- madmaniak 9y agoGame is a complex thing and it would handle it perfectly. Believe me it handles really well also simple cases. For me it's not a first iteration on the idea of routing automation. It gives you freedom and is really handy. Even if you never thought defining routes is a problem. I hope you'll give it a try.
- mstaoru 9y agoTiny lib with a website that pulls 1.1 MB of JS.
- madmaniak 9y agoWill fix. I was in a rush.
- tomc1985 9y agoWhy are you showing something that's rushed? If this is a personal project what's the deadline? Why not wait until you have a finished product (eg hosted on a proper port 80 web URL with a domain name)
- janpieterz 9y agoMy gut tells me it's a great idea, but indeed as others say, take the time!
- madmaniak 9y agoThank you for your advices. What can I say - I am and I will be in a rush for a while. I have also bigger personal projects. I'm glad I was able to ship it now. I have good feedback and I'll make it better thanks to your comments. I'm glad you took a while to see it despite all defects of the project site. If you like it please subscribe or connect me on twitter - I doubt I'll reach your attention again. Promoting personal projects is incredibly hard.
- rocky1138 9y agoI went to the website and got a white screen. Is the JS required?
- Findeton 9y agoDon't you have a domain? And you can setup cloudflare for free..
- madmaniak 9y agoThanks for recommendation. I've linked it to my domain http://router.maniak.pro:3000 http://router.maniak.pro:3000 right now. I'll change the port to standard http soon.
- daveio 9y agofinally, XSS As A Service.
- madmaniak 9y agoNice one :) You decide what you keep in url. Use case of google map when you're scrolling a map and you want to share a location with your friend is not vulnerable, right? Now it's easier
- nycmattw 9y agoYou should try and make the page a bit smaller. This is what I see on my Macbook Air: http://imgur.com/a/Mi3lb http://imgur.com/a/Mi3lb I tried scrolling to the left thinking there was more content, but that was it. It looked better on Chrome when I set the size to be 80%.
- madmaniak 9y agoThank you, I'll improve it
- aphextron 9y ago>Just 67 lines of code and less than 900 bytes while minified and gzipped. If this is 67 lines of code with zero dependencies, why do I need it as a dependency? Regarding CDN implementation, why would anyone add an HTTP request to the page for 900 bytes?
- madmaniak 9y ago1. Please explain me what you'd like to know. Router is one layer of SPA / PWA so you need it if you want to make one. It's framework independent and I'd not like too add more dependencies to your project for such a small thing - even if it's powerful. 2. If you want to check it out quickly with minimal effort, play in your browser js console - it's there.
- amingilani 9y agoCan someone please ELI5 what I'm supposed to be seeing? I just opened this page and saw a bunch of buzzwords. What is this? What is this for? Why is it hosted on an IP address?
- fredley 9y agoWhy is it running on port 3000?
- safeharbourio 9y agoop couldnt be bothered to reverse proxy it behind nginx/{other load balancer}.
- 43224gg252 9y agoor just redirect port 80 traffic to 3000 with iptables, it's one command. sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
- madmaniak 9y agoThank you for all advices. I'll host it properly. But what do you think about the library?
- amingilani 9y agoIt took me a while from reading all the comments to realize that it's a client side library that stores state in the URL. It's nice but I'm still not sure when to use it and why you made it. Maybe you could add your personal use and motivation to it? Otherwise it's a clever library.
- madmaniak 9y agoI just disagree with declaring paths with kind of regex pattern matching set of rules. This approach is flexible and natural. It will not stop you when your application became complex and even with simple cases it's faster - you touch less places in your code to make a change.
- a13n 9y agoHow is this different than building a single page app with say, react router + redux?
- madmaniak 9y agoYou can use anything with this router (redux too). I agree react router is a nice tool - but in a classic paradigm. The difference is - you don't define routes. If you create a component and it needs a data you just ask the url store for it. Or if you need to persist some data you just write to the store. It creates nice urls - always a name and a value. Additionally you have setters which will handle a serialization of your object to nice string. And of course getters which will wrap your data into a custom object - so it's not a string.
- coding123 9y agoProbably want to remove "goddamn"
- artursapek 9y agolol, what?
- AndrewStephens 9y agoI think I see what this is for, despite the unilluminating site. Storing state in the URL is a good idea - it lets your users bookmark and share links to your application's state. I have a couple of questions though: When I have done this in the past, I have used the url fragment to store the state, i.e.: https://sheep.horse/tagcloud.html#computing https://sheep.horse/tagcloud.html#computing . This works even with static sites because the browser doesn't send the fragment (everything past the # symbol) to the server. By encoding state in the path of the URL, you require server support. I guess the flip side of that is that your site can continue to work without js support. I notice that your demo and docs don't mention anything about manipulating the browser's history to allow the user to move to previous states using the back button. That can be a pretty useful thing to provide.
- floatingatoll 9y agoFragments are worse than described here. Fragments are incompatible with redirects. Not only does the browser not send them, but any server-side redirects will either require active-JS redirects to capture and redirect the fragment, or strip the fragment as inappropriate/pointless, or if you're very lucky, maintain it somehow through the redirect. Do not use fragments for any critical function without vetting your entire workflow and all servers and useragents in your request/response path.
- AndrewStephens 9y agoWhat you say is absolutely true, and I agree. But I also subscribe to the URLs-are-user-interface school of thought and think that implementing redirects to change your UI requires careful thought. I'll admit that sometimes it is unavoidable as applications change over time. Maintaining state in the path, query parameters, or fragment are all techniques that can work, but each comes with disadvantages. I wonder if anyone has been mad enough to maintain state in subdomains: https://accnumber18573.color-yellow.example.com/ https://accnumber18573.color-yellow.example.com/
- madmaniak 9y agoYou have a valid point about # and that it works on static site. I'm aware of that and I'll add this as a feature so you'll be able to choose on init(). Please explain me the part about back button on example.
- skrebbel 9y agoI think I like the idea, but the docs are a major puzzle. This is a library for mapping URLs to data (or function calls? not sure) without a single URL in the docs. There is also a demo, which shows that it works, but not how it works (no source code displayed except if i want to dig down in the entire site's source code). @madmaniak, add some examples, please :-)
- madmaniak 9y agoThank you for kind words and sorry for being so enigmatic. Step 1: Attach pro-router Step 2: R.init(root: 'helloworld') Step 3: R.write('foo', 'bar') # url changes from '/' to '/helloworld/foo/bar' R.param('foo') # => 'bar' Please ask me any use case you'd like to solve. I'll try to explain more.
- sAbakumoff 9y agohttps://dayssincelastjavascriptframework.com/ https://dayssincelastjavascriptframework.com/
- madmaniak 9y agoas you see it's a small tool you can use with any framework
- sAbakumoff 9y agoI know, but I am sending this link to any JS related thread in HN ;)
- madmaniak 9y agoYay! :D
- jmeyer2k 9y agoThis is just a static site with a zero.
- sAbakumoff 9y agoYes, this is the crux of the joke :-)
- davexunit 9y agoWhy is pattern matching "stubborn"? Seems like the perfect application of a pattern matcher.
- ryandrake 9y agoAll I see initially is a white screen. Then realized I had to scroll down (and oddly to the right!) in order to see any content. Clicking on "DEMO" leads to the same thing (scroll right for actual content) but with super large text and oddly-placed elements. Still not quite sure what this is about, but it looks like a neat art project?
- madmaniak 9y agoObviously I failed with preparing a proper flexbox css. I had one day to make this website. I'll polish things too look well. If you can ignore the layout you'll find neat art project for frontend routing :)