Skip to content

kgish/angular-nestjs-jwt

Repository files navigation

Angular Nestjs Jwt

Template for setting up an Angular application using Nestjs and JWT.

Installation

$ git clone https://github.com/kgish/angular-nestjs-jwt.git
$ cd angular-nestjs-jwt

Original setup

For those interested, here is a short guide to how this workspace was originally setup.

Dependencies

Install the latest releases of the Angular CLI, Nrwl/Nx CLI and Schematics.

$ yarn global add @angular/cli @nrwl/cli @nrwl/schematics

When asked select angular-nest.

Screenshot of the monitor page

Workspace

Create the workspace and change directories.

$ yarn create nx-workspace ng-nest-jwt --directory=angular-nestjs-jwt
$ cd angular-nestjs-jwt

Docker

Create a docker-compose.yml file in the root directory with the following contents.

version: '2.4'
services:
  db:
    container_name: angular_nestjs_db
    image: postgres:10.7
    volumes:
      - './db/initdb.d:/docker-entrypoint-initdb.d'
    ports:
      - '5432:5432'

Add the following to package.json:

{
  ...
  "scripts": {
    ...
    "run:services": "docker-compose up && exit 0",
    "stop:services": "docker-compose down"
  },
  ...
}

Dotenv

$ yarn add dotenv @types/dotenv

In the workspace root directory add a file .env with the following contents.

DB_type=postgres
DB_host=localhost
DB_PORT=5432
DB_USER=angular_nestjs
DB_PASSWORD=angular_nestjs
DB_DATABASE=angular_nestjs
DB_SYNCHRONIZE=true
DB_LOGGING=true

TypeOrm

From the workspace root directory, install the typeorm library.

$ yarn add typeorm pg @nestjs/typeorm

Create a configuration file in the workspace root directory called ormconfig.json with the following contents.

{
  "name": "development",
  "type": "postgres",
  "host": "localhost",
  "port": 5432,
  "username": "angular_nestjs",
  "password": "angular_nestjs",
  "database": "angular_nestjs",
  "synchronize": true,
  "logging": true,
  "entities": ["dist/api/**/*.entity.js"],
  "cli": {
    "entitiesDir": "apps/api/app/src"
  }
}

Package.json

"watch:server": "nodemon",
"build:server": "tsc -p ./apps/api/tsconfig.app.json",
"run:server": "node -r dotenv/config -r source-map-support/register dist/apps/api/src/main.js"

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published