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
4 changes: 4 additions & 0 deletions config/config.devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ features:
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
mediaRedirect:
enabled: false
storageUrls:
- 'https://s3.amazonaws.com/media.elrond.com'
auth:
enabled: false
maxExpirySeconds: 86400
Expand Down
4 changes: 4 additions & 0 deletions config/config.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ features:
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
mediaRedirect:
enabled: false
storageUrls:
- 'https://s3.amazonaws.com/media.elrond.com'
image:
width: 600
height: 600
Expand Down
4 changes: 4 additions & 0 deletions config/config.testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ features:
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
mediaRedirect:
enabled: false
storageUrls:
- 'https://s3.amazonaws.com/media.elrond.com'
image:
width: 600
height: 600
Expand Down
130 changes: 67 additions & 63 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@
"@golevelup/nestjs-rabbitmq": "^4.0.0",
"@multiversx/sdk-core": "^13.2.2",
"@multiversx/sdk-data-api-client": "^0.7.0",
"@multiversx/sdk-nestjs-auth": "4.0.1",
"@multiversx/sdk-nestjs-cache": "4.0.1",
"@multiversx/sdk-nestjs-common": "4.0.1",
"@multiversx/sdk-nestjs-elastic": "^4.0.1",
"@multiversx/sdk-nestjs-http": "4.0.1",
"@multiversx/sdk-nestjs-monitoring": "4.0.1",
"@multiversx/sdk-nestjs-rabbitmq": "4.0.1",
"@multiversx/sdk-nestjs-redis": "4.0.1",
"@multiversx/sdk-nestjs-auth": "4.2.0",
"@multiversx/sdk-nestjs-cache": "4.2.0",
"@multiversx/sdk-nestjs-common": "4.2.0",
"@multiversx/sdk-nestjs-elastic": "^4.2.0",
"@multiversx/sdk-nestjs-http": "4.2.0",
"@multiversx/sdk-nestjs-monitoring": "4.2.0",
"@multiversx/sdk-nestjs-rabbitmq": "4.2.0",
"@multiversx/sdk-nestjs-redis": "4.2.0",
"@multiversx/sdk-wallet": "^4.0.0",
"@nestjs/apollo": "12.0.11",
"@nestjs/common": "10.2.0",
Expand Down
8 changes: 8 additions & 0 deletions src/common/api-config/api.config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,4 +912,12 @@ export class ApiConfigService {
getCacheDuration(): number {
return this.configService.get<number>('caching.cacheDuration') ?? 3;
}

isMediaRedirectFeatureEnabled(): boolean {
return this.configService.get<boolean>('features.mediaRedirect.enabled') ?? false;
}

getMediaRedirectFileStorageUrls(): string[] {
return this.configService.get<string[]>('features.mediaRedirect.storageUrls') ?? [];
}
}
2 changes: 2 additions & 0 deletions src/endpoints/endpoints.controllers.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { PoolController } from "./pool/pool.controller";
import { TpsController } from "./tps/tps.controller";
import { ApplicationController } from "./applications/application.controller";
import { EventsController } from "./events/events.controller";
import { MediaController } from "./media/media.controller";

@Module({})
export class EndpointsControllersModule {
Expand All @@ -50,6 +51,7 @@ export class EndpointsControllersModule {
TokenController, TransactionController, UsernameController, VmQueryController, WaitingListController,
HealthCheckController, DappConfigController, WebsocketController, TransferController,
ProcessNftsPublicController, TransactionsBatchController, ApplicationController, EventsController,
MediaController,
];

const isMarketplaceFeatureEnabled = configuration().features?.marketplace?.enabled ?? false;
Expand Down
4 changes: 3 additions & 1 deletion src/endpoints/endpoints.services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { PoolModule } from "./pool/pool.module";
import { TpsModule } from "./tps/tps.module";
import { ApplicationModule } from "./applications/application.module";
import { EventsModule } from "./events/events.module";
import { MediaModule } from "./media/media.module";

@Module({
imports: [
Expand Down Expand Up @@ -77,13 +78,14 @@ import { EventsModule } from "./events/events.module";
TpsModule,
ApplicationModule,
EventsModule,
MediaModule,
],
exports: [
AccountModule, CollectionModule, BlockModule, DelegationModule, DelegationLegacyModule, IdentitiesModule, KeysModule,
MiniBlockModule, NetworkModule, NftModule, NftMediaModule, TagModule, NodeModule, ProviderModule,
RoundModule, SmartContractResultModule, ShardModule, StakeModule, TokenModule, RoundModule, TransactionModule, UsernameModule, VmQueryModule,
WaitingListModule, EsdtModule, BlsModule, DappConfigModule, TransferModule, PoolModule, TransactionActionModule, WebsocketModule, MexModule,
ProcessNftsModule, NftMarketplaceModule, TransactionsBatchModule, TpsModule, ApplicationModule, EventsModule,
ProcessNftsModule, NftMarketplaceModule, TransactionsBatchModule, TpsModule, ApplicationModule, EventsModule, MediaModule,
],
})
export class EndpointsServicesModule { }
28 changes: 28 additions & 0 deletions src/endpoints/media/media.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Controller, Get, NotFoundException, Param, Res } from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { Response } from "express";
import { MediaService } from "./media.service";

@Controller()
@ApiTags('media')
export class MediaController {
constructor(
private readonly mediaService: MediaService,
) { }

@Get("/media/:uri(*)")
async redirectToMediaUri(
@Param('uri') uri: string,
@Res() response: Response
) {
const redirectUrl = await this.mediaService.getRedirectUrl(uri);
if (!redirectUrl) {
throw new NotFoundException('Not found');
}

response.statusMessage = 'Found';
response.setHeader('location', redirectUrl);
response.setHeader('cache-control', 'max-age=60');
return response.redirect(redirectUrl);
}
}
13 changes: 13 additions & 0 deletions src/endpoints/media/media.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from "@nestjs/common";
import { MediaService } from "./media.service";

@Module({
imports: [],
providers: [
MediaService,
],
exports: [
MediaService,
],
})
export class MediaModule { }
Loading