Authentication with Passport JWT

This is the third part of Getting Started with NestJS. This document was updated to use NestJS 5.3.6

We use Passport as our authentication middleware with NestJS. It suppport different methods, in Passport it’s called Strategy, to authenticate e.g Local, OpenID, Facebook, Google Account and Twitter. We use the local one.

We need a user entity to persist registered user. This is the same task as creating the product entity from last time.

Create folder user in folder nestjs-backend/src.

Create file user.entity.ts in folder nestjs-backend/src/user.
Continue reading “Authentication with Passport JWT”

Add TypeORM to NestJS Project

This is the second part of Getting Started with NestJS. This document was updated to use NestJS 5.3.6

We add sqlite3 database support with TypeORM. Install TypeORM and sqlite3 for our project:

npm i -s @nestjs/typeorm typeorm sqlite3

In folder nestjs-backend/src create folder product.

In folder nestjs-backend/src/product create the file product.entity.ts.


import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Product {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 500 })
  name: string;

  @Column('text')
  description: string;
}

Continue reading “Add TypeORM to NestJS Project”

Getting Started with NestJS

We are getting started with NestJS. This document is a work in progress and it gets updated as we go. This document was updated to use NestJS 5.3.6 We use Visual Studio Code, download and install it. Open the console in VS Code with View|Integrated Terminal. Now create a new folder for the project on the console and open it as VS Code project folder:

 mkdir nestjs-backend code -r nestjs-backend

Install Node.js if you don’t have it yet. Check for npm version (currently 5.6.0), npm comes with Node.js.

npm -v

If the version is older than 5 update it with

npm install -g npm

Continue reading “Getting Started with NestJS”

Handle offline and online status

Check if your web app is offline/online and show the status and handle it when the user triggers something needing the connection. [Mozilla: Online and offline events](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events)

What is the right way to wait for data in Angular?

I have a child-component `CheckboxListComponent` which shows a list of checkboxes. The list is populated in `ngOnInit` through a webservice-call which takes more or less time. It also has a function `setEntryChecked` to set a specific item to checked. When `foo()` is called before the `CheckboxListComponent` has it’s data the call was lost or has no effect. My solution is to wait for the result to be available with `await this.listSubject.first().toPromise()`. Is there a better way to do this in TypeScript? Continue reading “What is the right way to wait for data in Angular?”

10000km Milestone

Today I reached the 10k milestone. From 02. August 2013 to 03. November 2015 I made 12.15km daily. The need for maintenance was very low. Not a single time I had to adjust the Gates Drive Belt.

Only two punctures during that time:

2014-03-07 3317km Fix the rear tire.

2015-06-08 7871km Replace the front tube.