Comments (10)
I'm not part of the Nest team in any way right now, but I've got some opinions I'd like to add to this discussion :)
IMO, Hapi is all about configuration over code, and they have a nice API for this. Express, while being faster, was always nastier to configure (imo, just to reiterate).
What Nest excels at is essentially allowing you to combine your config and your code seamlessly by making use of TypeScript decorators, instead of defining config JSON and wrapping in a controller reference like Hapi does, or doing it all in express code. It uses express under the hood, sure, but this is really just an implementation detail. In a perfect world, you'd never write any pure Express code yourself, or any Hapi / Koa code, if they were supported underlying frameworks.
Using Hapi, etc for the underlying engine would also probably be less optimal, primarily because it's slower than Express, and also it'd probably be a much harder task to generate the Hapi config than it is to hook into express and create routes and so on (ironically, in this case, express's much cited weakness becomes it's strength). I'm just guessing on this last point, as I didn't write any of this code.
Given the above, I'm curious, what would the motivation be for supporting multiple frameworks beyond Express?
from nest.
@kamilmysliwiec I'd like to fork and branch and look into seeing if it's possible to loosen the coupling between Nest and Express, and see what the cost of supporting Koa and Hapi would be.
Ideally, there should be a way for teams to smoothly transition from an app built on Koa/Hapi/ to a DI-enabled NestJS framework, slowly chipping away at the old architecture.
from nest.
Hi @thomrick,
I totally agree with @zachgrayio. The support for the other popular libraries is not needed. Nest is here to provide an architecture, especially to build scalable and loosely coupled systems. What is under the hood is just an implementation detail. I chose express, because - it is fast, popular and there is a lot of ready to use 3rd-party libraries.
from nest.
@wbhob, I do think it's a very important for wider adoption (it could facilitate migration and protect from vendor lock-in), but I understand it may not be cost/time-effective. @jhanschoo I appreciate any effort,
Thank you
from nest.
@kamilmysliwiec
"Nest is here to provide an architecture, especially to build scalable and loosely coupled systems"
It is coupled with express though.
Those of us who have a set of complext hapi/koa middlewares cannot just use your "provided architecture". (which looks great btw).
from nest.
@thomrick from the source code i see that express is tightly coupled with the implementation no abstraction done, would required massive modification to support hapi/koa (next version maybe?)
@zachgrayio agree with @thomrick supporting other framework would increase reusability of already created middlewares etc.
from nest.
Hey guys,
Totally agree with you. It was just a suggestion.
from nest.
Again, @amitport though it is coupled with express, it doesn't matter. When you elect to use Nest, you must elect to use express, because it's the foundation of the house that Nest is built on; it handles HTTP, while Nest handles syntax sugar and developer experience.
I realize that it is probably a pain to transition all your routes, but if you want to use Nest, it's one of the steps to getting there.
In terms of loose coupling in the snippet you provided, the loose coupling is between the frontend and backend, and between individual controllers, not between Nest and the underlying framework.
@jhanschoo I imagine it would be fairly difficult to decouple Express and Nest, and to integrate Hapi or Koa, because all of those APIs are completely different, and maintaining three different forks of code that essentially do almost the same thing is needlessly laborious.
from nest.
FeathersJS is trying something similar. (feathersjs/feathers#258)
I'll do some research and give it a try; I'd like to see if it can't be refactored into an API+officially supported Express plugin. The other interfaces can be community-maintained.
from nest.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from nest.
Related Issues (20)
- Cannot read properties of undefined (reading 'constructor') HOT 3
- Nest can't resolve dependencies of the DiscoveryService (?). Please make sure that the argument ModulesContainer at index [0] HOT 11
- I have a question about dependency injection and module import HOT 1
- Supply time to TypeOrmLogger.logQuery() HOT 1
- TCP.onStreamRead (node:internal/stream_base_commons:217:20) HOT 1
- RabbitMQ Bug Microservices HOT 1
- nx 18 + nest + webpack + serverless breaking with error src/main.handler is undefined or not exported HOT 1
- NestJS doesn't handle "Operation failed: QueueDeclare" error from amqplib HOT 1
- Problems Encountered with NestJS and pnpm in a Monorepo Setup HOT 1
- grpc microservice stops listening to requests after version 10.3.3 (needs peer dependency) HOT 1
- perf: caching return value for some functions HOT 1
- The request body does not return an object whose value is an array of objects
- Jest spy doesn't work on Microservices Controller (EventPattern) E2E Tests
- Feature Request: Support for Bun.js HOT 1
- Multi-tenant app fail on first non durable tree request HOT 2
- Kafka Microservice Error When Consumer Has Not Joined the Consumer Group
- LoggerService transforms the instance of Error when controller throws an Error HOT 3
- Easy way to compose ORed validators HOT 1
- Not sure if it is bug or feature request, nest middleware in jest runs before any other express middleware HOT 2
- Devtools with microservices: Error: listen EADDRINUSE: address already in use :::8000 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nest.