update documentation

This commit is contained in:
Philipp Kunz 2024-04-14 18:57:25 +02:00
parent 1830daacba
commit 5ea494cef3
5 changed files with 156 additions and 40 deletions

View File

@ -2,17 +2,31 @@
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "apiglobal",
"githost": "code.foss.global",
"gitscope": "api.global",
"gitrepo": "test-sdk",
"description": "an sdk for testing ag handlers",
"npmPackagename": "@apiglobal/test-sdk",
"description": "A software development kit for testing API Gateway handlers.",
"npmPackagename": "@api.global/test-sdk",
"license": "MIT",
"projectDomain": "api.global"
"projectDomain": "api.global",
"keywords": [
"API testing",
"SDK",
"development tools",
"API Gateway",
"server simulation",
"handlers testing",
"automated testing",
"TypeScript",
"Node.js"
]
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -1,8 +1,8 @@
{
"name": "@apiglobal/test-sdk",
"name": "@api.global/test-sdk",
"version": "2.0.2",
"private": false,
"description": "an sdk for testing ag handlers",
"description": "A software development kit for testing API Gateway handlers.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
@ -42,5 +42,16 @@
"browserslist": [
"last 1 chrome versions"
],
"type": "module"
}
"type": "module",
"keywords": [
"API testing",
"SDK",
"development tools",
"API Gateway",
"server simulation",
"handlers testing",
"automated testing",
"TypeScript",
"Node.js"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

140
readme.md
View File

@ -1,37 +1,123 @@
# @apiglobal/test-sdk
# @api.global/test-sdk
an sdk for testing ag handlers
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@apiglobal/test-sdk)
* [gitlab.com (source)](https://gitlab.com/apiglobal/test-sdk)
* [github.com (source mirror)](https://github.com/apiglobal/test-sdk)
* [docs (typedoc)](https://apiglobal.gitlab.io/test-sdk/)
## Install
To install `@api.global/test-sdk`, you need to have Node.js and npm installed. Follow these steps to install it:
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/apiglobal/test-sdk/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/apiglobal/test-sdk/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@apiglobal/test-sdk)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/apiglobal/test-sdk)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@apiglobal/test-sdk)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@apiglobal/test-sdk)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@apiglobal/test-sdk)](https://lossless.cloud)
```bash
npm install @api.global/test-sdk --save
```
This will add `@api.global/test-sdk` to your project's dependencies.
## Usage
This document provides a comprehensive guide on how to effectively utilize the `@api.global/test-sdk` module in your project. We will explore various use cases, demonstrate the SDK's capabilities through code examples, and ensure a thorough understanding of its features. This guide assumes that you have basic knowledge of TypeScript and are familiar with the concepts of asynchronous programming.
Use TypeScript for best in class intellisense
### Getting Started
## Contribution
First, ensure that you are importing the SDK's functionalities as follows:
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
```typescript
import { AgTestServer, createTestServer, stopTestServer } from '@api.global/test-sdk';
```
For further information read the linked docs at the top of this readme.
### Creating and Starting a Test Server
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
The `@api.global/test-sdk` allows for the creation of test servers with custom handlers. Here's how to set it up:
```typescript
import { createTestServer } from '@api.global/test-sdk';
// Your custom handler should extend from AAgHandler
class MyCustomHandler extends AAgHandler<any> {
constructor(envManagerArg: AgEnvironment) {
super(envManagerArg);
this.slug = 'mycustomhandler'; // Define a unique slug for your handler
}
// Implement required handler methods here
}
async function setupTestServer() {
const testServer = await createTestServer(MyCustomHandler);
console.log('Test server started successfully');
return testServer;
}
```
### Sending Requests to the Test Server
With the test server running, you can now simulate requests. Let's demonstrate how to send a request to the custom handler and evaluate the response:
```typescript
import { testFire } from '@api.global/test-sdk';
async function testRequest() {
const testResponse = testFire<MyCustomHandler, MyRequestInterface>(
'mycustomhandler', // The slug of your handler
'POST', // The HTTP method
{ // The request body
key: 'value'
}
);
// Expecting a response from the server
const expectedResponse = await testResponse.expect({
expectedKey: 'expectedValue'
});
console.log('The expected response was received:', expectedResponse);
}
```
### Stopping the Test Server
It's important to properly shut down the test server once your testing is complete to free up resources:
```typescript
async function shutdownTestServer() {
await stopTestServer();
console.log('Test server stopped successfully');
}
```
### Full Example
Here's how everything comes together in a script:
```typescript
import { AgTestServer, createTestServer, stopTestServer, testFire } from '@api.global/test-sdk';
class MyCustomHandler extends AAgHandler<any> {
// Implementation of the custom handler...
}
async function main() {
const server = await setupTestServer();
await testRequest();
await shutdownTestServer();
}
main().catch(console.error);
```
This guide provides a foundational understanding of how to utilize `@api.global/test-sdk` for testing purposes. Through the creation of a test server, the execution of requests, and the evaluation of responses, developers can simulate real-world scenarios and ensure that their applications behave as expected in a controlled environment.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -3,8 +3,12 @@
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}