-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* return InvalidParamsException when AJV fails * update tests * update CEE integration tests
- Loading branch information
1 parent
b31cc90
commit 0ec6e9a
Showing
11 changed files
with
94 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
import { | ||
middleware, | ||
ValidatorInterfaceResolver, | ||
ParamsType, | ||
ContextType, | ||
ResultType, | ||
MiddlewareInterface, | ||
InvalidParamsException, | ||
ParamsType, | ||
ResultType, | ||
ValidatorInterfaceResolver, | ||
middleware, | ||
} from '@ilos/common'; | ||
|
||
@middleware() | ||
export class ValidatorMiddleware implements MiddlewareInterface { | ||
constructor(private validator: ValidatorInterfaceResolver) {} | ||
|
||
async process(params: ParamsType, context: ContextType, next: Function, schema: string): Promise<ResultType> { | ||
try { | ||
await this.validator.validate(params, schema); | ||
} catch (e) { | ||
console.error(e); | ||
throw new InvalidParamsException(e.message); | ||
} | ||
|
||
await this.validator.validate(params, schema); | ||
return next(params, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.