Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
5ea494cef3 | |||
1830daacba | |||
52cca1c8f3 | |||
fd5f50e420 | |||
ce88b62d3c | |||
9fa3165304 | |||
069d61ccf7 |
@ -12,40 +12,36 @@ stages:
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- pnpm install -g pnpm
|
||||
- pnpm install -g @shipzone/npmci
|
||||
- npmci npm prepare
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
- npmci command pnpm audit --audit-level=high --dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
@ -56,7 +52,6 @@ auditDevDependencies:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -67,10 +62,9 @@ testStable:
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- npmci npm build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
@ -96,10 +90,9 @@ codequality:
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
@ -119,11 +112,9 @@ trigger:
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -2,17 +2,31 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "apiglobal",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "api.global",
|
||||
"gitrepo": "test-sdk",
|
||||
"shortDescription": "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"
|
||||
}
|
||||
}
|
10936
package-lock.json
generated
10936
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@ -1,30 +1,30 @@
|
||||
{
|
||||
"name": "@apiglobal/test-sdk",
|
||||
"version": "1.0.27",
|
||||
"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",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.14.0",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.15.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/sdk": "^1.0.18",
|
||||
"@apiglobal/typedrequest": "^1.0.54",
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/smartexpress": "^3.0.81",
|
||||
"@apiglobal/sdk": "^2.0.1",
|
||||
"@apiglobal/typedrequest": "^2.0.12",
|
||||
"@apiglobal/typedrequest-interfaces": "^2.0.1",
|
||||
"@pushrocks/qenv": "^5.0.2",
|
||||
"@pushrocks/smartexpress": "^4.0.28",
|
||||
"@pushrocks/smartobject": "^1.0.4"
|
||||
},
|
||||
"files": [
|
||||
@ -41,5 +41,17 @@
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
"API testing",
|
||||
"SDK",
|
||||
"development tools",
|
||||
"API Gateway",
|
||||
"server simulation",
|
||||
"handlers testing",
|
||||
"automated testing",
|
||||
"TypeScript",
|
||||
"Node.js"
|
||||
]
|
||||
}
|
||||
}
|
4232
pnpm-lock.yaml
generated
Normal file
4232
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
140
readme.md
140
readme.md
@ -1,39 +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 | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](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
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| 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:
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
```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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as testSdk from '../ts/index';
|
||||
import * as testSdk from '../ts/index.js';
|
||||
|
||||
let testServer: testSdk.AgTestServer;
|
||||
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/test-sdk',
|
||||
version: '2.0.2',
|
||||
description: 'an sdk for testing ag handlers'
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from './test-sdk.plugins';
|
||||
import { AgTestServer } from './test-sdk.classes.testserver';
|
||||
import * as plugins from './test-sdk.plugins.js';
|
||||
import { AgTestServer } from './test-sdk.classes.testserver.js';
|
||||
import { AAgHandler } from '@apiglobal/sdk';
|
||||
|
||||
export { AgTestServer };
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './test-sdk.plugins';
|
||||
import * as plugins from './test-sdk.plugins.js';
|
||||
|
||||
export class AgTestServer {
|
||||
public handlers: Array<plugins.agSdk.AAgHandler<any>> = [];
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user