Skip to main content

Stack TypeScript NestJS

Introduction

The TypeScript NestJS stack offers support for easily implementing a Node.js backend while using TypeScript as implementation language. The stack is based on NestJS and allows native development in combination with pre-generated modules which makes it easy to implement different use cases.

k5 SDK

When using the TypeScript NestJS stack, the k5 SDK plays a major role for the easy and streamlined implementation of your backend. It is an automatically generated node package, which offers rich support for various use cases and will be added as a dependency into your project.

Example usage of the k5 sdk within a project:

import { ConfigModule } from '@nestjs/config';
import { Module } from '@nestjs/common';
import { K5SDKModule } from 'k5-sdk';

@Module({
imports: [
ConfigModule.forRoot(),
K5SDKModule.forRoot(),
],
controllers: [],
providers: [],
})
export class AppModule {}

The generation of the k5 SDK can be triggered through the command k5 generate-code in the Solution CLI and also during pipeline execution.

The classes and functions offered in the k5 SDK is depending on the enabled Extensions and the items modelled in the Solution Designer. To learn more about how to use them, please check Base features of TypeScript NestJS stack.

NestJS patterns

The TypeScript NestJS stack is built on top of the principles of NestJS and fully supports them (e.g. Modules, Providers, Controllers). To find out more about these patterns, please checkout the NestJS Documentation. When creating the project, it also comes with a default set of initial files, similar to what developers get when initially using the Nest CLI. These files help you to easily start development.

The TypeScript NestJS stack is fully compliant with native NestJS development. When using it, you'll keep all the flexibility that NestJS offers you to be able to cover any use case.

Project structure

After cloning the project using the Solution CLI, the following initial project structure is created:

├── node_modules
│ ├── k5-sdk // k5 SDK mmodule
├── src
│ ├── app.module.ts // Root module of the application
│ └── main.ts // The entry file of the application, creates a Nest application instance.
├── src-design // Holds all design files automatically added through Solution Designer
├── jest-e2e.config.js // Configuration for Jest e2e tests
├── jest.config.js // Configuration for Jest tests
├── k5-project.yml // Project configuration
├── nest-cli.json // Nest CLI configuration
├── .env // Example .env file containing placeholders for app variables
├── .eslintrc.js // ESLint configuration
├── .prettierrc // Prettier configuration
├── .gitignore
├── .editorconfig
├── package-lock.json
├── package.json
├── tsconfig.build.json
└── tsconfig.json