LazyStack

ClientSDK

LazyStack generates C# and TypeScript clients using the NSwag library and by performing some post processing on the files generated by NSwag.

C# ClientSDK

LazyStack generates the application {appName}ClientSDK library project and the {appName}Schema library project.

Use the C# ClientSDK library, along with the LazyStackAuth library, in your client application to make secure calls against your AWS Application Stack. Consider the following diagram of the PetStore application.

A normal NSwag client library would include both the methods and data classes. We generate two separate libraries because the Schema library is used by both the client and server code. This Schema library only contains data object classes for information exchanged among the client and API Gateways.

TypeScript Libraries

LazyStack optionally generates a solution and file system folder, called TypeScriptClientLibs, containing one or more TypeScript libraries of the following types:

  • Angular
  • AngularJS
  • Aurelia
  • Axios
  • Fetch
  • JQueryCallbacks
  • JQueryPromises

See the NSwag documentation for more information about these libraries and our user guide for how to use LazyStack directives to specify which TypeScript library to generate.

For web apps, it is generally accepted practice to use the AWS-Amplify libraries for calling AWS Services. Amplify makes authenticating users against AWS Cognito easy. AWS Amplify also provides ready-to-use UI Components for popular frameworks like React, React Native, Angular, Vue, Ionic and Next.js.

AWS Amplify includes the an API class which is used to make secure calls against API Gateways. Under the covers, the Amplify API class uses Axios to make http requests.

Since LazyStack uses NSwag to generate the TypeScript ClientSDK, you don't need to use the Amplify API class to make http requests. Although not required, we recommend using the Axios option when generating your TypeScript ClientSDK to reduce the libraries code packed in your SPA.

Unlike the C# ClientSDK, we don't split the data classes out into a separate library.

Supporting Configuration Files Used by ClientSDKs

Both the C# and TypeScript ClientSDK libraries are configured using two generated configuration files:

  • AwsSettings.json: This configuration file contains the information necessary to connect to the AWS Serverless Stack. For developer accounts, this file is generated by the LazyStack tool Generate\Stacks\Dev\AwsSettings command. For CI/CD pipelines, this file is generated by LazyStackSMF utilities. There is also a LazyStack repo LazyStackGetSettings project for your reference and possible use in hand rolled CI/CD pipeline work.

  • MethodMap.json: This file is generated file contains a map of methods to ApiGateways that the ClientSDK uses to direct calls to the ApiGateway servicing each method. This file is regenerated each time the LazyStack generate process is performed.

For C# clients these two files are generally used as embedded resources.

For Web App clients these two files are copied into into the SPA src folder and bundled with your SPA.

LazyStackAuth

The AWS Cognito Authentication C# libraries are rather involved and require a substantial time investment to master. They are also 100% AWS specific and do not attempt to present a generalized process. On the other hand, these Cognito libraries are robust and implement a well known challenge/response pattern. The LazyStackAuth library wraps the AWS Cognito authentication libraries with a fully generalized challenge/response model that provides for the implementation of other authentication providers or for extensions to the the Cognito authentication process.

The LazyStackAuth project is available as a NuGet package, a LazyStack template project and as a MIT licensed source project in the LazyStackLibs GitHub repository. It provides a generalized challenge/response based user management library that uses the Amazon.Extension.CognitoAuthentication library to make calls against the Cognito authentication service. Note that it also calls AWS STS to get temporary credentials if necessary.

See the detailed documentation for LazyStackAuth for more information.