forked from humanprotocol/human-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app/user/worker): remove chain id validation (#114)
* fix(app/user/worker): remove chain id validation * Test fix and JWT User data align * Updates README.md: Adds Caching section, Changes in signature type * Removes commented code * Changes after hcaptcha api check * Adds interceptor for axios requests * Fix/signature (#126) * Updates README.md (#125) * Updates README.md: Adds Caching section, Changes in signature type * README.md updates * README.md updates * fix(app/worker): add signature field to req body * update(app): revert readme * fix(app/register-address): fix test --------- Co-authored-by: macnablocky <143715306+macnablocky@users.noreply.github.com> Co-authored-by: Kacper Koza <kacper.koza@silksh.pl> * Fixes undefined in POST data, fixes unit tests * Adds Resign job feature, small changes in the gateway config (#134) * Fixes * Fixes in dependencies --------- Co-authored-by: Kacper Koza <kacper.koza@silksh.pl> Co-authored-by: maciej.nabialek <maciej.nabialek@blockydevs.com> Co-authored-by: macnablocky <143715306+macnablocky@users.noreply.github.com>
- Loading branch information
1 parent
7701d7f
commit 6c1a082
Showing
73 changed files
with
4,074 additions
and
4,007 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
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
10 changes: 10 additions & 0 deletions
10
packages/apps/human-app/server/src/common/config/gateway-config.types.ts
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { | ||
HCaptchaLabelingStatsEndpoints, | ||
HCaptchaLabelingVerifyEndpoints, | ||
ReputationOracleEndpoints, | ||
} from '../enums/reputation-oracle-endpoints'; | ||
|
||
export type GatewayEndpoints = | ||
| HCaptchaLabelingStatsEndpoints | ||
| ReputationOracleEndpoints | ||
| HCaptchaLabelingVerifyEndpoints; |
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
3 changes: 2 additions & 1 deletion
3
packages/apps/human-app/server/src/common/enums/external-api-name.ts
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,4 +1,5 @@ | ||
export enum ExternalApiName { | ||
REPUTATION_ORACLE = 'REPUTATION_ORACLE', | ||
HCAPTCHA_LABELING = 'HCAPTCHA_LABELING', | ||
HCAPTCHA_LABELING_STATS = 'HCAPTCHA_LABELING_STATS', | ||
HCAPTCHA_LABELING_VERIFY = 'HCAPTCHA_LABELING_VERIFY', | ||
} |
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
40 changes: 40 additions & 0 deletions
40
packages/apps/human-app/server/src/common/interceptors/axios-request.interceptor.ts
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import axios from 'axios'; | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { EnvironmentConfigService } from '../config/environment-config.service'; | ||
|
||
@Injectable() | ||
export class AxiosRequestInterceptor { | ||
private readonly logger = new Logger(AxiosRequestInterceptor.name); | ||
|
||
constructor(private configService: EnvironmentConfigService) { | ||
this.initializeRequestInterceptor(); | ||
} | ||
|
||
private initializeRequestInterceptor() { | ||
if (!this.configService.axiosRequestLoggingEnabled) return; | ||
axios.interceptors.request.use( | ||
(config) => { | ||
const { url, method, params, data, headers } = config; | ||
this.logger.log('NEW REQUEST:'); | ||
this.logger.log(`Request URL: ${url}`); | ||
this.logger.log(`Method: ${method}`); | ||
this.logger.log(`Params: ${JSON.stringify(params ?? {})}`); | ||
this.logger.log(`Body: ${JSON.stringify(data ?? {})}`); | ||
this.logger.log(`Headers: ${JSON.stringify(headers ?? {})}`); | ||
return config; | ||
}, | ||
(error) => { | ||
this.logger.error(`Request error: ${error.message}`); | ||
return Promise.reject(error); | ||
}, | ||
); | ||
|
||
axios.interceptors.response.use( | ||
(response) => response, | ||
(error) => { | ||
this.logger.error(`Response error: ${error.message}`); | ||
return Promise.reject(error); | ||
}, | ||
); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/apps/human-app/server/src/common/interceptors/interceptor.module.ts
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module, Global } from '@nestjs/common'; | ||
import { AxiosRequestInterceptor } from './axios-request.interceptor'; | ||
|
||
@Global() | ||
@Module({ | ||
providers: [AxiosRequestInterceptor], | ||
exports: [AxiosRequestInterceptor], | ||
}) | ||
export class InterceptorModule {} |
2 changes: 1 addition & 1 deletion
2
packages/apps/human-app/server/src/common/interfaces/endpoint.interface.ts
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.