29 ms·
Show HN: Zero – A fast, zero-configuration server for React, Node.js, Markdown
- photonios 8y agoI think this is really nice for when I want to hack together a quick front-end for something. Once I have a working React/Node.js set up I can really quickly build something, but what usually stops me is the dozens of packages and things I need to wire together before I can actually start building something. `create-react-app` is also pretty good, but this seems to do a bit more. I really like the simplicity of the set up and the fact that you can also just whip up an API call or something.
- sametmax 8y agoI find that the best thing about create-react-app is the eject feature. It's an instant tutorial on how this damn mad hatter of an ecosystem works. They heavily commented the thing too ! Honestly, any lecture on react should have a part where people ejects and read the source code.
- rekshaw 8y agoThis is exactly what I needed. However with great abstraction comes great responsibility: you are now the gatekeepers of keeping things efficient in the backend. If I write "require('moment')", will you blindly require, or will you require, tree-shake, minify, etc? I guess my question is: can I trust Zero to always strive for optimum efficiency, or is it just convenience?
- yodon 8y agoIf your requirements include "optimum efficiency", you almost certainly are not in the sweet spot for a general purpose zero configuration product.
- rekshaw 8y agoI guess optimum/optimal efficiency is a lot to ask for, of anyone, let alone a convention over configuration framework, but you get my point!
- asadlionpk 8y agoI think that's a valid concern. We can certainly optimize and enable tree-shaking (zero uses Parcel to bundle React and HTML). The idea is to implement common optimizations so users don't have to. But also to provide enough escape hatches so advanced users can 'eject' and fine-tune themselves.
- rekshaw 8y agoYes please do, I just have a pet peeve against npm modules requiring mb's of files to only use a couple functions. Knowing that Zero does tree-shaking and general optimizations for me will make me happily use for most of my projects!
- PerryCox 8y agoHaving Markdown rendered as HTML is basically all I want when I'm standing up a single web page or a small website. This is definitely something I'll bookmark for later.
- scrollaway 8y agoCaddy also has native Markdown functionality, by the way. https://caddyserver.com/docs/markdown https://caddyserver.com/docs/markdown
- gjmacd 8y agoWhy is this any different than say, next.js?
- asadlionpk 8y agoNext.js does file-based routing for React pages. This does the same for your API functions too.
- dzek69 8y agoserver is down (yay for proof of scalability ;)) so i can't tell for sure, but it looks like it's derived/based on next.js and comes from the same authors
- dzek69 8y agoserver is up again and it wasn't the case. the page and code styling misleaded me
- joshstrange 8y agoMy first thought is it doesn't have enough features or too much magic BUT that is EXACTLY why it shines. I'm not going to build the next FAANG company on this but it will let me get a backend up and running VERY quickly to test out an idea. The number of ideas of mine that have been killed in the cradle by decision paralysis is higher than I would like...
- asadlionpk 8y agoExactly this. One of the aims to start this project was to reduce one more friction when testing an idea. Project configurations and set up is a big time suck.
- joshstrange 8y agoThank you for creating this! I often find I had an idea and then spend 1-2 hours doing NOTHING towards the idea trying to future-proof what I'm writing to the max. That is a trait of mine I need to work on by itself but "zero" should help let convince me to "just try it with zero before you setup TypeScript/Angular/Vue/React/Cordova/Express/etc...". I saw your other comment about making it Apache/PHP level easy and as someone who came from that background and when I first saw a query param displayed in the response from the web (ie: localhost?name=Josh -> Hello Josh!) I was hooked (you can imagine my reaction when I learned what a database was ). In that vein do you think TypeScript is on the horizon for support? It's not a dealbreaker by any means but it would be nice to just write .ts files and have them automatically compiled (transpiled?). I can write JS just fine but TS's types are a nice sanity check for me.
- xxandroxygen 8y agothe project's philsophy seems to be "use a bundler that works and don't reinvent it" so I bet adding a TS bundler would be a possibility, that'd be awesome
- asadlionpk 8y agoThanks! I will def move .ts up the list. It should be easy to add.
- lugg 8y agoAt quick glance. Cool. Dig the idea, going to have to take a deep dive to see how things work later. I still have to have a giggle at the similarities between what you produced and what is essentially a PHP/Dom/Apache setup. The Async wait for initial props before what is essentially a template render just drove it home. One key thing missing is an easy wrap around running tests. What would it take to add this?
- asadlionpk 8y agoI started with PHP / Wordpress themes myself and the aim here to bring back the simplicity of web development. Def inspired by PHP/Apache setup.
- gumbo 8y agoThis is very cool framework and I will certainly use it for small to medium sized apps or website. However, just going through the doc there doesn’t seems to be a way to split components since any file is assumed to be a page. Any way around that? Lastly, it’s a shame that the doc link points to github. The doc, as layed out in github is a perfect use case for zero.
- asadlionpk 8y agoYou are very right (and I did try that). I just wanted to avoid redundant docs for now. As it's a bit sparse and is continuously being updated.
- bryanlarsen 8y agoIt seems to me that you should have a folder (www?) that is served by zero, and a folder (lib?) that isn't. Then files in the www folder can import from the lib folder.
- dstroot 8y agoSupports the new hotness MDX. JSX/React components inside markdown. This is awesome for standing something up quickly. Thanks for creating this!
- xxandroxygen 8y agothis is impressive! I would absolutely reach for this first when scraping something together quickly. I'd be super interested in seeing numbers for just how far this can scale before falling over.
- asadlionpk 8y agoCurrently this is as scalable as a normal node+express app. The aim for now is to improve development experience for now.
- xxandroxygen 8y agoLove it, that's what I figured, and I agree with the aim!
- giancarlostoro 8y agoThe time example reminds me of WSGI for Python. Neat that it supports templates too.
- desmondl 8y agoAre there any plans to make this support Typescript in the future? :)
- asadlionpk 8y agoYes. Should be easy! As we are not a typescript shop yet, we might need a hand with that. Otherwise, I will try to figure it out soon.
- q3k 8y ago> File-system Based Routing: If your code resides in ./api/login.js it's exposed at http://<SERVER>/api/login http://<SERVER>/api/login. Inspired by good ol' PHP days. > Auto Dependency Resolution: If a file does require('underscore'), it is automatically installed and resolved. You can always create your own package.json file to install a specific version of a package. This sounds like a security nightmare. EDIT: to be clear, I don't meant he combination of both is a security concern, that each one of them separately is problematic.
- gpmcadam 8y agoJust like "good ol' PHP days!" as the docs say :D
- untog 8y ago...why? I get that file-system based routing means you know the location of a source file on disk, but if anyone can access that file you've already lost. And auto-dependency resolution also doesn't seem any larger a security concern, all it's doing is skipping an "npm install" command.
- q3k 8y agoBecause if you ever have a broken upload system that allows you to drop a JS file somewhere accessible by the file system routing, you have remote code execution. Additionally, you now have to write guards in every non-endpoint JS file so that it doesn't get executed just by a misplaced HTTP request. And as for automatic dependency resolution, this means you're not even aware of what transitive dependencies you're pulling in, what version they are and have no way to vet anything - everything is hidden behind a wall of magic.
- adrusi 8y agoMake your application directory read-only to the user running the application, as it ought to be anyway. Automatic dependency resolution however... Fantastic for experimentation, but that's a dealbreaker for production. Maybe it would be OK if it actually wrote the package-lock.json to the application directory, I'd have to think about that.
- davish 8y agoLooking through the code on github found a .py file handler in the works: https://github.com/remoteinterview/zero/blob/master/packages/handler-python/handler.js https://github.com/remoteinterview/zero/blob/master/packages... Any idea of a timeline on this feature? I think it could be really awesome to be able to prototype with python in addition to js.
- asadlionpk 8y agoThe js part (React, MDX, Node) is almost complete. I will put out a basic handler for python ASAP if that's going to be useful to you :)
- nvusuvu 8y agoWould be for me.
- brillout 8y agoReframe author here (https://github.com/reframejs/reframe https://github.com/reframejs/reframe). This is super interesting, what are you plans regarding this? Super curious.
- raihansaputra 8y agoI'm interested
- sjroot 8y agoIs there any way to "ignore" specific files or directories? For example, I want to reuse React components across different routes (exposed as jsx files). However, I don't want `mysite.com/components/Container` to be a valid endpoint.
- deleted 8y ago[deleted]
- sjroot 8y agoI would propose adding support for a 'zeroignore' file to handle this. :)
- asadlionpk 8y agoYes. It's not written in docs yet but any file or folder starting with _ (underscore) is not exposed publicly. This feature spec is still open for discussion as on how to tackle it the best.
- sjroot 8y agoCheck my reply to this comment. The underscore idea was one of the first things to come to mind too, but I think having a specific file makes it clear to others who might not understand Zero internals.
- asadlionpk 8y agoYou are right. A .zeroignore file seems like a good idea.
- jermaustin1 8y agoWould that not count as a configuration file though?
- shadofx 8y agoYou can still configure zero conf frameworks, it's just not explicitly required for it to function
- awb 8y agoFor markdown based sites, why not statically generate the site? Why render it on each request?
- asadlionpk 8y agoAs markdown can be dynamic in this case. (see https://mdxjs.com https://mdxjs.com). Static 'export' can be a good feature though.
- html5web 8y agoGreat job! Took 2 minutes to install and run.
- miki123211 8y agoAs others have said before, I think this is amazing for small one offs and maybe for beginning programmers. I'm afraid that, like all frameworks, people will start to misuse it eventually. Someone will make a little app with that, because it's so fast, simple and amazing, right? Later, however, the app will grow and it will become a maintainability nightmare. The only good thing about it is that you can easily get out of this framework and migrate to managing express/node/react yourself, or so it seems. It isn't like rails, where if you get into it, your app is so highly coupled to it that any escaping is impossible, even if your app becomes very complex.
- asadlionpk 8y agoEscaping and writing a custom node+express+React SSR server for a zero-based app should be easy. But zero isn't a 'platform' anyway. It's just an abstraction on common config and some glue code, all open-source so you can easily fork and improve.
- insulfrable 8y agoMinimalism has a cost. http://npm.broofa.com/?q=zero http://npm.broofa.com/?q=zero
- asadlionpk 8y agoStanding on the shoulders of giants :) You will eventually be adding all those packages when you develop a production-grade React / Node app anyway.
- insulfrable 8y agoPerhaps this should be done gradually and thoughtfully, rather than pulling half the internet into each minimalist app out there.
- progx 8y agoWelcome to the world of node.
- wesleytodd 8y agoThis is nothing to do with node. This is poor programmer decision making. You can build great node apps with a real minimalist approach. Holding up projects which pull in half of npm as "the world of node" is like holding up a hot and ready 5$ pizza and saying all Italian food is bad.
- SahAssar 8y agoI think the point is that this is almost encouraged in the node ecosystem, while in most other language ecosystems I know of it wouldn't be.
- wesleytodd 8y agoEncouraged by who? I see the same people which used to install jQuery or WordPress plugins and were able to get janky but working sites. But prolific module authors and node core contributors don't promote these approaches. Maybe if you listen too much to twitter "thought leaders" you might get this impression, but we are all aware of the problems with social media platforms...
- metalrain 8y agoWhile I embrace less configuration, you can't really avoid TLS these days. There is always configuration, many of configurations. Some implicit, some explicit.
- miki123211 8y ago> Zero reads credentials from environment variables. Zero also loads variables from .env file in your project root, if it's present. Security nightmare? Can I do myapp.com/.env and read the credentials from the wider internet?
- chickenfries 8y agoWhy would you assume that they have this bug? If you’re actually curious if the bug exists go read the code or try it yourself.
- ozten 8y agoAnother common on this page documents this bug on their production website.
- benhowdle 8y agoMaybe a silly question, but is there anything one needs to consider before deploying this to, let's say, Heroku?
- notduncansmith 8y agoNah
- dammod 8y agoAs others have pointed out, make sure to mark files that are not supposed to be exposed to the client by prefixing them with a underscore, otherwise you'll have a bit of a security issue. Otherwise, you're good to go.
- benhowdle 8y agoAce! but in terms of running it, how would Heroku know how to, ie. if there's no `package.json`, there'll be no `npm run start` defined?
- asadlionpk 8y agoThis should help: https://github.com/remoteinterview/zero#running-on-cloud https://github.com/remoteinterview/zero#running-on-cloud
- benhowdle 8y agoOh, never spotted this: https://github.com/remoteinterview/zero#running-on-cloud https://github.com/remoteinterview/zero#running-on-cloud Oops. Couldn't see it on the main docs site (https://zeroserver.io/ https://zeroserver.io/)
- wesleytodd 8y agoWow, I love that people can wrap express and many of its components and end with something so different from its foundation. That being said, this level of "batteries included" approach has a cost. In this example, it is the complexity of this file[1] and the fact that if you were to write this as a single express middleware you could probably write it in less than 20 lines. Guess this is just not my cup of tea? [1] https://github.com/remoteinterview/zero/blob/master/packages/core/lib/router/index.js https://github.com/remoteinterview/zero/blob/master/packages... Edit: also looks like the author decided to wrap their own multi process model? https://github.com/remoteinterview/zero/blob/master/packages/core/lib/router/index.js#L140-L182 https://github.com/remoteinterview/zero/blob/master/packages...
- progx 8y agoYes, writting an express backend is really simple, some plugins, error-handling etc. and you can run it in less than 1 hour. But the Frontend with webpack needs definitely more time, hours and hours to fiddle webpack to your needs. This project has a definded strucutre and support defined modules (react), so it could save you a lot of webpack config time, but you can not do everything with it. You have to use it as it is.
- wesleytodd 8y agoLol, if the setup on the FE takes hours to fiddle something is wrong with the choice of tooling. I don't use webpack, so I guess I am just spoiled?
- asadlionpk 8y agoThe alternative is using parcel. Zero is a server equivalent to Parcel (and uses parcel internally)
- progx 8y agoYou never use it, or? It is nothing wrong with the tool, the tool does what it does. I sayd to configure it, to fit exactly your needs, it take a long time. Using an other tool will not change it.
- leowoo91 8y agoSo cycle repeats, PHP reborn?
- marcrosoft 8y agoZero configuration... read "We made choices for you, just trust us. Read our documentation to see what your missing. Oh, also since you didn't configure it we'll change (the defaults) on our next release".
- Vinnl 8y ago> Oh, also since you didn't configure it we'll change (the defaults) on our next release That doesn't really matter, since I'll only use the next release for my next release, and the previous prototype has either been thrown away or turned into a proper stack.
- lotyrin 8y agoI wonder if this what the people who made the things I have to inherit and patch and secure believed. Current app is EOL Framework Release in an EOL Language Release running on an EOL Distro Release on an unmonitored server without any patches applied... so business as usual.
- revskill 8y agoHow to override default routes, then ?
- asadlionpk 8y agoCan you give me an example of a rewrite? Zero already does some rewrites: https://github.com/remoteinterview/zero#route-rewrites https://github.com/remoteinterview/zero#route-rewrites
- tathougies 8y agoRule 35: Every year, someone somewhere will reinvent PHP or CGI or some combination of the two.
- MarvelousWololo 8y agoWhere can I find the other rules?
- tathougies 8y agoI make them up as I go along!
- aliswe 8y agoIn non-sequential order. :)
- MarvelousWololo 8y agolol let me know if you ever compile them in a single place. love it!
- SahAssar 8y agoThese will carry you over until the "real" ones appear: https://spacecraft.ssl.umd.edu/akins_laws.html https://spacecraft.ssl.umd.edu/akins_laws.html
- yowlingcat 8y agoI want to print these out and share them with past teams I've worked on.
- MarvelousWololo 8y agoawesome! thank you!
- anitil 8y agoIf you ever watched NCIS, I have just the thing: http://www.ncisfanwiki.com/page/NCIS%3A+Gibbs%27+Rules http://www.ncisfanwiki.com/page/NCIS%3A+Gibbs%27+Rules
- LoSboccacc 8y agoWeird how does it knows what certificate to get for https
- asadlionpk 8y agoYou probably need nginx in front of this.
- mighty_bander 8y agoMy God, the people on this thread. There are people out there, working as software "engineers," who think that if they can't personally find a vuln in 5 seconds, the system must be secure. How is this #1 on the site right now?
- asadlionpk 8y agoI thought that was ‘banter’ in your username.
- didip 8y agoWhere have I seen this before... CGI scripts?
- coolgoose 8y agoI am so confused why the 'good old days' of php is a good example of how to do application development. Every php framework got away from that for really good mesure, including not having your logic in the server document root.
- playpause 8y agoIt's for quick experiments and prototypes. PHP (without frameworks) was great for that.
- asadlionpk 8y agoEasier to create. With a path to scalability if ever needed.
- slim 8y agoEvery php framework got away from that for really good mesure, including not having your logic in the server document root. IMHO unless you are building a http daemon, "your logic" should probably not include routing http requests. Using directory tree, url rewriting or generally leaving the controller part of your logic to the underlying httpd is probably fine in most php projects. Note: php frameworks can't do microservices
- joshstrange 8y agoPeople in this thread are way overly negative. I understand this tool as something to be used for prototyping and locally-only but everyone is jumping on how insecure it is or how it's got a bunch of dependencies, or it's just express, etc. None of that matters if you aren't exposing this to the internet. This is a really neat project that lets you play with something right away and a lot of you all are bashing the author for things not even in the scope of the project. Lastly this has so many upvotes and is #1 on the front page because it's cool, fun, and perfect for a little prototype or POC. There are a number of positive comments buried at the bottom but the highest comment is about how this is a "Security Nightmare". Edit: Typo and I wanted to add: Not everything posted on HN has to be battle-tested, scalable, parallelizable, profitable, cloud-ready, secure, etc. It's the kind of attitude in this thread that keeps people from posting their own work at all. No one want's to get torn apart, back off and provide constructive criticism or keep quiet. (Note: advice I have not always practiced in the past) Edit 2: Show HN rules (https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html), I think this makes my point better than I can. Show HN > Show HN is a way to share something that you've made on Hacker News. The current Show HNs can be found via show in the top bar, and the newest are here. To post one, simply submit a story whose title begins with "Show HN". What to Submit > Show HN is for something you've made that other people can play with. HN users can try it out, give you feedback, and ask questions in the thread. > A Show HN needn't be complicated or look slick. The community is comfortable with work that's at an early stage. > If your work isn't ready for people to try out yet, please don't do a Show HN. Once it's ready, come back and do it then. > Blog posts, sign-up pages, and fundraisers can't be tried out, so they can't be Show HNs. > New features and upgrades ("Foo 1.3.1 is out") generally aren't substantive enough to be Show HNs. A major overhaul is probably ok. In Comments > Be respectful. Anyone sharing work is making a contribution, however modest. > Ask questions out of curiosity. Don't cross-examine. > Instead of "you're doing it wrong", suggest alternatives. When someone is learning, help them learn more. > When something isn't good, you needn't pretend that it is. But don't be gratuitously negative.
- scottmf 8y ago>People in this thread are way overly negative. That's most of HN these days, and why I never visit anymore.
- scottmf 8y agoApart from the security concerns this actually looks awesome.
- laurent123456 8y agoThat's pretty cool to quickly put together a POC app. There should be an "eject" command that would export everything to a "real" Node application, with package.json and so on, so that the POC can be converted to a real app easily.
- brillout 8y agoCheck out Reframe: https://github.com/reframejs/reframe https://github.com/reframejs/reframe It's a web framework like Zero Server and Next.js but everything is ejectable.
- bschwindHN 8y agoOr alternatively, check out re-frame: https://github.com/Day8/re-frame https://github.com/Day8/re-frame It's a web framework with a well-thought-out architecture that you don't need to "eject" from.
- blunte 8y agoNot to sound adversarial, but configuring a web framework tends to be one of the last difficult or time consuming parts of building a web app or backend in my experience.
- brillout 8y agoIf you need SPA then yea it's easy. But when you need SSR it becomes a whole different story. Now imagine you want parts of your app to be SPA and some other parts of your app to be SSR. This becomes super complex. Frameworks like Reframe allow you to do that. (I'm Reframe's author (https://github.com/reframejs/reframe https://github.com/reframejs/reframe).) Admittedly, mixing SPA and SSR views in one app is uncommon today but that's because people are not aware that they can do that. This will change.
- BinaryIdiot 8y ago"Zero configuration" But, you can install express, copy paste the getting started code and be up and running at a similar level in 5 minutes. I...guess I don't understand why I should trade something super simple and easy to use for this additional level of abstraction magic. There is such a thing as too much abstraction.
- asadlionpk 8y agoTry doing the same for React (in the same express project). With SSR enabled :)
- deleted 8y ago[deleted]
- brillout 8y agoDepending on what you need, setting up a React app is super complicated and time consuming. Especially when you need SSR. There is a reason why frameworks such as Next.js, Reframe, and now this one are being used. I'd actually say the opposite, it's tools like Webpack that don't have enough abstraction. I don't care how source maps are being generated, why on earth is it a good idea for Webpack to force me to dig into that? (If at least Webpack's default source map config would work out of the box but it doesn't.) Parcel hits the right abstraction level much better. Disclaimer: I'm Reframe's author (https://github.com/reframejs/reframe https://github.com/reframejs/reframe).
- coolmitch 8y agothere's already a very popular react (cljs) framework called reframe https://github.com/Day8/re-frame https://github.com/Day8/re-frame
- franciscop 8y agoNo, you cannot, not in an easy way. I've taught many people Node.js/express and they always struggle with all of those copy/pasted configuration bits. Now if I add them, I tell them something along the lines This is just magic, copy/paste it to make your app work. Some day you will understand. Once you get used to them it's easy, but to get started it's a nightmare. I started with PHP back in the day, and even though it's hated around here the bar to getting started there is amazingly low in a good way.
- deleted 8y ago[deleted]
- deleted 8y ago[deleted]
- renton 8y agoI thought we moved away from this sort of structure as an improvement?
- openbasic 8y agoSo... 2019's PHP?
- ihassann 8y agoNice work bro. Seems pretty solid. Congrats from fellow Karachian :)
- electrotype 8y agoMake a RealWorld.io implementation or it doesn't exist! https://github.com/gothinkster/realworld https://github.com/gothinkster/realworld
- juliend2 8y agoWow, that readme file is a github repo masterpiece.
- yowlingcat 8y agoThis is wonderful. Great antidote to toy framework fatigue.
- franciscop 8y agoI did something very similar but arguably with even less configuration, https://serverjs.io/ https://serverjs.io/ const server = require('server'); server(() => "Place your Node.js API here."); However my project doesn't have the automatic routing/installing/React, which looks great! Keep it up, I like the direction where this is going.
- tazard 8y agoHey, that looks cool too. Thanks for sharing it!
- deleted 8y ago[deleted]
- jacksonastone 8y agoSuper cool. Well done.
- gyvastis 8y agoHow's this different from Koa?
- IceDane 8y agoWho is this for? Is the goal to enable people who don't know what they're doing at all to make applications? Maybe at a glance that is a laudable goal, but surely there is a point where, if you need so much handholding, you should consider either sitting down and learning what you need or making someone else is build it for you. Newbies? I guess that is possible, but I personally think that actually learning to use your tools and the libraries that are available should be the goal. Handing the control of everything to some 3rd party component is eventually going to leave the beginner with issues they have no way of solving because they've never had to learn anything.
- lujim 8y agoPrototyping, hobbyists, people who host a site about cats and don't need 1000 extra lbs of server side weight. Spinning up a simple API to learn a new client side library. Anywhere that tooling and configuration is getting in the way of someone learning something new. Seems perfect for some uses.
- jarvuschris 8y agoThere's a lot of value in removing all the plumbing you typically find at the start of node project to handle basic things like routing. I'm a big fan of moving all that "outside" the app This might seem silly if all you're use to is working on some startup's big app with a dozen other people, but for small orgs that need to run small programs for a long time it's a mess to maintain that stuff over the long term and to count on lone coders in small engagements to get right. > Handing the control of everything to some 3rd party component In the cases I describe, this ^^ is a great idea. Keeps maintenance of the common stuff in a common place. Everyone freaked out in this thread about there being a way to get at files outside the project root. Well the author fixed that in one place and now it's fixed for everyone. How many times does an error like that come up and go undetected and uncorrected when even an experienced node coder has to copy pasta so much stock plumbing for the 1000th time to spin up a small service for a small org?
- hipjiveguy 8y agoI for one think this looks great! Keep up the good work and don't get discouraged!
- arispen 8y agoI agree. Fun idea and keep up the good work!