How do Express and hapi compare to each other?

后端 未结 6 2061
耶瑟儿~
耶瑟儿~ 2020-12-12 08:51

From web application design and development point of view, how do Express and Hapi compare to each other? For basic examples they seem similar, however I\'m interested to le

6条回答
  •  不思量自难忘°
    2020-12-12 09:09

    My organization is going with Hapi. This is why we like it.

    Hapi is:

    • Backed by major corps. This means the community support will be strong, and there for you throughout future releases. It's easy to find passionate Hapi people, and there are good tutorials out there (though not as numerous and sprawling as ExpressJs tutorials). As of this post date npm and Walmart use Hapi.
    • It can facilitate the work of distributed teams working on various parts of the backend services without having to have comprehensive knowledge of the rest of the API surface (Hapi's plugins architecture is the epitome of this quality).
    • Let the framework do what a framework is supposed to: configure things. After that the framework should be invisible and allow devs to focus their real creative energy on building out business logic. After using Hapi for a year, I definitely feel Hapi accomplishes this. I... feel happy!

    If you want to hear directly from Eran Hammer (Hapi's lead)

    Over the past four years hapi grew to be the framework of choice for many projects, big or small. What makes hapi unique is its ability to scale to large deployments and large teams. As a project grows, so does its complexity – engineering complexity and process complexity. hapi’s architecture and philosophy handles the increased complexity without the need to constantly refactor the code [read more]

    Getting started with Hapi won't be as easy as ExpressJs because Hapi doesn't have the same "star power"... but once you feel comfortable you'll get A LOT of mileage. Took me about ~2 months as a new hacker who irresponsibly used ExpressJs for a few years. If you're a seasoned backend developer you'll know how to read the docs, and you probably won't even notice this.

    Areas the Hapi documentation can improve on:

    1. how to authenticate users and create sessions
    2. handling Cross-Origin-Requests (CORS)
    3. uploading files (multipart, chunked)

    I think authentication would be the most challenging part of it because you have to decide on what kinda auth strategy to use (Basic Authentication, Cookies, JWT Tokens, OAuth). Though it's technically not Hapi's problem that the sessions/authentication landscape is so fragmented... but I do wish that they provided some hand-holding for this. It would greatly increase developer happiness.

    The remaining two aren't actually that difficult, the docs could just be written slightly better.

提交回复
热议问题