Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4131ceda93 | |||
| 6003625186 | |||
| 3b50e9c8cc | |||
| 2e42011eda | |||
| d9512ae3e8 | |||
| 32e72dc131 | |||
| 5371bd058a |
+1
-3
@@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
||||||
+51
-28
@@ -1,16 +1,19 @@
|
|||||||
# gitzone ci_default
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@@ -19,38 +22,42 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
- npmci command npm install --production --ignore-scripts
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command snyk test
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
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
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
@@ -60,7 +67,17 @@ testSTABLE:
|
|||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@@ -70,6 +87,7 @@ release:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@@ -79,11 +97,14 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
@@ -94,18 +115,20 @@ trigger:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
|
|||||||
Vendored
+3
-21
@@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+26
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+2
-1
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartguard",
|
"gitrepo": "smartguard",
|
||||||
"shortDescription": "smart guards for validations",
|
"description": "smart guards for validations",
|
||||||
"npmPackagename": "@pushrocks/smartguard",
|
"npmPackagename": "@pushrocks/smartguard",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "push.rocks"
|
"projectDomain": "push.rocks"
|
||||||
|
|||||||
Generated
+17656
-1561
File diff suppressed because it is too large
Load Diff
+27
-11
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartguard",
|
"name": "@pushrocks/smartguard",
|
||||||
"version": "1.0.3",
|
"version": "2.0.1",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "smart guards for validations",
|
"description": "smart guards for validations",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -13,16 +14,31 @@
|
|||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.60",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.69",
|
||||||
"@pushrocks/smartexpress": "^3.0.35",
|
"@pushrocks/smartexpress": "^3.0.110",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^5.0.2",
|
||||||
"@types/node": "^10.11.7",
|
"@types/node": "^17.0.22",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@pushrocks/smartrequest": "^1.1.16"
|
"@pushrocks/smartrequest": "^1.1.56"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# @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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
## 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). :)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartguard from '../ts/index';
|
import * as smartguard from '../ts/index.js';
|
||||||
import * as smartexpress from '@pushrocks/smartexpress';
|
import * as smartexpress from '@pushrocks/smartexpress';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ tap.test('should create a demo smartexpress instance', async () => {
|
|||||||
cors: true,
|
cors: true,
|
||||||
forceSsl: false,
|
forceSsl: false,
|
||||||
defaultAnswer: async () => 'hi there',
|
defaultAnswer: async () => 'hi there',
|
||||||
port: 3211
|
port: 3211,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -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) => {
|
smartexpressInstance.addRoute(
|
||||||
await smartguard.passGuards({
|
'/testroute',
|
||||||
|
new smartexpress.Handler('ALL', async (req, res) => {
|
||||||
|
await smartguard.passGuards(
|
||||||
|
{
|
||||||
req,
|
req,
|
||||||
res
|
res,
|
||||||
}, [ipGuard]);
|
},
|
||||||
|
[ipGuard]
|
||||||
|
);
|
||||||
console.log('ip guard said ok');
|
console.log('ip guard said ok');
|
||||||
res.status(200);
|
res.status(200);
|
||||||
res.send('hi');
|
res.send('hi');
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
console.log('Got here ok');
|
console.log('Got here ok');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -48,7 +54,7 @@ tap.test('should start server with guards in place', async () => {
|
|||||||
|
|
||||||
tap.test('should execute a request', async () => {
|
tap.test('should execute a request', async () => {
|
||||||
const response = await smartrequest.request('http://localhost:3211/testroute', {
|
const response = await smartrequest.request('http://localhost:3211/testroute', {
|
||||||
method: 'GET'
|
method: 'GET',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
+5
-5
@@ -1,14 +1,14 @@
|
|||||||
import * as plugins from './smartguard.plugins';
|
import * as plugins from './smartguard.plugins.js';
|
||||||
import { Guard } from './smartguard.classes.guard';
|
import { Guard } from './smartguard.classes.guard.js';
|
||||||
import { GuardSet } from './smartguard.classes.guardset';
|
import { GuardSet } from './smartguard.classes.guardset.js';
|
||||||
export * from './smartguard.classes.guard';
|
export * from './smartguard.classes.guard.js';
|
||||||
|
|
||||||
export const passGuards = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
|
export const passGuards = async <T>(dataArg: T, guards: Array<Guard<T>>) => {
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
const guardSet = new GuardSet<T>(guards);
|
const guardSet = new GuardSet<T>(guards);
|
||||||
const results = await guardSet.executeGuardsWithData(dataArg);
|
const results = await guardSet.executeGuardsWithData(dataArg);
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
if(!result) {
|
if (!result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import * as plugins from './smartguard.plugins';
|
import * as plugins from './smartguard.plugins.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a block handler is used
|
* a block handler is used
|
||||||
*/
|
*/
|
||||||
export class BlockHandler {
|
export class BlockHandler {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartguard.plugins';
|
import * as plugins from './smartguard.plugins.js';
|
||||||
|
|
||||||
export type TGuardFunction<T> = (dataArg: T) => Promise<boolean>;
|
export type TGuardFunction<T> = (dataArg: T) => Promise<boolean>;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './smartguard.plugins';
|
import * as plugins from './smartguard.plugins.js';
|
||||||
import { Guard } from './smartguard.classes.guard';
|
import { Guard } from './smartguard.classes.guard.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a guardSet is a set of guards that need to be fulfilled
|
* a guardSet is a set of guards that need to be fulfilled
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
export {
|
export { smartpromise };
|
||||||
smartpromise
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
||||||
-17
@@ -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"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user