It is true that I have search a lot for a proper production ready NodeJS with TypeScript code, but believe me I have struggled a lot and started building it by myself. Though, few of the github code I have downloaded and checkout how it works. I found one clean and fresh code (I forgot the link)and on top of it, I have added my idea to create a simple, production ready and extendable NodeJS with TypeScript code with Swagger enabled.
|TypesScript is known as Object oriented programming language.
|TypeScript has a feature known as Static typing.
|TypeScript gives support for modules.
|TypeScript has Interface.
|TypeScript support optional parameter function.
Let's start building the application -
Dependencies On NodeJS typeScript
swagger-ui-express, @types/swagger-ui-express - swagger UI for endpoint
The sample I am going to create here, will follow the above diagram. If you need more abstraction layer, you can improvise the architecture as well. But, for the time being, I am making it simple. Here, you will see, there are decoupled handlers which are build to serve its purpose independently and individually.
To deploy the typescript anabled nodejs code to heroku, you need to follow few steps.
You can find the complete code from here. Please share your suggestions to improve the article.
- Lazy Panda Tech