Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions packages/apps/dashboard/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,27 @@
"@human-protocol/core": "workspace:*",
"@human-protocol/logger": "workspace:*",
"@human-protocol/sdk": "workspace:*",
"@nestjs/axios": "^3.1.2",
"@nestjs/cache-manager": "^2.2.2",
"@nestjs/common": "^10.2.7",
"@nestjs/config": "^3.2.3",
"@nestjs/core": "^11.1.9",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^10.3.10",
"@keyv/redis": "^5.1.5",
"@nestjs/axios": "^4.0.1",
"@nestjs/cache-manager": "^3.1.0",
"@nestjs/common": "^11.1.12",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.12",
"@nestjs/mapped-types": "^2.1.0",
"@nestjs/platform-express": "^11.1.12",
"axios": "^1.3.1",
"cache-manager": "^5.4.0",
"cache-manager-redis-yet": "^5.1.5",
"cache-manager": "7.2.8",
"dayjs": "^1.11.12",
"ethers": "~6.15.0",
"keyv": "^5.5.5",
"lodash": "^4.17.21",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^11.0.2",
"@nestjs/testing": "^10.4.6",
"@nestjs/cli": "^11.0.16",
"@nestjs/schematics": "^11.0.9",
"@nestjs/testing": "^11.1.12",
"@types/express": "^4.17.13",
"@types/jest": "30.0.0",
"@types/node": "22.10.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CacheModuleAsyncOptions } from '@nestjs/common/cache';
import { ConfigModule } from '@nestjs/config';
import { redisStore } from 'cache-manager-redis-yet';
import * as _ from 'lodash';

import KeyvRedis, { Keyv } from '@keyv/redis';
import logger from '../../logger';
import { RedisConfigService } from './redis-config.service';

