Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What frameworks are recommended nowadays for Typescript? Is Express still dominant here or are there TS-first options?


nest.js is fantastic. https://nestjs.com/


Agreed - trying out nest.js the first time gave me hope that we'd see something like Django for typescript/javascript. Especially paired with nx workspaces, with shared code between front & backend... so nice.


How's their authentication solution? Auth is such a critical component of most web apps, yet something that IMO a lot of web frameworks don't fully flesh out compared to how easy it is with Django.

I took a quick look at their auth docs, and while the docs seem pretty detailed, I noticed it involves multiple packages (@nestjs/passport, passport, passport-local, and their corresponding types) that you then have to glue together into a full solution. The instructions also apparently only show you how to store passwords in plain text, and using something like bcrypt to do it yourself is an exercise left to the reader. Not rocket science, as this [1] (older) article pointed out, it's hard finding quality auth-related tutorials in the Node ecosystem. With Django a lot of this stuff is built-in and solidly implemented. Granted, this was after a quick look at the docs, so my impression might be off.

[0] https://docs.nestjs.com/security/authentication

[1] https://hackernoon.com/your-node-js-authentication-tutorial-...


Passportjs is the standard across all these frameworks. It's modular by design, so you can easily compose the right auth system for your needs. I've always found it quite intuitive and I've never seen anything even nearly as comprehensive in any language.

http://www.passportjs.org/


What do you find you get from auth libraries? I've always found them much more trouble than they're worth. But I feel like I must be missing something.


I've been using https://tsed.io/ with great success.


I've been out of the JS/TS world for a couple years. Are decorators everywhere now? I will be very sad if so.


TSed has a great dependency injection system, and uses decorators for a few things, I did not find its use excessive.


My experience is only n=3 but I've only rarely seen them where I've worked over the past 5 years. The only sane use case I've seen was for tagging logs and metrics.


My codes are written on JS but the sensitive parts are heavily commented with TS types so my vscode intellisense could assist me with correct types.

/* * @type {Map<String, Number>} */

const map = new Map();

Like that.

Express JS is still shit, koajs and fastify are a little better, I used to use nodejs's internal http and https libraries directly but these days uwebsockets.js is what you'd want since it's mature enough already (used by top crypto exchanges).

https://github.com/uNetworking/uWebSockets.js/

And oh it comes with TS types which are cool.


I second the NestJS recommendation, but I’ve also got quite far using pretty stock standard Express style middleware with Deno. It’s been a fun experience.


Two I've been lightly following are Redwood[0] and Blitz[1]. Still a long ways behind something like Rails, but promising nonetheless.

[0] https://github.com/blitz-js/blitz [1] https://github.com/redwoodjs/redwood


If you want static types you can still use typescript in JavaScript as doc comments. If you really want the syntax as well you can always compile your code down to javascript before. So express works just as well with typescript as it does with JavaScript


Every single typescript oriented library that I've tried has had a pretty atrocious dev experience and no end of compatibility issues.

I love typescript, but the ecosystem is without a doubt one of the biggest detractors.


I have written at least 10 apps in TS with dozens of libraries, including some server-only stuff.

All the problems I've had were with JS and npm. TS has been amazing and worked flawlessly. I just can't understand your experience at all.


That's alright. We're obviously not working on the same projects, and are likely taking different approaches to reach our goals.


NestJS is quite a bit better in that regard, but in general I agree with your overall point. What do you feel most of these frameworks are missing re. dev experience?


Mostly use other languages for back-end systems, but I will definitely be checking out NestJS soon.

With regards to TS, generally, it takes a lot of effort to get it to work. More often than not, getting to that point in a way that is actually useful/practical and cost effective, requires yet another library to be installed.

Just look at the TSLint/ESLint migration problems, the popularity of all those TS runners such as ts-node/ts-node-dev/tsx-watch/ts-babel/etc., the complete lack of interoperability between all those separate pieces.

Many issues and even proposed fixes to parts of the TS ecosystem - which is all community ran - are either ignored, left open because no one seems to be able to figure it out, or deemed to be out of scope.

I don't know how to fix this honestly. Some leadership from Microsoft would be a good start.


You don't need any of those. TSLint was deprecated long ago, and TS runners are only mildly useful in development (to the point where I don't bother and just `tsc && node dist`). Are you sure it's a problem with the ecosystem?


Yeah that’s fair: I’m a bit of an early adopter of Deno [0] for that reason, it helps standardise quite a bit of that. Promising, anyway, if a bit rough currently.

[0] https://deno.land




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: