Develop Advanced Extensions with SAP Cloud SDK

Building a CRUD extension using TypeScript

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Build a CRUD extension application using TypeScript and the Nest framework

Exploring the Use of Nest and SAP Cloud SDK

Introducing the Nest (NestJS) Framework

Nest (NestJS) is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with and fully supports TypeScript (yet still enables developers to code in pure JavaScript), and combines elements of Object Oriented Programming (OOP), Functional Programming (FP), and Functional Reactive Programming (FRP).

Nest makes use of robust HTTP Server frameworks like Express (the default) and optionally can be configured to use Fastify as well. It provides a level of abstraction above these common Node.js frameworks (Express/Fastify), but also exposes their APIs directly to the developer. This provides developers with the freedom to use the myriad of third-party modules, which are available for the underlying platform.

You can find full documentation of Nest in the official web site at https://nestjs.com

Introducing the SAP Cloud SDK Command Line Interface

SAP provides a command line interface (CLI) that can be installed through the npm tool and then used to create an initial extension application based on JavaScript/TypeScript and using the Nest application framework.

You can use the CLI to do the following:

  • Setup your Cloud Foundry app to authenticate through the app router
  • Setup your Cloud Foundry app to use a CDS service
  • Add the scripts to set up a Jenkins master for CI/CD of your project
  • Display auto-complete installation instructions
  • Generate an OData client from a edmx service file definition
  • Package application files for deployment

To install the CLI via NPM, run the following command:

Code snippet
npm install -g @sap-cloud-sdk/cli
Copy code

To create your initial application, based on Nest and the SAP Cloud SDK, run the following command:

Code snippet
sap-cloud-sdk init my-project
Copy code

You can access the full CLI documentation at https://github.com/SAP/cloud-sdk-cli

Debugging with Visual Studio Code

Using the Nest framework in conjunction with Visual Studio Code provides an optimum development experience. You can also run the following features at the same time:

  • The debug feature: to set breakpoints and stop program execution when required.
  • The watch feature: to change the source code of the running application. This is automatically recognized, the application is automatically re-built and re-started.

Create, Update and Delete requests in SAP Cloud SDK

The create/update/delete request is created and executed using the request builder provided within the related object class (in this case, BusinessPartnerAddress).

In the example, you use the create function to prepare the create request for subsequent execution. In a similar way, you can update or delete.

Save progress to your learning plan by logging in or creating an account