Expand All @@ -17,7 +17,7 @@ export const CacheFactoryConfig: CacheModuleAsyncOptions = {
isGlobal: true,
imports: [ConfigModule],
useFactory: async (configService: RedisConfigService) => {
const store = await redisStore({
const redisAdapter = new KeyvRedis({
socket: {
host: configService.redisHost,
port: configService.redisPort,
Expand All @@ -26,10 +26,17 @@ export const CacheFactoryConfig: CacheModuleAsyncOptions = {
disableOfflineQueue: true,
});

store.client.on('error', throttledRedisErrorLog);
redisAdapter.on('error', throttledRedisErrorLog);
redisAdapter.client.on?.('error', throttledRedisErrorLog);

const keyvStore = new Keyv({
store: redisAdapter,
namespace: undefined,
useKeyPrefix: false,
});

return {
store: () => store,
stores: [keyvStore],
};
},
inject: [RedisConfigService],
Expand Down
24 changes: 12 additions & 12 deletions packages/apps/fortune/exchange-oracle/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
"dependencies": {
"@human-protocol/logger": "workspace:*",
"@human-protocol/sdk": "workspace:*",
"@nestjs/axios": "^3.1.2",
"@nestjs/common": "^10.2.7",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^11.1.9",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.3.10",
"@nestjs/schedule": "^4.0.1",
"@nestjs/swagger": "^7.4.2",
"@nestjs/axios": "^4.0.1",
"@nestjs/common": "^11.1.12",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.12",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.1.12",
"@nestjs/schedule": "^6.1.0",
"@nestjs/swagger": "^11.2.5",
"@nestjs/terminus": "^11.0.0",
"@nestjs/typeorm": "^10.0.1",
"@nestjs/typeorm": "^11.0.0",
"@types/passport-jwt": "^4.0.1",
"axios": "^1.3.1",
"body-parser": "^1.20.3",
Expand All @@ -61,9 +61,9 @@
},
"devDependencies": {
"@golevelup/ts-jest": "^0.6.1",
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^11.0.2",
"@nestjs/testing": "^10.4.6",
"@nestjs/cli": "^11.0.16",
"@nestjs/schematics": "^11.0.9",
"@nestjs/testing": "^11.1.12",
"@types/body-parser": "^1",
"@types/express": "^4.17.13",
"@types/jest": "30.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export class SnakeCaseInterceptor implements NestInterceptor {
}

if (request.query) {
request.query = transformKeysFromSnakeToCamel(request.query);
const transformedQuery = transformKeysFromSnakeToCamel(request.query);
Object.defineProperty(request, 'query', {
value: transformedQuery,
configurable: true,
enumerable: true,
writable: true,
});
}

return next
Expand Down
18 changes: 9 additions & 9 deletions packages/apps/fortune/recording-oracle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"dependencies": {
"@human-protocol/logger": "workspace:*",
"@human-protocol/sdk": "workspace:*",
"@nestjs/axios": "^3.1.2",
"@nestjs/common": "^10.2.7",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^11.1.9",
"@nestjs/platform-express": "^10.3.10",
"@nestjs/swagger": "^7.4.2",
"@nestjs/axios": "^4.0.1",
"@nestjs/common": "^11.1.12",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.12",
"@nestjs/platform-express": "^11.1.12",
"@nestjs/swagger": "^11.2.5",
"axios": "^1.3.1",
"body-parser": "^1.20.2",
"class-transformer": "^0.5.1",
Expand All @@ -43,9 +43,9 @@
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^11.0.2",
"@nestjs/testing": "^10.4.6",
"@nestjs/cli": "^11.0.16",
"@nestjs/schematics": "^11.0.9",
"@nestjs/testing": "^11.1.12",
"@types/express": "^4.17.13",
"@types/node": "^22.15.16",
"eslint": "^9.39.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export class SnakeCaseInterceptor implements NestInterceptor {
}

if (request.query) {
request.query = transformKeysFromSnakeToCamel(request.query);
const transformedQuery = transformKeysFromSnakeToCamel(request.query);
Object.defineProperty(request, 'query', {
value: transformedQuery,
configurable: true,
enumerable: true,
writable: true,
});
}

return next
Expand Down
29 changes: 15 additions & 14 deletions packages/apps/human-app/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,37 @@
"@human-protocol/core": "workspace:*",
"@human-protocol/logger": "workspace:*",
"@human-protocol/sdk": "workspace:*",
"@nestjs/axios": "^3.1.2",
"@nestjs/cache-manager": "^2.2.1",
"@nestjs/common": "^10.2.7",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^11.1.9",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.3.10",
"@nestjs/schedule": "^4.0.1",
"@nestjs/swagger": "^7.4.2",
"@keyv/redis": "^5.1.5",
"@nestjs/axios": "^4.0.1",
"@nestjs/cache-manager": "^3.1.0",
"@nestjs/common": "^11.1.12",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.12",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.1.12",
"@nestjs/schedule": "^6.1.0",
"@nestjs/swagger": "^11.2.5",
"@nestjs/terminus": "^11.0.0",
"@types/passport-jwt": "^4.0.1",
"axios": "^1.7.2",
"cache-manager": "^5.4.0",
"cache-manager-redis-yet": "^5.1.5",
"cache-manager": "7.2.8",
"class-transformer": "^0.5.1",
"class-validator": "0.14.1",
"ethers": "^6.15.0",
"joi": "^17.13.3",
"jsonwebtoken": "^9.0.2",
"jwt-decode": "^4.0.0",
"keyv": "^5.5.5",
"lodash": "^4.17.21",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^11.0.2",
"@nestjs/testing": "^10.4.6",
"@nestjs/cli": "^11.0.16",
"@nestjs/schematics": "^11.0.9",
"@nestjs/testing": "^11.1.12",
"@types/express": "^4.17.13",
"@types/jest": "30.0.0",
"@types/jsonwebtoken": "^9.0.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import KeyvRedis, { Keyv } from '@keyv/redis';
import { CacheModuleAsyncOptions } from '@nestjs/cache-manager';
import { ConfigModule } from '@nestjs/config';
import { redisStore } from 'cache-manager-redis-yet';
import _ from 'lodash';
import logger from '../../logger';
import { EnvironmentConfigService } from './environment-config.service';
Expand All @@ -16,7 +16,7 @@ export const CacheFactoryConfig: CacheModuleAsyncOptions = {
isGlobal: true,
imports: [ConfigModule],
useFactory: async (configService: EnvironmentConfigService) => {
const store = await redisStore({
const redisAdapter = new KeyvRedis({
socket: {
host: configService.cacheHost,
port: configService.cachePort,
Expand All @@ -25,10 +25,17 @@ export const CacheFactoryConfig: CacheModuleAsyncOptions = {
disableOfflineQueue: true,
});

store.client.on('error', throttledRedisErrorLog);
redisAdapter.on('error', throttledRedisErrorLog);
redisAdapter.client?.on?.('error', throttledRedisErrorLog);

const keyvStore = new Keyv({
store: redisAdapter,
namespace: undefined,
useKeyPrefix: false,
});

return {
store: () => store,
stores: [keyvStore],
};
},
inject: [EnvironmentConfigService],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import {
NestInterceptor,
ExecutionContext,
CallHandler,
BadRequestException,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { plainToInstance, ClassConstructor } from 'class-transformer';
import { validateSync } from 'class-validator';
import 'reflect-metadata';

@Injectable()
Expand All @@ -29,7 +27,13 @@ export class TransformEnumInterceptor implements NestInterceptor {

// Transform and validate enums in the query (for GET requests)
if (query) {
request.query = this.transformEnums(query, targetClass);
const transformedQuery = this.transformEnums(query, targetClass);
Object.defineProperty(request, 'query', {
value: transformedQuery,
configurable: true,
enumerable: true,
writable: true,
});
}
}

Expand Down Expand Up @@ -60,22 +64,13 @@ export class TransformEnumInterceptor implements NestInterceptor {
targetClass: ClassConstructor<any>,
): any {
// Convert the body or query to an instance of the target class
let transformedInstance = plainToInstance(targetClass, bodyOrQuery);

// Transform the enums before validation
transformedInstance = this.lowercaseEnumProperties(
const transformedInstance = this.lowercaseEnumProperties(
bodyOrQuery,
transformedInstance,
plainToInstance(targetClass, bodyOrQuery),
targetClass,
);

// Validate the transformed data
const validationErrors = validateSync(transformedInstance);
if (validationErrors.length > 0) {
throw new BadRequestException('Validation failed');
}

return bodyOrQuery;
return transformedInstance;
}

private lowercaseEnumProperties(
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/human-app/server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function bootstrap() {
const port = envConfigService.port;
if (envConfigService.isCacheToRestart) {
const cacheManager: Cache = app.get<Cache>(CACHE_MANAGER);
await cacheManager.reset();
await cacheManager.clear();
}

app.useGlobalPipes(new ValidationPipe({ transform: true }));
Expand Down
26 changes: 13 additions & 13 deletions packages/apps/job-launcher/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
"@google-cloud/vision": "^4.3.2",
"@human-protocol/logger": "workspace:*",
"@human-protocol/sdk": "workspace:*",
"@nestjs/axios": "^3.1.2",
"@nestjs/common": "^10.2.7",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^11.1.9",
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.3.10",
"@nestjs/schedule": "^4.0.1",
"@nestjs/swagger": "^7.4.2",
"@nestjs/axios": "^4.0.1",
"@nestjs/common": "^11.1.12",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.1.12",
"@nestjs/jwt": "^11.0.2",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.1.12",
"@nestjs/schedule": "^6.1.0",
"@nestjs/swagger": "^11.2.5",
"@nestjs/terminus": "^11.0.0",
"@nestjs/throttler": "^6.5.0",
"@nestjs/typeorm": "^10.0.1",
"@nestjs/typeorm": "^11.0.0",
"@sendgrid/mail": "^8.1.3",
"@types/passport-jwt": "^4.0.1",
"@types/uuid": "^10.0.0",
Expand Down Expand Up @@ -76,9 +76,9 @@
"devDependencies": {
"@faker-js/faker": "^9.8.0",
"@golevelup/ts-jest": "^0.6.1",
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^11.0.2",
"@nestjs/testing": "^10.4.6",
"@nestjs/cli": "^11.0.16",
"@nestjs/schematics": "^11.0.9",
"@nestjs/testing": "^11.1.12",
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.13",
"@types/jest": "30.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ export class SnakeCaseInterceptor implements NestInterceptor {
}

if (request.query) {
request.query = transformKeysFromSnakeToCamel(request.query);
const transformedQuery = transformKeysFromSnakeToCamel(request.query);
Object.defineProperty(request, 'query', {
value: transformedQuery,
configurable: true,
enumerable: true,
writable: true,
});
}

return next.handle().pipe(
Expand Down
Loading
Loading