10 ms·
AdonisJS
- Ciantic 2y agoLooking at this, it has similar aspects as ASP.NET Core, and the same flaws as the Controller per class design used. Methods such as "index", "show" and "store" do not share a state, they shouldn't share a class either. However, you can rectify this, by just not trying to share a class with any of those. In .NET Steve Smith, aka Ardalis shows how to do this with his Clean architecture [1]. One idea is to make a class for each endpoint. This also makes it easier for "Update" classes to share functionality with other "Update" classes and so on. [1]: https://github.com/ardalis/CleanArchitecture/tree/main/sample/src/NimblePros.SampleToDo.Web/Projects https://github.com/ardalis/CleanArchitecture/tree/main/sampl...
- treve 2y agoGrouping related functionality in a class and using it as a namespace, and using inheritance to get a few useful common features in close proximity and handing hooks is perhaps not the most correct from an OOP perspective, but it's common and results in much less boilerplate than doing everything 'correctly'. What's more egregious to me is that the methods should just match HTTP method names and have 1 controller per route.
- mewpmewp2 2y agoWhat about just having request handling functions in a single file or a directory?
- crowcroft 2y agoBoth approaches are fine, and doable. As a convention I don't think one method per verb in a controller is inherently bad just because they don't share state. Plenty of long running, maintainable projects follow this practice.
- OptionOfT 2y agoThe idea was that a controller is instantiated per request, so constructor and then your method, index / post / list / ... You could use your constructor as a shared place to set up the requirements for your method.
- jitl 2y agoHas anyone tried both AdonisJS and RedwoodJS and can compare the two? Adonis and Redwood are both trying to be the JavaScript version of Rails/Laravel - a traditional active-record based MVC rapid development server application framework. The last time I looked for one of these (2018) they were immature and now at least in terms of website and documentation they both appear very capable. But if there’s one thing that JS libraries are good at, it’s marketing and slick documentation. So, curious to hear any experiences with either and especially both. Is it actually good?
- itslennysfault 2y agoI haven't used either so I can't chime in on that front, but long ago I was pretty into Sails which is written by a team that loves rails, but switched to NodeJS so it's basically Node on Rails. I actually thought they discontinued it, but I just searched and it still exists. It was a solid framework like 5 years ago when I used it last so I assume it's quite mature now. https://sailsjs.com/ https://sailsjs.com/
- kevinob11 2y ago5 - 6 years ago I used sails and regretted it because of the assumptions made in waterline about databases. At the time there was no transaction support and joins were a mess. This was pre-1.0, so perhaps it has changed. These days I use DRF because I like getting the built in Django admin for free. I know it is a bit dated in some ways, but I love the way Django structures things, works for my mental model.
- sureglymop 2y agoI think something that is somewhat similar but even more fleshed out than Sails is NestJS. Personally though, I'm just done with server side JS and the dependency hell coming with it.
- itslennysfault 2y agoNestJS is my go to and the reason why I haven't touched Sails in years, but it is more "Angular for the backend" than "Rails for JavaScript" imo. but I probably should've mentioned it anyway since it has been my node backend framework of choice for quite a while. I'm kinda with you on that though. I'm actually currently prototyping new services in DotNet Core and am really enjoying it so far.
- Brosper 2y agoI am just exploring this kind of frameworks for my company. I wonder how many people use it on productions and are happy with it.
- rpowers 2y agoAnyone else see these types of announcement posts, and it's like they already have thousands of users? Where do y'all learn about these projects so early?
- yasoob 2y agoSo a few reasons come to mind. Firstly, these projects usually do more than one HN posts. And by the time they have thousands of users, they have already done quite a few HN posts by then. Additionally, if you follow a particular scene (JS in this case) then you can hear about these projects quite a lot on tech Twitter. Adonis was being actively discussed a few days ago after Theo posted a video about why there is no Rails alternative in JS-land. I personally remember hearing about Adonis when I searched for a Rails alternative in JS a long time ago. And lastly, this project specifically has been in the making for a good number of years now. So it makes sense that there are quite a few people out there using it.
- bluetidepro 2y agoTo what "yasoob" said, you probably just missed it in past HN posts: https://hn.algolia.com/?q=adonisjs https://hn.algolia.com/?q=adonisjs - It's been talked about for 4+ years now.
- NayamAmarshe 2y agoThis is getting popular due to the recent 'Laravel vs JS Frameworks' controversy. https://www.youtube.com/watch?v=yaodD79Q4iE https://www.youtube.com/watch?v=yaodD79Q4iE
- amanvirk 2y agoHell yes. Maintaining this framework for 10years and only recently we have started getting attention because of all this Laravel vs JS drama!
- Kerrick 2y agoRight here on Hacker News, actually. https://news.ycombinator.com/item?id=16509058 https://news.ycombinator.com/item?id=16509058
- m1nes 2y ago[flagged]
- deleted 2y ago[deleted]
- amanvirk 2y agoWe came 10yrs ago
- revskill 2y agoLack of vite/webpack/... FE integration is a huge breaker.
- rykuno 2y agoHow? It claims to support InertiaJS.
- revskill 2y agoBe real, you want to build a SPA, how ?
- 0xblinq 2y agoWe can’t read the docs for you.
- tresormuco 2y agohttps://docs.adonisjs.com/guides/views-and-templates/inertia https://docs.adonisjs.com/guides/views-and-templates/inertia
- amanvirk 2y agohttps://docs.adonisjs.com/guides/basics/vite https://docs.adonisjs.com/guides/basics/vite
- aobdev 2y agoThere are plenty of mature front end SPA frameworks that would work perfectly fine with Adonis. If you want to build traditional server side templated pages they provide a templating engine called Edge, and the docs tell you how to use Vite to bundle assets. If you want to make pages feel like an SPA without using a framework, they suggest Inertia as another comment points out. What do you feel is missing?
- 0xblinq 2y agoDid you even check the docs? Or just reading the title was enough to drop your opinion?
- nikodunk 2y agoNo mention of Views? The one thing I'd love to understand and is missing vs. Rails/Laraval is an integrated solution of solving the View part of MVC I think? Looks like a really beautiful framework. EDIT: Nevermind, it's in the docs, just not on the main landing page so feels a little more secondary. TLDR they recommend you use Edge/Pug/Nunjucks, htmx, vite for css bundling. Nice! https://docs.adonisjs.com/guides/views-and-templates/introduction https://docs.adonisjs.com/guides/views-and-templates/introdu...
- ortsa 2y agoAn official mention of Pug? Now, they got me listening. Maybe it's because it's (mostly) markup, but Pug is the only whitespace language that I really gel with. I wish it had more support across the board! Maybe it's the years of Emmet use that's got me biased. I remember getting excited about both of these before they each changed names.
- efilife 2y agoI never saw the appeal of Pug, it's hideous and completely unreadable for me. I can't easily tell where code starts and ends
- ortsa 2y agoI absolutely understand. For me it's the _only_ exception to this feeling. Probably something to do with it not being a programming language, and my own preference for as little nested elements as possible, though I can imagine how anything close to div soup would be completely untenable.
- mewpmewp2 2y agoI heavily dislike Pug, just because it depends on indentation. Maybe I'm just my IDE somehow wrong, but trying to rearrange things seems always so much more complicated and trying to learn this clever syntax instead of doing normal html.
- morbicer 2y agoNah, if you want heavy backend, go with Go/Ktor/C#, not node. If you want light backend, use sth like Hono or H3. If you want to primarily produce html, use Remix or Next. Adonis/Redwood/Nest is something you will regret in few years because it will lock you down to "their" ways of doing things instead of something with replaceable components. Admitted, Adonis looks most sensible out of these 3. Redwood is poisoned with needless GraphQL and Nest is written like 2008 java. In Adonis you can at least pick the db layer. But even Adonis locks you to their validator instead of Zod or his cousins, they use their own Request/Response classes instead of the platform ones, has yucky inheritance and annotations magic etc.
- songbird23 2y agothis is the way
- charlie0 2y agoLocking things in is not an issue if things are well built and well maintained. Having used Laravel, I'm amazed at their DX. First party libs all built by the same team, tools also built by the same team. Everything is congruent and just flows. Compare that to the wild west that is Javascript land. Multiple libraries that all do the same thing in different ways. Stuff being deprecated or completely changed. Sure, if you want "choice", there's plenty of stuff out there for that. You can cobble together your own framework or pick a light framework pick and then add your "batteries" to it. I hope AdonisJS only has 1 way of doing things and that those ways are good, then it will truly go a long way.
- morbicer 2y agoPHP world is different. There's only Laravel and Symfony. You can't count on both surviving till atomic winter. As you say, js world is fickle and I wouldn't count on Adonis being here for a long time. Mix and match is more pragmatic in this setting.
- tommica 2y ago> You can't count on both surviving till atomic winter. Nor can you count on your JS library to survive until next winter.
- holoduke 2y agoI never understood why you need more than a simple expressjs server. After all nodejs works best if served directly after a load balancer. But before heavy duty application logic. Node is fast in accepting, forwarding and replying requests. Put your real work in small c# or golang apps.
- jatkindev 2y agoCurious, why do you say Node.js works best served directly after a load balancer? Genuinely just wondering, never heard this before.
- antifa 2y agoAlmost all high level backends (node, php, python, ruby, etc.) work best behind a load balancer.
- antifa 2y agoWhat I look for in an expressjs alternative is 1.) First class typescript support 2.) Better tree shaking.
- begueradj 2y agoI used it for 3 years where everything which was too important (a took a long time to be done by the only maintainer (Harminder Virk) at that time with his only one "helper" (Romain Lanz) , so long that I had to stop using it because it was difficult to use in those conditions.
- amanvirk 2y agoHeck. 3yrs is quite long. Ill drop anything that doesn't allow me to ship daily
- begueradj 2y agoYou must be its creator (Harminder Virk) because this is the type of responses (much worse ones, to be accurate) you were used to provide for anyone who asks you about something.
- amanvirk 2y agoThat was sarcasm on your original comment that you have edited 3 times. Anyways, don't take it seriously and have fun
- begueradj 2y agoIf you check my Github profile, you will see I still have on my list of starred repositories several of yours. I also still have at least 2 articles on my blog related to AdonisJs. I hope you understand what I mean.
- madmaniak 2y agoHehey! I'm late for the party :D I just wanted people interested in frameworks to take a look on comparison with (my) framework which purposefully takes another approach https://news.ycombinator.com/item?id=40743058 https://news.ycombinator.com/item?id=40743058