• image
  • image
  • image
logo logo
  • Home
  • View Jobs
  • Services
  • About Us
  • Blog
  • Contact Us
img img

Booting up with a Sample

March 22, 2019

Cats-app using NestJS

Best way to evaluate a framework is to get rolling with a tutorial and follow each step to the word of it. NestJS is no different in this perspective i.e. of getting started. However, we ventured in charting a different trajectory to get started. This is the log of our experience as we ventured in this trajectory.

The approach

Author of the framework KamilMyśliwiec (@kamilmysliwiec[1]) has committed sample application[2] “cats-app” in GitHub to the demonstrate the prowess of the framework. What else could be a good starting point other than the author of the framework itself demonstrating the prowess of his own creation.

Though, we observed Kamil’s sample to be more technical than any other such sample say e.g. AngularJS’s sample application PhoneCat[3].

Our Oblog – First dispatch

We cooked this “Oblog” term for this post which expands to Observation Log. To begin we start by installing the CLI for NestJS.

 

npmi -g @nestjs/cli

 

 

This command fetched 208 packages with skipping optional dependencyfsevents(in a Windows 10 Home edition).

CLI gets us the freedom to run commands which otherwise would need a prefix’ish style before the actual commandnodee.g.

[1]https://github.com/kamilmysliwiec

[2]https://github.com/nestjs/nest/tree/master/sample/01-cats-app

[3]https://docs.angularjs.org/tutorial

 

 

node “[path to npm global directory]\node_modules\@nestjs\cli\bin\nest.js” new project

 

 

CLI shortens the command further to

 

nestnew project

 

Without digressing deep into the CLI and its necessity (as a developer tool) or the lack of necessity (dissoluteness into brevity) let us get the code sample from GitHub. We will need git command which can be downloaded from the Git’s own website. Once installed you will be able to run the following command –

 

git clone https://github.com/nestjs/nest.git “.”

 

Above code clones the repository to the directory from which you have executed the above command. You can very well replace the “.” in the above command with full path to any other directory to which you wish to download the code.

samplefolder of the repo contains the sub-folder01-cats-appwhich is also the app used to narrate the features of NestJS in the documentation.

Tools of trade For a Node.js application best place to inspect an unknown code is begin with package.json file. It gives a good perspective into the application and its complexity. More the dependencies, more the complexity and vice versa etc.

 

Package.json file other than the standard tags contains NPM scripts[1] section where we can notice author have defined two different ways in which the app will behave. In developer machine it will run directly from TypeScript codebase using the TypeScript REPL package for Node.js. However, if run in production mode i.e.npm start –prodthe sample will be transpiled to pure JavaScript which is then run using Node.js runtime. We are referring to the following lines of code from the sample –

 

“scripts”: {

 

“start”: “ts-node src/main.ts”,

 

“prestart:prod”: “tsc”,

 

“start:prod”: “node dist/main.js”,

 

…

 

},

 

The above best demonstrates the claim made by the author when the framework is attributed as – “Uses progressive JavaScript”.

[1]https://medium.freecodecamp.org/introduction-to-npm-scripts-1dbb2ae01633

 

In the same file when we inspect the dependencies (particularly overlooking at the version number); we will find all packages in the Nest.js repository are all referred inferring the possibility of using them all which will give us the reference point to use them appropriately in some another functional context.

Also, typically all of them (though not necessarily) but evolve at same pace i.e. version number. We are referring to the following statements in the file –

 

“dependencies”: {

 

“@nestjs/common”: “^5.3.0”,

 

“@nestjs/core”: “^5.3.0”,

 

“@nestjs/microservices”: “^5.3.0”,

 

“@nestjs/testing”: “^5.3.0”,

 

“@nestjs/websockets”: “^5.3.0”,

 

“class-transformer”: “^0.1.7”,

 

“class-validator”: “^0.8.1”,

 

“reflect-metadata”: “^0.1.12”,

 

“rxjs”: “^6.0.0”,

 

“typescript”: “^2.8.0”

 

},

 

 

The devDependencies section gives us the insight on tooling required for the developer to build upon the sample.

We just warmed up ourselves with the ecosystem of the sample codebase. Our next dispatch of Oblog will explore codebase’s other aspects in the context of framework.

 

The Editorial Board

Teamware Solutions

Post navigation

Previous Article
Next Article

Recent post

  • The Swiss Army Knife for developer
  • Time Management Techniques
  • Habits of Successful Leaders
  • Error in probabilities
  • Another gem from the past

Archives

  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • October 2023
  • June 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • January 2021
  • December 2020
  • October 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • Home
  • View Jobs
  • Services
  • About Us
  • Contact Us
img img