Why TypeScript?27 May 2019
Node JS is great for api development, we have used it for ages. We also have great web frameworks like express and koa, nice orms like sequelize, bookshelf, objection and mongoos, and we have a lot of other libraries and plugins that we love to use. Although, sometimes, it feels like it’s not enough. We want something better, something cleaner, something more stylish, state of the art technology.
Can we have it? Yes, we can!
What does TypeScript have to offer?
Another tool is reflection-mapping, another reason why you should switch to TypeScript. It’s like php annotations, but better…not in comments. You can annotate anything, make your own annotations, use them however you want, or just use the ones others have already implemented.
Those are just the tools we have, but that's nothing if we have to implement everything on our own. So here comes our new sets of libraries, written specifically for TypeScript:
- typestack/routing-controller s- so now you can create your controller classes, and annotate routing in annotations! Behind the new mask it still uses good old expressjs or koa (your choice)
- typeORM - typeScript ORM maps your database into classes, and supports all the databases you want to use; sql or no-sql, it’s your choice!
- typestack/class-transformer - so you can transform your class models into, or out of, plain JSON.
- typestack/class-validator - after you transform your request into classes, you have to validate it. Why don’t you setup validators as an annotation next to the class properties?
- typestack/typedi - and now let’s connect it all together with this lovely dependency injection library, so you don’t have to worry about where your classes are anymore.
If you bring all these pieces together, I promise you that your new project will be a piece of art!
See slides on this topic below:
Do you like this article?