ngx-starter-kit
develop
develop
  • NGX Starter Kit
  • Getting Started
    • FAQ2
    • Why
    • Installation
    • Playbook
    • NestJs Playbook
  • Concepts
    • Introduction
    • Store
    • Actions
    • State
    • Select
  • Advanced
    • Action Handlers
    • Actions Life Cycle
    • Envoy Proxy
    • Cancellation
    • Composition
    • Error Handling
    • Ivy Migration Guide
    • Lazy Loading
    • Life-cycle
    • Mapped Sub States
    • Meta Reducers
    • Options
    • Shared State
    • State Token
    • State Operators
    • Style Guide
    • Troubleshooting
  • Dev Ops
    • Keycloak
  • Modules
    • Apps
      • WebApp
      • Api
    • Libs
      • Admin
      • Blog
      • Core
      • Dashboard
      • Gen
      • Home
      • Not Found
      • Shared
  • Recipes
    • Authentication
    • Caching
    • Component Events from NGXS
    • Debouncing Actions
    • Dynamic Plugins
    • Immutability Helpers
    • Style Guide
    • Unit Testing
  • Community
    • Resources
    • Contributors
    • Contributing
  • Change Log
  • FAQ
  • TODO
Powered by GitBook
On this page
  • Description
  • Built with
  • Development
  • Run
  • Build
  • Commands
  • Generate
  • Unit Test
  • E2E Test
  • Health
  • Reference

Was this helpful?

  1. Modules
  2. Apps

Api

PreviousWebAppNextLibs

Last updated 3 years ago

Was this helpful?

Description

Backend API build with Framework.

This project uses to simplify and standardize the REST API

Built with

Component

Using

Descrption

Base

ORM

CRUD

nest-router

File Upload

Validation

Documentation

Authentication

Testing

Code Style

Development

Run

Postgres

start Postgres

# start local postgres
docker-compose up postgres
# (or) start local postgres with data reset
docker-compose up -V postgres #remove volumes

# (optional) start local keycloak
docker-compose up keycloak

# stop local postgres before restart again
docker-compose down
# (or) stop local postgres with data reset
docker-compose down -v #remove volumes

if error The container name "/postgres" is already in use by container, remove orphan container.

docker ps -a
docker rm 82be5234c94a

connect Postgres running on local k8s

$ POD_NAME=$(kubectl get pods  -lapp=postgres -o jsonpath='{.items[0].metadata.name}')
$ kubectl port-forward $POD_NAME 5432:5432

Run Dev Mode

# start in watch mode
nx serve api
# to turn on logging for `request`
NODE_DEBUG=request nx serve api
DEBUG=typeorm:* nx serve api
# optionally you can run with prod env(environment.prod.ts) for tesrting! use this for testing only.
nx serve api --prod

Run Prod Mode

# clean dist first
npx rimraf dist
# then build
ng build api --prod
# then run
node dist/apps/api/main.js

Build

build for production env

ng build api --prod
# or
yarn workspace @ngx-starter-kit/api build:prod

Commands

# to run custom commands, `check api:typeorm in angular.json`
ng run api:typeorm

Generate

# check of nest installed
nest info

# scaffold auth module
nest g module app/auth  --dry-run
nest g controller auth app/auth --flat --dry-run
nest g service auth app/auth --flat --dry-run
nest g class user.entity app/auth --no-spec --dry-run
nest g class auth.exception app/auth --no-spec --dry-run

Unit Test

coverage will be generate in coverage/apps/api

# unit test only changed
ng test api --onlyChanged
# generate coverage
ng test api --codeCoverage
# test in CI env
ng test api --runInBand

E2E Test

ng e2e api
# e2e test with watch mode
ng e2e api --watch
# e2e test in CI env
ng e2e api --forceExit --detectOpenHandles

Health

check API App health

local

prod

Reference

  • Awesome Nest

  • NestJS Samples

  • TypeORL Samples

&

&

API URL:

Swagger Docs URL:

scaffolding nest artifacts For more details checkout

Nest
@nestjsx/crud
http://localhost:3000
http://localhost:3000/docs
playbook
http://localhost:3000/health/live
http://localhost:3000/health/ready
https://api.kashmora.com/live
https://api.kashmora.com/ready
https://github.com/juliandavidmr/awesome-nest
https://github.com/nestjs/nest/tree/master/sample
https://github.com/typeorm/typeorm/tree/master/sample
NestJS
TypeORM
@nestjsx/crud
@nestjsx/nest-router
Multer
Class-Validator
Open API(Swagger)
Passport.js
Jest
SuperTest
Prettier
TS-Lint