Skip to content

A sample project to demonstrate how to implement a full-stack app with SAP Cloud Application Programming Model, plus SAPUI5 and TypeScript.

License

Notifications You must be signed in to change notification settings

daogrady/btp-full-stack-typescript-app

 
 

Repository files navigation

Open in Visual Studio Code License Status REUSE status

Full Stack TypeScript App

This sample project is a full stack application for the SAP BTP, Cloud Foundry environment that utilizes the SAP Cloud Application Programming Model (CAP) for Node.js and SAPUI5 with TypeScript.

TypeScript is a superset of JavaScript, which can essentially be described as JavaScript with syntax for types. The additionally added syntax allows a better editor integration and aims to catch errors early in development.

This project shows a full stack app entirely build with TypeScript. It is based on a basic lecture schedule scenario. The backend service features a simple data model (Rooms, Professors, Courses, Lectures) and provides data to populate a lecture schedule, which is displayed as a planning calendar on the frontend. Users can either view or manage the lecture schedule depending on the roles that are assigned to them.

diagram

UI5 TypeScript Frontend: A freestyle SAPUI5 app serves as the frontend for the project. Component, Controller, and Formatter are implemented using the perks of TypeScript. If you want to learn more about TypeScript with UI5, have a look at the following resources:

CAP TypeScript Backend: The backend service is implemented with CAP Node.js. TypeScript is used to write the service handler for the lecture service. A tsconfig.json file is used to define TypeScript compiler options and configuration. You can find more on using TypeScript with CAP here:

For a more detailed description of the sample app and takeaways when using TypeScript, please take a look at the accompanying blog post: Full Stack TypeScript App for Cloud Foundry - Sample Repository

Requirements

Download and Installation

  1. Clone the project:
git clone https://github.com/SAP-samples/btp-full-stack-typescript-app.git
cd btp-full-stack-typescript-app

(or download from https://github.com/SAP-samples/btp-full-stack-typescript-app/archive/main.zip)

  1. In the btp-full-stack-typescript-app folder, use npm (or yarn) to install the dependencies:
npm install
  1. In the app/lectures sub-folder, use npm (or yarn) to install the dependencies:
cd app/lectures
npm install

Run, Build and Deploy the App

npm run start is for production purposes and not intended to be used on your local machine. Since TypeScript code itself cannot be executed, a transpile step to JavaScript is needed before running the project. Choose one of the following options instead to run the app.

Run the App locally

npm run start-service:ts

The service is now available at http://localhost:4004.

npm run start-ui:ts

The UI5 app is now running on http://localhost:8080/index.html (a browser window with this URL opens automatically).

For local development with mock authentication use one of the following users to test the app:

ID password
admin initial
viewer initial

Run the App locally in watch mode

npm run watch

This starts a local development server in watch mode. Changes to files (including the uncompiled TypeScript resources) are automatically detected and applied. The CAP service is now available at http://localhost:4004 (a browser window with this URL opens automatically to show the generic index.html page), and the UI5 app can be accessed at http://localhost:4004/webapp/index.html.

For local development with mock authentication use one of the following users to test the app:

ID password
admin initial
viewer initial

Build the MTA and Deploy to Cloud Foundry

Additional preparation steps and tools are required to deploy the application to SAP BTP, Cloud Foundry environment. For more information and guidance on the initial setup, please have a look at these tutorials and resources:

mbt build -t ./
cf login
cf deploy lecture-schedule_1.0.0.mtar

Limitations

  • The local database uses in-memory mode. Data will be re-initialized after each restart.
  • The provided sample data only covers a specific timeframe (CW47/2021 to CW05/2022)
  • The user role check for UI adjustments is based on the standalone approuter and BTP roles. Therefore it is not available when running the app locally.

Known Issues

None at the moment.

How to obtain Support

This content is provided "as-is" with no other support.

License

Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

About

A sample project to demonstrate how to implement a full-stack app with SAP Cloud Application Programming Model, plus SAPUI5 and TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 88.6%
  • CAP CDS 5.0%
  • JavaScript 3.7%
  • HTML 2.6%
  • CSS 0.1%