Skip to content

Commit

Permalink
remove app id middleware for collections
Browse files Browse the repository at this point in the history
in favor of having app id in the route
  • Loading branch information
michavie committed Jan 9, 2024
1 parent f5bcd83 commit 478f1c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
6 changes: 3 additions & 3 deletions apps/api/src/endpoints/collections/collections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApiResponse } from '@nestjs/swagger'
import { AppService } from '@mvx-monorepo/common'
import { DataValue } from './entities/data.value'
import { DelegationService } from '@mvx-monorepo/common/delegation'
import { Controller, Get, Headers, NotFoundException, Param } from '@nestjs/common'
import { Controller, Get, NotFoundException, Param } from '@nestjs/common'

@Controller()
export class CollectionsController {
Expand All @@ -21,10 +21,10 @@ export class CollectionsController {
}

// TODO: @UseGuards(NativeAuthGuard)
@Get('/collections/:collection')
@Get('apps/:appid/collections/:collection')
@ApiResponse({ status: 200 })
@ApiResponse({ status: 404 })
async show(@Param('collection') key: string, @Headers('app-id') appId: number) {
async show(@Param('appid') appId: string, @Param('collection') key: string) {
const app = await this.appService.getAppById(+appId)

if (!app) {
Expand Down
16 changes: 0 additions & 16 deletions apps/api/src/middleware/app-id.middleware.ts

This file was deleted.

8 changes: 2 additions & 6 deletions apps/api/src/public.app.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { Module, NestModule } from '@nestjs/common'
import { DynamicModuleUtils } from '@mvx-monorepo/common'
import { LoggingModule } from '@multiversx/sdk-nestjs-common'
import { AppIdMiddleware } from './middleware/app-id.middleware'
import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common'
import { EndpointsServicesModule } from './endpoints/endpoints.services.module'
import { EndpointsControllersModule } from './endpoints/endpoints.controllers.module'
import { CollectionsController } from './endpoints/collections/collections.controller'

@Module({
imports: [LoggingModule, EndpointsServicesModule, EndpointsControllersModule],
providers: [DynamicModuleUtils.getNestJsApiConfigService()],
exports: [EndpointsServicesModule],
})
export class PublicAppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(AppIdMiddleware).forRoutes(CollectionsController)
}
configure() {}
}

0 comments on commit 478f1c2

Please sign in to comment.