Live data from Hacker News

Show HN: Server.js – A modern Express alternative

serverjs.io

21–30 of 124 posts

Re: Show HN: Server.js – A modern Express alternative

#21
post #6
post #4

Earlier quoted context omitted.

Basically what I find Koa does for me: http://koajs.com

I am in the Koa boat as well, does Express have anything that Koa does not? (not trying to start a framework flamewar, honestly!)

IMHO, and one of the reasons I decided to go with server, simplicity is a feature and the advantage of express over Koa. It is hard enough for new users to get started on Node.js, but to have to handle all of the new middleware concepts, PLUS to have to learn a lot more advanced features like generators is a no-go for my framework of choice.

- server: return something to reply to the browser. Can use `async` for more advanced features.

- express: reply.send() is fairly straightforward. next() for middleware is a new concept but conceptually in the right place (when you are digging a bit deeper in the middleware).

- Koa: yield, function with asterisk, etc.

So I think Koa is fine for devs who have been a while in JS dev, but the learning curve is too steep to get started. Same as what happens with React and the reason create-react-app has become so popular.

Re: Show HN: Server.js – A modern Express alternative

#23
post #6

Earlier quoted context omitted.

I am in the Koa boat as well, does Express have anything that Koa does not? (not trying to start a framework flamewar, honestly!)

IMHO, and one of the reasons I decided to go with server, simplicity is a feature and the advantage of express over Koa. It is hard enough for new users to get started on Node.js, but to have to handle all of the new middleware concepts, PLUS to have to learn a lot more advanced features like generators is a no-go for my framework of choice. - server: return something to reply to the browser. Can use `async` for more…

Koa has been doing async for a while. It's basically connect with promises instead of callbacks: `app.use(async (ctx, next) => { await next(); });`

Re: Show HN: Server.js – A modern Express alternative

#24

I'd argue koajs was the first modern express alternative, although it's arguably more of a connect alternative. I've been happily using it since generators were available under a flag with node 0.11 and it has always been a joy. There's a huge list of middleware [0] on their wiki, and you just pull in whatever you need. It means that your initial setup takes a bit longer, but it forces you to understand all the movin…

I didn't know about that middleware list, thanks for sharing.

About session rotation, it was my impression that it is a smaller problem compared to how it can be exploited if we're using cookies [1][2], could you share some more info about it please?

About Redis, I totally agree. You can add any store that you want with the plain `{ session: { store: ... } }` option. There is an issue though for some of them that need the original `session` passed in which I'll have to fix. So the main fix would really to improve the documentation to explain how to use the appropriate store.

Finally about socket.io, I also agree. I am not a large-scale system expert, so this is part of my limitations and that's why I recommend server.js for small-to-medium sized projects. Long-term I am working on improving on my knowledge here, but not the highest priority right now (compared to security for instance). Also, socket.io right now is not stable officially, so use with care. I'd love any help in here if you want to share some of your expertise.

[1] https://stackoverflow.com/questions/2846401/does-session-id-...

[2] https://www.owasp.org/index.php/Session_fixation

Re: Show HN: Server.js – A modern Express alternative

#26
Coming from Python, my understanding is that Express is sort of like flask (add your own everything), and something like sails.js is like Django (bundled, convention over configuration). I am wondering, why, unlike, Python and Rails, Django-type frameworks did not take off in Node.js? I would like to have a popular “Django.js”, so I am rooting for this project.

Re: Show HN: Server.js – A modern Express alternative

#27

As a side thing... is anyone getting a little wee tired of reading the following magical statement about every framework that comes out? :) > [insert the latest framework here] that just works so you can focus on your awesome project

Ah I didn't even think about it being a thing, thanks for the feedback. I did make server so I wouldn't have to worry about so many middleware pieces any longer and could work on my actual projects, but I see how this is fairly common wording.

Re: Show HN: Server.js – A modern Express alternative

#28

Coming from Python, my understanding is that Express is sort of like flask (add your own everything), and something like sails.js is like Django (bundled, convention over configuration). I am wondering, why, unlike, Python and Rails, Django-type frameworks did not take off in Node.js? I would like to have a popular “Django.js”, so I am rooting for this project.

My opinion is that Node.js follows a lot more the philosophy of small reusable modules, which is a lot more flexible with the disadvantage of a lot more initial work. I still don't think server.js is Django.js-like, since it leaves most decisions up to the developers. The main difference is that Django, Rails, Sails, etc are opinionated about both the libraries AND the code structure, while I tried to keep server opinionated only about some basic functionality, but leaving the more advanced and code structure totally up to the devs using it.

But I do try to do batteries-included, because express-like workflow involves following a bunch of steps that are basically the same for most projects.

Edit, maybe you are interested on Sails: https://sailsjs.com/

Re: Show HN: Server.js – A modern Express alternative

#29
post #13

It is built on top of express to keep all of the good things, but it adds basic middleware and some more advanced functionality like websockets through socket.io and security through helmet by default. It is designed to work perfectly with Promises and async/await, the new ES7 features that makes asynchronous code awesome. Also, I put a lot of work into making the documentation extensive and clear and I'll keep worki…

I like the design of the API, but I don't understand what you mean by "built on top of express?" I see you have express in a plugin module, but I'm not sure how it's being used.

In the package.json you can see its a dependency of the project. So it seems like its more of an abstraction of Express than an alternative.

Re: Show HN: Server.js – A modern Express alternative

#30
This might be somewhat negative, but I don't quite see what problem the library is solving.

It looks like as if Express wanted to become more like Koa (obvious from the context object). Frankly, it has missed out - koa's simplicity and elegance is unmatched. The routing and middleware syntax is particularly clunky.

Documentation seems really nice though.

Post reply on HN