Live data from Hacker News

Show HN: Server.js – A modern Express alternative

serverjs.io

31–40 of 124 posts

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

#31
post #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.

No problem, didn't sound negative. The main difference with Koa would be having a starting point with default middleware, security and websockets. I do agree with your points, Koa is probably the most elegant library out there, probably followed closely only by express.

But that is not why I created server. It is not about library elegance and simplicity, it's all about making it easy to use. Both of Express and Koa involve external middleware that the user has to manage manually, and there is a subset that is really common for most situations. Server.js is all about usage simplicity, including this subset by default and making things work by default.

Context was inspired initially by the way Promises work with a single return value, but then expanded further (and named after) Koa's context.

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

#32
Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification.

I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity.

There are a bunch dependencies I am now kind of decided on (not for technical reasons, but because they are clear popularity contest winners) and figured out how use:

    body-parser
    compression
    serve-favicon
    express-session
    csurf
    helmet
    cors
    dotenv
    moment
    selfsigned
    chalk
    debug
But still a bunch that I haven't gotten to googling and still need to decide on what to choose:

    logging (morgan vs winston)
    validation (express-validator, joi)
    auth (passport jwt, local, social)
    session storage (redis vs keeping it in database?)
    database (mongo/mongoose vs pg/knex/bookshelf/sequelize, graphql)
    storage (s3 vs gcs)
    ajax requests (request vs axios)
    mail (mailgun, sendgrid, mailchimp)
    error handlers
    rate limiting
    geo ip
I would be so happy if someone took away my power to choose and just forced me to use something that will "just work".

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

#33
post #32

Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification. I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity. There are a bunch depend…

Couldn't agree with you more. Have been involved in a few projects this year where a bunch of freelancers who had never worked together were thrown together to get something up and running quickly. The results were slightly horrifying precisely because everyone had their own tooling and way of doing things. Opinionated boilerplate would have solved so many problems for us upfront.

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

#34

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.

1. Node focuses on modularity. You pick your express clone, you pick your ORM, you pick your front end, you pick your logger, you pick your passportjs plugins. Because so many great things are just unopinionated modules, there's less need to make packages like express-mongoose, koa-mongoose, express-postgres, koa-postgre, express-pug, koa-pug, etc. (although I bet those exist anyways, they are simply gratuitous). If you want redis, you just pick your redis module from npm.

2. You could say npm is the framework.

3. You could say Adonisjs did kick off (pretty good if you wanted a laravel clone)

4. Mainstream webdev in Node is younger, so a clear rails clone is not evident but could already exist under your nose.

5. Maybe front end frameworks are the new "MVC frameworks". You can make both SPAs, MPAs, and hybrid SPA/MPAs with nuxtjs and nextjs. Do you need a full backend MVC framework to do what your frontend framework already does, but better?

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

#35
post #32

Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification. I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity. There are a bunch depend…

maybe time to make a "node on rails"!

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

#36
post #32

Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification. I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity. There are a bunch depend…

Totally a tangent but, don’t use moment.js! It inherits some of the parsing and other quirks from the awfulness that is the JS Date object, the mutability almost certainly will lead to being bit by a couple of bugs before you actually internalize it, and the time zone support is kind of tacked on as an afterthought.

I highly recommend js-joda, particularly if you’ll ever be computing/showing things to your users in different time zones. It actually treats dates and times rigorously, and has an api that makes it clear what kinds of operations make sense to do on a zoned vs local datetime and makes things like converting between timezones vs transposing them explicit and simple.

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

#38
post #32

Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification. I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity. There are a bunch depend…

Totally agree with you. I miss the opinionated nature of Rails when I work in the JS world.

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

#39
post #36
post #32

Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification. I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity. There are a bunch depend…

Totally a tangent but, don’t use moment.js! It inherits some of the parsing and other quirks from the awfulness that is the JS Date object, the mutability almost certainly will lead to being bit by a couple of bugs before you actually internalize it, and the time zone support is kind of tacked on as an afterthought. I highly recommend js-joda, particularly if you’ll ever be computing/showing things to your users in d…

I haven't tried it, but https://date-fns.org/ looks nice. For example, immutable API and just uses native Date objects.

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

#40
post #32

Rather than changing express's syntax, I would much rather have a better express boilerplate generator with an opinionated stack with good documentation/justification. I recently started learning express/node and wasted weeks googling for blog posts for each dependency to figure out how to configure them. I guess this is somewhat valuable for end-to-end understanding but not for productivity. There are a bunch depend…

If you already have a database, I recommend storing the session in the database. I personally use connect-pg-simple when using Postgres. In other words, I wouldn't add another major dependency like Redis just for session storage.
Post reply on HN