Skip to content

Commit 58cf32e

Browse files
committed
refactor: remove unnecessary type assertions in service files and improve context initialization in frontend
1 parent 649e94f commit 58cf32e

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

apps/backend/src/auth/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class AuthService {
215215
}
216216

217217
public async getUserFromToken(token: string): Promise<UserDocument | null> {
218-
const decoded = this.jwtService.decode(token) as TokenPayload;
218+
const decoded = this.jwtService.decode(token);
219219

220220
if (!decoded) {
221221
return null;

apps/backend/src/song/song.service.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ describe('SongService', () => {
455455
uploader: 'different-user-id'
456456
} as any;
457457

458-
jest.spyOn(songModel, 'findOne').mockReturnValue(songEntity as any);
458+
jest.spyOn(songModel, 'findOne').mockReturnValue(songEntity);
459459

460460
await expect(service.patchSong(publicId, body, user)).rejects.toThrow(
461461
HttpException
@@ -536,7 +536,7 @@ describe('SongService', () => {
536536
customInstruments: []
537537
} as any;
538538

539-
jest.spyOn(songModel, 'findOne').mockReturnValue(songEntity as any);
539+
jest.spyOn(songModel, 'findOne').mockReturnValue(songEntity);
540540

541541
await expect(service.patchSong(publicId, body, user)).rejects.toThrow(
542542
HttpException
@@ -638,7 +638,7 @@ describe('SongService', () => {
638638
...songDocument
639639
};
640640

641-
jest.spyOn(songModel, 'findOne').mockReturnValue(mockFindOne as any);
641+
jest.spyOn(songModel, 'findOne').mockReturnValue(mockFindOne);
642642

643643
const result = await service.getSong(publicId, user);
644644

@@ -655,7 +655,7 @@ describe('SongService', () => {
655655

656656
const mockFindOne = null;
657657

658-
jest.spyOn(songModel, 'findOne').mockReturnValue(mockFindOne as any);
658+
jest.spyOn(songModel, 'findOne').mockReturnValue(mockFindOne);
659659

660660
await expect(service.getSong(publicId, user)).rejects.toThrow(
661661
HttpException

apps/backend/src/user/user.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class UserService {
3030
try {
3131
return (await this.userModel.findByIdAndUpdate(user._id, user, {
3232
new: true // return the updated document
33-
})) as UserDocument;
33+
}));
3434
} catch (error) {
3535
if (error instanceof Error) {
3636
throw error;

apps/frontend/src/modules/browse/components/client/context/HomePage.context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { RecentSongsProvider } from './RecentSongs.context';
99
type HomePageContextType = null;
1010

1111
const HomePageContext = createContext<HomePageContextType>(
12-
null as HomePageContextType
12+
null
1313
);
1414

1515
export function HomePageProvider({

apps/frontend/src/modules/my-songs/components/client/MySongsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const SongRows = ({
4949

5050
const content = !page
5151
? Array(pageSize).fill(null)
52-
: (page.content as SongPreviewDtoType[]);
52+
: (page.content);
5353

5454
return (
5555
<>

0 commit comments

Comments
 (0)