Aliaksei Kuncevič

Angular Expert @ angularconsulting.com.au



v 1.0 (13/02/2019)

v 1.1 (07/03/2019)

Typescript
all the way from front to back

by Aliaksei Kuncevič

v 1.0 (13/02/2019)

v 1.1 (07/03/2019)

Who is already using Typescript?

Who is not using Typescript?

Does anyone remember year 2016?

The year
Typescript became
to get heavily adopted by frontend developers

Today we can do typescript with any frontend framework

React, Angular, Vue, Ember, etc

Approaching typescript
for back-end development with nodejs

Anyone tried that?

I did, early 2016

Tooling and types

Dependency injection

inversify.io

Recent days

A progressive Node.js framework for building efficient and scalable server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) heavily inspired by Angular

== 2+

!=

== 1.x

Features

  • Modules/Controllers/Providers
  • Middlewares/Interceptors
  • Pipes
  • Guards
  • Custom decorators
  • Dependency Injection
  • Testable
  • OOP/FP/FRP

Benefits

  • Build awesome maintainable apps
  • Helps you to stay DRY and SOLID
  • Share Typescript code between Angular and Nestjs
  • Expressjs under the hood
  • Compatibility with many other Nodejs libraries

Init new project

npm i -g @nestjs/cli
nest new project-name

NPM Run

 build
    tsc -p tsconfig.build.json
  format
    prettier --write "src/**/*.ts"
  start:dev
    nodemon
  start:debug
    nodemon --config nodemon-debug.json
  prestart:prod
    rimraf dist && tsc
  start:prod
    node dist/main.js
  lint
    tslint -p tsconfig.json -c tslint.json
  test:watch
    jest --watch
  test:cov
    jest --coverage
  test:debug
    node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand
  test:e2e
    jest --config ./test/jest-e2e.json

Code sharing

 "compilerOptions": {
    "paths": {
       "@serverTypes/*": ["../server/src/types/*"],
       "@serverHelpers/*": ["../server/src/core/helpers/*"]
    }
  },

Using NestJS with Nx

ng g node-app nestjs-app --framework nestjs
ng serve nestjs-app
ng build nestjs-app
ng test nestjs-app
ng lint nestjs-app
blog.nrwl.io/robust-backends-with-nx-7-3-and-nestjs-8fe1611375e6

Multiple Apps

tsmean

tsmean.com

Fullstack typescript

  1. monorepo
  2. tsmean
  3. NX

Can I use nestjs with react, vue, etc?

The perfect combo

Start with nestjs

github.com/nestjs/nest github.com/juliandavidmr/awesome-nestjs

Top Front-end Frameworks Trends

frontendwatch.com

Build with typescript
angular
nestjs

demo

NY

questions ?


@kuncevic