fix(core): update

This commit is contained in:
Philipp Kunz 2019-08-07 16:34:34 +02:00
parent eb9151e23e
commit 5371bd058a
10 changed files with 72 additions and 31 deletions

View File

@ -1,5 +1,5 @@
# gitzone ci_default
image: hosttoday/ht-docker-node:npmci
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
@ -49,14 +49,14 @@ testLTS:
tags:
- docker
- notpriv
testSTABLE:
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
@ -65,7 +65,7 @@ testSTABLE:
release:
stage: release
script:
- npmci node install stable
- npmci node install lts
- npmci npm publish
only:
- tags
@ -98,7 +98,9 @@ trigger:
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:18-dind
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc

View File

@ -14,4 +14,4 @@
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}
}

View File

@ -24,5 +24,16 @@
"dependencies": {
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.16"
}
}
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

26
readme.md Normal file
View File

@ -0,0 +1,26 @@
# @pushrocks/smartguard
smart guards for validations
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartguard)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartguard)
* [github.com (source mirror)](https://github.com/pushrocks/smartguard)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartguard/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartguard/badges/master/build.svg)](https://gitlab.com/pushrocks/smartguard/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartguard/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartguard/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartguard.svg)](https://www.npmjs.com/package/@pushrocks/smartguard)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartguard/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartguard)
[![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/)
## Usage
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -19,7 +19,7 @@ tap.test('should be able to create smartguards for a request', async () => {
req: smartexpress.Request;
res: smartexpress.Response;
}
const ipGuard = new smartguard.Guard<IRequestGuardData>(async (dataArg) => {
const ipGuard = new smartguard.Guard<IRequestGuardData>(async dataArg => {
console.log('executing ip guard');
if (dataArg) {
console.log('ip guard succeeded');
@ -30,15 +30,21 @@ tap.test('should be able to create smartguards for a request', async () => {
}
});
smartexpressInstance.addRoute('/testroute', new smartexpress.Handler('ALL', async (req, res) => {
await smartguard.passGuards({
req,
res
}, [ipGuard]);
console.log('ip guard said ok');
res.status(200);
res.send('hi');
}));
smartexpressInstance.addRoute(
'/testroute',
new smartexpress.Handler('ALL', async (req, res) => {
await smartguard.passGuards(
{
req,
res
},
[ipGuard]
);
console.log('ip guard said ok');
res.status(200);
res.send('hi');
})
);
console.log('Got here ok');
});

View File

@ -8,11 +8,11 @@ export const passGuards = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
const guardSet = new GuardSet<T>(guards);
const results = await guardSet.executeGuardsWithData(dataArg);
for (const result of results) {
if(!result) {
if (!result) {
return;
}
}
done.resolve();
await done.promise;
return;
};
};

View File

@ -3,6 +3,4 @@ import * as plugins from './smartguard.plugins';
/**
* a block handler is used
*/
export class BlockHandler {
}
export class BlockHandler {}

View File

@ -3,7 +3,7 @@ import * as plugins from './smartguard.plugins';
export type TGuardFunction<T> = (dataArg: T) => Promise<boolean>;
export class Guard<T> {
private guardFunction: TGuardFunction<T>;
private guardFunction: TGuardFunction<T>;
constructor(guardFunctionArg: TGuardFunction<T>) {
this.guardFunction = guardFunctionArg;
}
@ -16,4 +16,4 @@ export class Guard<T> {
const result = await this.guardFunction(dataArg);
return result;
}
}
}

View File

@ -20,4 +20,4 @@ export class GuardSet<T> {
const results = Promise.all(resultPromises);
return results;
}
}
}

View File

@ -1,6 +1,4 @@
import * as smartpromise from '@pushrocks/smartpromise';
// pushrocks scope
export {
smartpromise
};
export { smartpromise };