Skip to content

Conversation

@tomast1337
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses various TypeScript typechecking issues in the backend codebase by:

  • Upgrading Next.js from 16.0.8 to 16.0.10
  • Removing unnecessary @nbw/database dependency from @nbw/song package
  • Adding TypeScript configuration options for better type checking
  • Creating type declarations for the @nbw/thumbnail/node module
  • Fixing test assertions and mock configurations
  • Correcting OAuth strategy configurations

Changes:

  • Updated Next.js and related dependencies to version 16.0.10
  • Added moduleResolution: "node" and noEmit: true to backend tsconfig.json
  • Created type declaration file for @nbw/thumbnail/node module
  • Fixed test mocks to use jest.spyOn instead of direct mock manipulation
  • Changed toThrowError to toThrow in multiple test files
  • Fixed GitHub strategy configuration from redirect_uri to callbackURL
  • Added type assertions to resolve type incompatibilities

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
bun.lock Updated Next.js from 16.0.8 to 16.0.10 and removed @nbw/database dependency from @nbw/song
apps/backend/tsconfig.json Added moduleResolution and noEmit compiler options
apps/backend/src/types/thumbnail.d.ts Created type declarations for @nbw/thumbnail/node module
apps/backend/src/song/song.service.spec.ts Changed mock setup to use jest.spyOn
apps/backend/src/song/song.controller.spec.ts Added explicit type casting with as unknown as
apps/backend/src/song/song.controller.ts Added conditional check for sortField
apps/backend/src/lib/GetRequestUser.spec.ts Changed toThrowError to toThrow
apps/backend/src/auth/strategies/google.strategy.spec.ts Changed toThrowError to toThrow
apps/backend/src/auth/strategies/github.strategy.ts Fixed callbackURL property and added any cast
apps/backend/src/auth/strategies/github.strategy.spec.ts Changed toThrowError to toThrow
apps/backend/src/auth/strategies/discord.strategy/index.ts Added const assertion to prompt property
apps/backend/src/auth/strategies/discord.strategy/discord.strategy.spec.ts Changed toThrowError to toThrow
apps/backend/src/auth/strategies/JWT.strategy.spec.ts Changed toThrowError to toThrow
apps/backend/src/auth/auth.service.ts Added type casts for JWT payload and options
apps/backend/src/auth/auth.service.spec.ts Added explicit parameter type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +135 to +137
const sortField = query.sort
? sortFieldMap.get(query.sort) ?? 'createdAt'
: 'createdAt';
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional check query.sort ? sortFieldMap.get(query.sort) ?? 'createdAt' : 'createdAt' is redundant. The original code sortFieldMap.get(query.sort) ?? 'createdAt' already handles the case where query.sort is undefined or null correctly, since Map.get(undefined) returns undefined and the nullish coalescing operator (??) will fall back to 'createdAt'. The added ternary check doesn't add value and makes the code more verbose.

Suggested change
const sortField = query.sort
? sortFieldMap.get(query.sort) ?? 'createdAt'
: 'createdAt';
const sortField = sortFieldMap.get(query.sort) ?? 'createdAt';

Copilot uses AI. Check for mistakes.
Comment on lines +174 to +187
this.jwtService.signAsync(
payload as object,
{
secret: this.JWT_SECRET,
expiresIn: this.JWT_EXPIRES_IN,
} as any,
),
this.jwtService.signAsync(
payload as object,
{
secret: this.JWT_REFRESH_SECRET,
expiresIn: this.JWT_REFRESH_EXPIRES_IN,
} as any,
),
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast payload as object is unnecessary since TokenPayload is already an object type with defined properties. This cast reduces type safety without providing benefit. Similarly, casting the options object to any masks potential type issues with the JWT service configuration. Consider reviewing the JWT service types to ensure proper type compatibility rather than using type assertions.

Copilot uses AI. Check for mistakes.
Comment on lines 22 to +28
super({
clientID: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET,
redirect_uri: `${SERVER_URL}/v1/auth/github/callback`,
callbackURL: `${SERVER_URL}/v1/auth/github/callback`,
scope: 'user:read,user:email',
state: false,
});
} as any);
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from redirect_uri to callbackURL is correct and fixes a typo in the configuration property name. However, casting the entire configuration object to any masks other potential type issues. Consider checking the passport-github types to ensure all configuration properties are correctly typed rather than bypassing type checking with as any.

Copilot uses AI. Check for mistakes.

mockSongModel.aggregate.mockReturnValue(mockAggregate as any);
mockSongModel.populate.mockResolvedValue(songList);
jest.spyOn(songModel, 'aggregate').mockReturnValue(mockAggregate as any);
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test setup now uses jest.spyOn(songModel, 'aggregate') but the assertions still reference mockSongModel.aggregate and mockSongModel.populate. Since songModel is injected from the mocked mockSongModel, the assertions should be updated to use songModel instead of mockSongModel for consistency, or the spy should be on mockSongModel.

Copilot uses AI. Check for mistakes.

mockSongModel.aggregate.mockReturnValue(mockAggregate as any);
mockSongModel.populate.mockResolvedValue(songList);
jest.spyOn(songModel, 'aggregate').mockReturnValue(mockAggregate as any);
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous test, the setup uses jest.spyOn(songModel, 'aggregate') but the assertions reference mockSongModel.aggregate and mockSongModel.populate. The assertions should be updated to use songModel for consistency with the spy setup.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants