Skip to content

Commit

Permalink
refactor(controllers): remove cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Iqro-dev authored and Mnigos committed Dec 27, 2024
1 parent bd3bc62 commit ef97ea7
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 115 deletions.
8 changes: 1 addition & 7 deletions src/modules/history/router/history.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getQueueToken } from '@nestjs/bullmq'
import { DeepMockProxy, mockDeep } from 'vitest-mock-extended'
import { PaginateQuery } from 'nestjs-paginate'
import { MockInstance } from 'vitest'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { HistoryQueueEvents } from '../history.queue-events'

Expand Down Expand Up @@ -72,12 +71,7 @@ describe('HistoryController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

historyController = moduleRef.get(HistoryController)
historyQueue = moduleRef.get(getQueueToken(HISTORY_QUEUE))
Expand Down
5 changes: 1 addition & 4 deletions src/modules/history/router/history.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, UseGuards, UseInterceptors } from '@nestjs/common'
import { Controller, Get, UseGuards } from '@nestjs/common'
import { ApiOperation, ApiTags } from '@nestjs/swagger'
import { Queue } from 'bullmq'
import {
Expand All @@ -8,7 +8,6 @@ import {
PaginatedSwaggerDocs,
paginate,
} from 'nestjs-paginate'
import { CacheInterceptor, CacheTTL } from '@nestjs/cache-manager'

import { HistoryQueueEvents } from '../history.queue-events'
import { InjectHistoryQueue } from '../decorators'
Expand All @@ -31,8 +30,6 @@ export const historyTracksPaginateConfig: PaginateConfig<HistoryTrack> = {
@Controller('users/:id/history')
@ApiTags('users/{id}/history')
@UseGuards(ValidateUserIdGuard)
@UseInterceptors(CacheInterceptor)
@CacheTTL(30)
@ApiAuth()
export class HistoryController {
constructor(
Expand Down
8 changes: 1 addition & 7 deletions src/modules/items/albums/albums.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'
import { NotFoundException } from '@nestjs/common'
import { PaginateQuery } from 'nestjs-paginate'
import { MockInstance } from 'vitest'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { AlbumsController } from './albums.controller'
import { AlbumsRepository } from './albums.repository'
Expand All @@ -29,12 +28,7 @@ describe('AlbumsController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

albumsController = moduleRef.get(AlbumsController)
albumsRepository = moduleRef.get(AlbumsRepository)
Expand Down
3 changes: 0 additions & 3 deletions src/modules/items/albums/albums.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
NotFoundException,
Param,
ParseUUIDPipe,
UseInterceptors,
} from '@nestjs/common'
import {
ApiBadRequestResponse,
Expand All @@ -21,7 +20,6 @@ import {
PaginatedSwaggerDocs,
paginate,
} from 'nestjs-paginate'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { AlbumsRepository } from './albums.repository'
import { AlbumBaseDocument, AlbumDocument } from './docs'
Expand All @@ -44,7 +42,6 @@ export const albumsPaginateConfig: PaginateConfig<Album> = {
}

@Controller('albums')
@UseInterceptors(CacheInterceptor)
@ApiTags('albums')
export class AlbumsController {
constructor(private readonly albumsRepository: AlbumsRepository) {}
Expand Down
8 changes: 1 addition & 7 deletions src/modules/items/artists/router/artists.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'
import { NotFoundException } from '@nestjs/common'
import { PaginateQuery } from 'nestjs-paginate'
import { MockInstance } from 'vitest'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { ArtistsRepository } from '../artists.repository'

Expand Down Expand Up @@ -54,12 +53,7 @@ describe('ArtistsController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

artistsController = moduleRef.get(ArtistsController)
artistsRepository = moduleRef.get(ArtistsRepository)
Expand Down
3 changes: 0 additions & 3 deletions src/modules/items/artists/router/artists.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Param,
ParseUUIDPipe,
Query,
UseInterceptors,
} from '@nestjs/common'
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
import {
Expand All @@ -15,7 +14,6 @@ import {
PaginatedSwaggerDocs,
paginate,
} from 'nestjs-paginate'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { ArtistsRepository } from '../artists.repository'
import { Artist } from '../artist.entity'
Expand All @@ -38,7 +36,6 @@ export const artistsPaginateConfig: PaginateConfig<Artist> = {
}

@Controller('artists')
@UseInterceptors(CacheInterceptor)
@ApiTags('artists')
export class ArtistsController {
constructor(
Expand Down
8 changes: 1 addition & 7 deletions src/modules/items/tracks/tracks.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'
import { NotFoundException } from '@nestjs/common'
import { PaginateQuery } from 'nestjs-paginate'
import { MockInstance } from 'vitest'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { TracksController } from './tracks.controller'
import { TracksRepository } from './tracks.repository'
Expand Down Expand Up @@ -30,12 +29,7 @@ describe('TracksController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

tracksController = moduleRef.get(TracksController)
tracksRepository = moduleRef.get(TracksRepository)
Expand Down
3 changes: 0 additions & 3 deletions src/modules/items/tracks/tracks.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
NotFoundException,
Param,
ParseUUIDPipe,
UseInterceptors,
} from '@nestjs/common'
import {
ApiBadRequestResponse,
Expand All @@ -21,7 +20,6 @@ import {
PaginatedSwaggerDocs,
paginate,
} from 'nestjs-paginate'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { TracksRepository } from './tracks.repository'
import { TrackBaseDocument, TrackDocument } from './docs'
Expand All @@ -43,7 +41,6 @@ export const tracksPaginateConfig: PaginateConfig<Track> = {
}

@Controller('tracks')
@UseInterceptors(CacheInterceptor)
@ApiTags('tracks')
export class TracksController {
constructor(private readonly tracksRepository: TracksRepository) {}
Expand Down
8 changes: 1 addition & 7 deletions src/modules/reports/router/reports.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Test, type TestingModule } from '@nestjs/testing'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { ReportsService } from '../reports.service'

Expand Down Expand Up @@ -43,12 +42,7 @@ describe('ReportsController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

reportsController = moduleRef.get(ReportsController)
reportsService = moduleRef.get(ReportsService)
Expand Down
10 changes: 1 addition & 9 deletions src/modules/reports/router/reports.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import { CacheInterceptor } from '@nestjs/cache-manager'
import {
Controller,
Get,
Query,
UseGuards,
UseInterceptors,
} from '@nestjs/common'
import { Controller, Get, Query, UseGuards } from '@nestjs/common'
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'

import { ReportsService } from '../reports.service'
Expand Down Expand Up @@ -35,7 +28,6 @@ import { StatsMeasurement } from '@modules/stats/enums'
@Controller('/users/:id/reports')
@ApiTags('users/{id}/reports')
@UseGuards(ValidateUserIdGuard, TimeRangeGuard)
@UseInterceptors(CacheInterceptor)
@ApiAuth()
@ApiUser()
export class ReportsController {
Expand Down
8 changes: 1 addition & 7 deletions src/modules/stats/router/stats-rigtch.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing'
import { MockInstance } from 'vitest'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { StatsRigtchService } from '../stats-rigtch.service'
import { StatsMeasurement } from '../enums'
Expand Down Expand Up @@ -39,12 +38,7 @@ describe('StatsRigtchController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

statsRigtchController = moduleRef.get(StatsRigtchController)
statsRigtchService = moduleRef.get(StatsRigtchService)
Expand Down
10 changes: 1 addition & 9 deletions src/modules/stats/router/stats-rigtch.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import { CacheInterceptor } from '@nestjs/cache-manager'
import {
Controller,
Get,
Query,
UseGuards,
UseInterceptors,
} from '@nestjs/common'
import { Controller, Get, Query, UseGuards } from '@nestjs/common'
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'

import { StatsMeasurement } from '../enums'
Expand All @@ -30,7 +23,6 @@ import { ValidateUserIdGuard } from '@modules/users/guards'
@Controller('/users/:id/stats/rigtch')
@ApiTags('users/{id}/stats/rigtch')
@UseGuards(ValidateUserIdGuard, TimeRangeGuard)
@UseInterceptors(CacheInterceptor)
@ApiAuth()
@ApiStatsRigtchQuery()
@ApiUser()
Expand Down
8 changes: 1 addition & 7 deletions src/modules/stats/router/stats-spotify.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CacheInterceptor } from '@nestjs/cache-manager'
import { Test, TestingModule } from '@nestjs/testing'
import type { MockInstance } from 'vitest'

Expand Down Expand Up @@ -61,12 +60,7 @@ describe('UsersProfileController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

statsSpotifyController = moduleRef.get(StatsSpotifyController)
spotifyService = moduleRef.get(SpotifyService)
Expand Down
10 changes: 1 addition & 9 deletions src/modules/stats/router/stats-spotify.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
Controller,
Get,
Query,
UseGuards,
UseInterceptors,
} from '@nestjs/common'
import { Controller, Get, Query, UseGuards } from '@nestjs/common'
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
import { CacheInterceptor } from '@nestjs/cache-manager'
import { AccessToken } from '@spotify/web-api-ts-sdk'

import { ApiAuth, RequestToken } from '@common/decorators'
Expand All @@ -25,7 +18,6 @@ import { TopItemQuery } from '@modules/users/dtos'
@Controller('/users/:id/stats/spotify')
@ApiTags('users/{id}/stats/spotify')
@UseGuards(ValidateUserIdGuard, TokenGuard)
@UseInterceptors(CacheInterceptor)
@ApiAuth()
@ApiUser()
export class StatsSpotifyController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CacheInterceptor } from '@nestjs/cache-manager'
import { Test, TestingModule } from '@nestjs/testing'
import { MockInstance } from 'vitest'

Expand Down Expand Up @@ -72,12 +71,7 @@ describe('UsersProfileController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

usersProfileController = moduleRef.get(UsersProfileController)
spotifyService = moduleRef.get(SpotifyService)
Expand Down
13 changes: 1 addition & 12 deletions src/modules/users/controllers/users-profile.controller.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import {
Controller,
Get,
Query,
UseGuards,
UseInterceptors,
} from '@nestjs/common'
import { Controller, Get, Query, UseGuards } from '@nestjs/common'
import { ApiOperation, ApiOkResponse, ApiTags } from '@nestjs/swagger'
import { AccessToken } from '@spotify/web-api-ts-sdk'
import { CacheInterceptor } from '@nestjs/cache-manager'

import { ApiItemQuery, ApiUser, RequestUser } from '../decorators'
import { LastItemQuery, TopItemQuery } from '../dtos'
Expand Down Expand Up @@ -66,7 +59,6 @@ export class UsersProfileController {
}

@Get('top/artists')
@UseInterceptors(CacheInterceptor)
@ApiOperation({
summary: "Getting user's top artists (cached).",
deprecated: true,
Expand Down Expand Up @@ -101,7 +93,6 @@ export class UsersProfileController {
}

@Get('top/tracks')
@UseInterceptors(CacheInterceptor)
@ApiOperation({
summary: "Getting user's top tracks (cached).",
deprecated: true,
Expand Down Expand Up @@ -136,7 +127,6 @@ export class UsersProfileController {
}

@Get('top/genres')
@UseInterceptors(CacheInterceptor)
@ApiOperation({
summary: "Getting user's top genres (cached).",
deprecated: true,
Expand All @@ -159,7 +149,6 @@ export class UsersProfileController {
}

@Get('analysis')
@UseInterceptors(CacheInterceptor)
@ApiOperation({
summary: "Getting user's analysis (cached).",
deprecated: true,
Expand Down
8 changes: 1 addition & 7 deletions src/modules/users/controllers/users.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CacheInterceptor } from '@nestjs/cache-manager'
import { Test, TestingModule } from '@nestjs/testing'
import { MockInstance } from 'vitest'

Expand Down Expand Up @@ -67,12 +66,7 @@ describe('UsersController', () => {
},
},
],
})
.overrideInterceptor(CacheInterceptor)
.useValue({
intercept: vi.fn(),
})
.compile()
}).compile()

usersController = moduleRef.get(UsersController)
usersRepository = moduleRef.get(UsersRepository)
Expand Down

0 comments on commit ef97ea7

Please sign in to comment.