fix(core): update

This commit is contained in:
Philipp Kunz 2020-06-15 16:39:48 +00:00
parent 6788fbf715
commit 8be8ce109e
6 changed files with 3292 additions and 900 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@ -24,13 +24,14 @@ mirror:
- docker
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
tags:
- lossless
- docker

4101
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,28 +3,28 @@
"version": "1.0.29",
"private": false,
"description": "make typed requests towards apis",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/smartexpress": "^3.0.57",
"@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^13.7.1",
"tslint": "^6.0.0",
"@gitzone/tsbuild": "^2.1.24",
"@gitzone/tstest": "^1.0.33",
"@pushrocks/smartexpress": "^3.0.69",
"@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^14.0.13",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@apiglobal/typedrequest-interfaces": "^1.0.12",
"@pushrocks/lik": "^3.0.17",
"@pushrocks/smartdelay": "^2.0.6",
"@apiglobal/typedrequest-interfaces": "^1.0.13",
"@pushrocks/lik": "^4.0.13",
"@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartjson": "^3.0.10",
"@pushrocks/smartrequest": "^1.1.47"
},
@ -32,11 +32,12 @@
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}
}

View File

@ -8,16 +8,27 @@ make typed requests towards apis
* [docs (typedoc)](https://apiglobal.gitlab.io/typedrequest/)
## Status for master
[![pipeline status](https://gitlab.com/apiglobal/typedrequest/badges/master/pipeline.svg)](https://gitlab.com/apiglobal/typedrequest/commits/master)
[![coverage report](https://gitlab.com/apiglobal/typedrequest/badges/master/coverage.svg)](https://gitlab.com/apiglobal/typedrequest/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@apiglobal/typedrequest.svg)](https://www.npmjs.com/package/@apiglobal/typedrequest)
[![Known Vulnerabilities](https://snyk.io/test/npm/@apiglobal/typedrequest/badge.svg)](https://snyk.io/test/npm/@apiglobal/typedrequest)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/apiglobal/typedrequest/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/apiglobal/typedrequest/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@apiglobal/typedrequest)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/apiglobal/typedrequest)](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/typedrequest)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@apiglobal/typedrequest)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@apiglobal/typedrequest)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
## Contribution
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). :)
## Contribution

View File

@ -10,11 +10,9 @@ import { TypedHandler } from './typedrequest.classes.typedhandler';
export class TypedRouter {
public upstreamTypedRouter: TypedRouter;
public routerMap = new plugins.lik.Objectmap<
TypedRouter
>();
public routerMap = new plugins.lik.ObjectMap<TypedRouter>();
public handlerMap = new plugins.lik.Objectmap<
public handlerMap = new plugins.lik.ObjectMap<
TypedHandler<plugins.typedRequestInterfaces.ITypedRequest>
>();
@ -28,7 +26,9 @@ export class TypedRouter {
// lets check for deduplication
const existingTypedHandler = this.getTypedHandlerForMethod(typedHandlerArg.method);
if (existingTypedHandler) {
throw new Error(`a TypedHandler for ${typedHandlerArg.method} alredy exists! Can't add another one.`);
throw new Error(
`a TypedHandler for ${typedHandlerArg.method} alredy exists! Can't add another one.`
);
}
this.handlerMap.add(typedHandlerArg);
@ -36,7 +36,7 @@ export class TypedRouter {
/**
* adds another sub typedRouter
* @param typedRequest
* @param typedRequest
*/
public addTypedRouter(typedRouterArg: TypedRouter) {
this.routerMap.add(typedRouterArg);
@ -47,24 +47,27 @@ export class TypedRouter {
}
public checkForTypedHandler(methodArg: string): boolean {
return !! this.getTypedHandlerForMethod(methodArg);
return !!this.getTypedHandlerForMethod(methodArg);
}
/**
* gets a typed Router from the router chain, upstream and downstream
* @param methodArg
* @param checkUpstreamRouter
* @param checkUpstreamRouter
*/
public getTypedHandlerForMethod(methodArg: string, checkUpstreamRouter = true): TypedHandler<any> {
public getTypedHandlerForMethod(
methodArg: string,
checkUpstreamRouter = true
): TypedHandler<any> {
let typedHandler: TypedHandler<any>;
if (this.upstreamTypedRouter && checkUpstreamRouter) {
typedHandler = this.upstreamTypedRouter.getTypedHandlerForMethod(methodArg);
} else {
typedHandler = this.handlerMap.find(handler => {
return handler.method === methodArg;
});
if (!typedHandler) {
this.routerMap.getArray().forEach(typedRouter => {
if (!typedHandler) {
@ -77,7 +80,6 @@ export class TypedRouter {
return typedHandler;
}
/**
* routes a typed request to a handler
* @param typedRequestArg