Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
c293d30
fix: navbar padding extrapolating max width (`box-sizing: content-box`)
Bentroen Jan 1, 2026
697e29c
fix: thumbnail color buttons missing border transparency
Bentroen Jan 1, 2026
9d20ad8
fix: song upload field icon losing its size
Bentroen Jan 1, 2026
3664c2c
refactor(thumbnail): replace `canvasFactory` with split browser and N…
Bentroen Jan 2, 2026
3694956
fix: noteCount and duration are possibly null in search param assignment
Bentroen Jan 2, 2026
ab54e70
fix: add type import for JSX in CustomMarkdown component
tomast1337 Jan 2, 2026
001a364
feat(search): add SearchLayout component and wrap SearchSongPage in S…
tomast1337 Jan 2, 2026
15b47dc
fix: upgrade `@hookform/resolvers` from 3.10.0 to 5.2.2
Bentroen Jan 2, 2026
0d8199b
fix: upgrade zod schema's `message` field to `error` (deprecated in v4)
Bentroen Jan 2, 2026
d8db8de
fix: add default form values in upload form
Bentroen Jan 2, 2026
98d11ad
refactor: make `errors` access in `formMethods.formState` clearer
Bentroen Jan 2, 2026
fef1d82
chore: move `@napi-rs/canvas` to optional dependencies in bun.lock
Bentroen Jan 2, 2026
e4c0512
chore: sort packages in backend's `package.json`
Bentroen Jan 2, 2026
3bda4b8
fix: add default empty array for custom instruments in upload form
Bentroen Jan 2, 2026
d7832db
fix: reset form and store state when navigating away from upload page
Bentroen Jan 2, 2026
88bb979
fix: split form typings in `Input`/`Output` and call `parse` on form …
Bentroen Jan 3, 2026
c451be0
chore: add setting to use project's TypeScript version instead of bun…
Bentroen Jan 4, 2026
757b729
chore: replace root `tsconfig.json` with `references` field
Bentroen Jan 4, 2026
2720e25
chore: enable `composite` in package-inherited root TS config
Bentroen Jan 4, 2026
16d85c8
chore: rename `tsconfig.build.json` to `tsconfig.json`
Bentroen Jan 4, 2026
b5216a0
chore: review base TS settings in global `tsconfig.base.json`
Bentroen Jan 4, 2026
3c8beda
chore: review base TS settings for packages in `tsconfig.package.json`
Bentroen Jan 4, 2026
01e0984
chore: merge `tsconfig.build.json` into `tsconfig.json` for packages
Bentroen Jan 4, 2026
d5f531d
fix: remove `@database` path alias in database package
Bentroen Jan 4, 2026
2186717
chore: remove `build:types` script from packages and replace with `ts…
Bentroen Jan 4, 2026
bcf7af3
chore: add `typecheck` command to workspace root
Bentroen Jan 4, 2026
2b0eeff
chore: make backend and frontend TS projects `composite` (following r…
Bentroen Jan 4, 2026
67daa09
chore: clean up frontend's `tsconfig.json`
Bentroen Jan 4, 2026
dc7f599
chore: clean up backend's `tsconfig.json`
Bentroen Jan 4, 2026
710d79e
style: add comments and line breaks to frontend/backend tsconfig
Bentroen Jan 4, 2026
b5e6023
style: fully comment settings in base and package `tsconfig.json`
Bentroen Jan 4, 2026
f508b89
chore: add type checking workflow on push and pull request
Bentroen Jan 4, 2026
a011504
chore: add `eslint-import-resolver-typescript` dependency
Bentroen Jan 5, 2026
06dbb5c
chore: add separate TS config for ESLint
Bentroen Jan 5, 2026
2b3c4a7
chore: add `baseUrl` and `@nbw` path alias to root TS config
Bentroen Jan 5, 2026
9faf154
chore: ensure that orchestrator TS config doesn't emit types
Bentroen Jan 5, 2026
79f2bf9
chore: remove `outDir` from base TS config
Bentroen Jan 6, 2026
8498c2f
fix: add `baseUrl` to app TS configs
Bentroen Jan 5, 2026
f85b959
fix: ensure types are emitted in `configs` package through `rootDir` …
Bentroen Jan 5, 2026
ab269fc
fix: enforce `src -> dist` output structure for all packages
Bentroen Jan 5, 2026
4eab8c9
build: re-introduce separate `js` and `types` steps in database build
Bentroen Jan 6, 2026
774326d
chore: ensure TS build cache files are output to `dist`
Bentroen Jan 6, 2026
d148680
chore: let TS infer build cache output location as `dist/`
Bentroen Jan 6, 2026
3dbd11f
fix: incorrect import alias in `database` package
Bentroen Jan 6, 2026
0ca8c47
fix: `thumbnail` package using removed `build:types` script
Bentroen Jan 6, 2026
5d94120
chore: remove `composite` from frontend and backend packages
Bentroen Jan 6, 2026
5e5bf4a
chore: re-add `rootDir` and `tsInfoBuildFile` on package projects
Bentroen Jan 10, 2026
3914f6a
chore: refactor build scripts and improve TypeScript configuration
tomast1337 Jan 10, 2026
8581179
Merge branch 'refactor/tsconfig-cleanup' of github.com:OpenNBS/NoteBl…
tomast1337 Jan 10, 2026
9c75b72
refactor: update imports to use 'type' for TypeScript types in variou…
tomast1337 Jan 10, 2026
b323da5
fix: BlogPageProps and HelpPageProps to use Promise for params
tomast1337 Jan 10, 2026
ddec03c
refactor: refactor search page components into dedicated module
tomast1337 Jan 10, 2026
6b28ef6
Merge branch 'develop' of github.com:OpenNBS/NoteBlockWorld into refa…
tomast1337 Jan 10, 2026
c8dadc6
Merge branch 'develop' of https://github.com/OpenNBS/NoteBlockWorld i…
Bentroen Jan 10, 2026
7536bd7
Fix: update build script to use webpack
tomast1337 Jan 10, 2026
8206099
Merge branch 'develop' of github.com:OpenNBS/NoteBlockWorld into refa…
tomast1337 Jan 10, 2026
8a18083
fix: HelpPost component to handle async params
tomast1337 Jan 10, 2026
696f3f9
fix: update form types and default values in Thumbnail components
tomast1337 Jan 10, 2026
5e5985c
test: Updated AuthController and SongController to test the current c…
tomast1337 Jan 10, 2026
8f6f077
Refactor/Update TypeScript configuration across all packages (#74)
Bentroen Jan 10, 2026
dbfd374
Merge branch 'develop' into fix/test
Bentroen Jan 10, 2026
65bb8ae
chore(deps): bump next from 16.0.8 to 16.0.10 in /apps/frontend
dependabot[bot] Jan 10, 2026
3fa1910
update dev script in package.json to include webpack
tomast1337 Jan 11, 2026
64cdca4
Fix test failures and module resolution issues (#75)
Bentroen Jan 11, 2026
0a9d96f
Merge branch 'develop' into dependabot/npm_and_yarn/apps/frontend/nex…
Bentroen Jan 11, 2026
d9f70ec
chore(deps): bump next.js from 16.0.8 to 16.0.10 (#66)
Bentroen Jan 11, 2026
3eb22fa
fix: adjust shadcn/ui's settings file to use actual project settings
Bentroen Jan 11, 2026
deff809
fix: disable @shadcn/ui styles temporarily
Bentroen Jan 11, 2026
d7d9c75
chore: add `--webpack` flag to `next dev` command
Bentroen Jan 11, 2026
4c2d780
Merge branch 'develop' of https://github.com/OpenNBS/NoteBlockWorld i…
Bentroen Jan 11, 2026
c332eb5
refactor: update TypeScript configurations and improve type handling …
tomast1337 Jan 11, 2026
71f73f1
Merge branch 'develop' of github.com:OpenNBS/NoteBlockWorld into develop
tomast1337 Jan 11, 2026
57c969c
chore(deps): update Next.js and related packages to version 16.0.10
tomast1337 Jan 11, 2026
ed39809
chore: add `@nbw/thumbnail/node` type defs on backend
Bentroen Jan 15, 2026
d34865f
chore(types): change backend's `moduleResolution` to `bundler`
Bentroen Jan 15, 2026
58a90d8
chore(types): remove type definitions for `@nbw/thumbnail/node`
Bentroen Jan 15, 2026
7429301
refactor(types): remove redundant ternary operator in song query `sor…
Bentroen Jan 15, 2026
c5a22d5
refactor(types): remove catch-all types for `jwtService.signAsync` call
Bentroen Jan 15, 2026
8e43122
fix(config): parse duration env configs on startup and coerce to `ms.…
Bentroen Jan 15, 2026
bf1acef
fix(config) use `config.getOrThrow` to simplify logic in `AuthModule`
Bentroen Jan 15, 2026
98c472b
fix(config): validator's `defaultMessage` not being shown on env vali…
Bentroen Jan 15, 2026
ba1d3b9
chore(types): add TODO for improving typing on GitHub login strategy
Bentroen Jan 15, 2026
b25030b
test(song): remove duplicate authorization tests
Bentroen Jan 16, 2026
35a1bda
Typechecking fixes (#77)
Bentroen Jan 16, 2026
04beab8
chore: upgrade tailwindcss to 4.1.18
Bentroen Jan 16, 2026
9d3b891
fix: properly upgrade project to Tailwind CSS v4
Bentroen Jan 16, 2026
29bfcf7
fix: prevent FontAwesome from injecting CSS after load
Bentroen Jan 16, 2026
7a57548
fix: apply Lato font to theme via CSS variable
Bentroen Jan 16, 2026
b521ae6
fix: make buttons use pointer cursor
Bentroen Jan 19, 2026
98fa6ac
chore: delete tailwind.config.js
Bentroen Jan 19, 2026
a8e11d9
chore: remove `autoprefixer` from PostCSS config
Bentroen Jan 19, 2026
f19d1f9
chore: change `postcss.config.js` extension to `.mjs`
Bentroen Jan 19, 2026
9e93de8
refactor: use modern export syntax in PostCSS config
Bentroen Jan 19, 2026
da7f5f6
chore: remove `@shrutibalasa/tailwind-grid-auto-fit` dependency
Bentroen Jan 19, 2026
d2e349f
fix: change font definition from `@layer theme` to `@theme` directive
Bentroen Jan 19, 2026
5dbf95e
fix: re-add `ease-out-back` CSS transition defition
Bentroen Jan 19, 2026
5e47d3d
fix: change icon set from `lucide` to `fontawesome` in @shadcn/ui config
Bentroen Jan 19, 2026
c9c690c
fix: re-add grid auto-fit utility classes
Bentroen Jan 19, 2026
ea0cb6b
fix: mismatched icon size on social login provider icons
Bentroen Jan 19, 2026
3004290
chore: enable suggestions inside strings on VS Code settings
Bentroen Jan 22, 2026
0bbc259
chore: add `globals.css` as config file for Tailwind CSS extension
Bentroen Jan 22, 2026
bff6137
chore: enable Tailwind CSS Intellisense inside utility functions
Bentroen Jan 22, 2026
6a53b7d
fix: add Lato font variable to root html element
Bentroen Jan 22, 2026
1e54464
fix: revert to old slider component in thumbnail editor
Bentroen Jan 22, 2026
673ac51
fix: adjust custom slider element appearance
Bentroen Jan 22, 2026
29a343c
fix: adjust form elements' slider appearance
Bentroen Jan 25, 2026
afbaa79
refactor: replace unused `size` param in `SongCardGroup` with auto-fit
Bentroen Jan 25, 2026
a3308b3
chore: add TODOs related to component standardization
Bentroen Jan 25, 2026
730041f
fix: simplify form label's font size definition
Bentroen Jan 26, 2026
b0ac670
Properly migrate project to Tailwind CSS v4 (#78)
Bentroen Jan 26, 2026
83b6438
chore: add `remove-markdown` to frontend dependencies
Bentroen Jan 26, 2026
7683a31
fix: strip markdown syntax from blog post preview
Bentroen Jan 26, 2026
77ba230
fix: increase blog post preview excerpt's length
Bentroen Jan 26, 2026
c7e1675
fix(blog): Strip Markdown syntax in blog post previews (#79)
Bentroen Jan 26, 2026
134aa10
chore: add section comments on VS Code settings file
Bentroen Jan 26, 2026
3f24932
chore(lint): remove test files from ESLint config
Bentroen Jan 26, 2026
45081d2
fix(ui): add translucent glass effect to navbar and search bar
Bentroen Feb 3, 2026
88bfbeb
fix(ui): pad song card grid to always display minimum number of columns
Bentroen Feb 3, 2026
8791210
fix: don't proxy downloaded songs through backend server
Bentroen Feb 3, 2026
d7899b1
build: fix missing single quote in `start:server` command
Bentroen Feb 3, 2026
cd3ad18
feat(auth): enhance cookie handling and trust proxy settings
tomast1337 Feb 7, 2026
50679dd
Merge branch 'develop' of github.com:OpenNBS/NoteBlockWorld into develop
tomast1337 Feb 7, 2026
fdfb105
fix(auth): update cookie security settings to allow JavaScript access
tomast1337 Feb 7, 2026
dab5c43
fix(auth): refine cookie options for improved security and compatibility
tomast1337 Feb 7, 2026
cb06c19
fix(auth): remove sameSite attribute from cookie options for compatib…
tomast1337 Feb 7, 2026
34d834c
fix(auth): add path option to cookie settings for proper routing
tomast1337 Feb 19, 2026
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
32 changes: 32 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Type Check

on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main

jobs:
typecheck:
runs-on: ubuntu-latest
env:
THUMBNAIL_URL: ${{ vars.THUMBNAIL_URL }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Type check (project references)
run: bun run typecheck
24 changes: 23 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
/***********************************
Linting and formatting settings
**********************************/
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.validate": [
Expand All @@ -13,8 +16,27 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},

/***********************************
Tailwind CSS IntelliSense settings
***********************************/
// Enable suggestions inside strings for Tailwind CSS class names
// https://github.com/tailwindlabs/tailwindcss-intellisense#editorquicksuggestions
"editor.quickSuggestions": {
"strings": "on"
},
"tailwindCSS.experimental.configFile": {
"apps/frontend/src/app/globals.css": "apps/frontend/src/**"
},
"tailwindCSS.classFunctions": ["tw", "clsx", "cn"],
"files.associations": {
".css": "tailwindcss",
"*.scss": "tailwindcss"
}
},

/***********************************
Use the workspace version of TypeScript
***********************************/
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
12 changes: 6 additions & 6 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"@aws-sdk/client-s3": "3.946.0",
"@aws-sdk/s3-request-presigner": "3.946.0",
"@encode42/nbs.js": "^5.0.2",
"@nbw/config": "workspace:*",
"@nbw/database": "workspace:*",
"@nbw/song": "workspace:*",
"@nbw/sounds": "workspace:*",
"@nbw/thumbnail": "workspace:*",
"@nestjs-modules/mailer": "^2.0.2",
"@nestjs/common": "^11.1.9",
"@nestjs/config": "^4.0.2",
Expand Down Expand Up @@ -56,12 +61,7 @@
"rxjs": "^7.8.2",
"uuid": "^13.0.0",
"zod": "^4.1.13",
"zod-validation-error": "^5.0.0",
"@nbw/database": "workspace:*",
"@nbw/song": "workspace:*",
"@nbw/thumbnail": "workspace:*",
"@nbw/sounds": "workspace:*",
"@nbw/config": "workspace:*"
"zod-validation-error": "^5.0.0"
},
"devDependencies": {
"@faker-js/faker": "^10.1.0",
Expand Down
22 changes: 14 additions & 8 deletions apps/backend/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ const build = async () => {
target: 'bun',
minify: false,
sourcemap: 'linked',
external: optionalRequirePackages.filter((pkg) => {
try {
require(pkg);
return false;
} catch (_) {
return true;
}
}),
external: [
...optionalRequirePackages.filter((pkg) => {
try {
require(pkg);
return false;
} catch (_) {
return true;
}
}),
'@nbw/config',
'@nbw/database',
'@nbw/song',
'@nbw/sounds',
],
splitting: true,
});

Expand Down
30 changes: 24 additions & 6 deletions apps/backend/src/auth/auth.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ describe('AuthController', () => {
let authService: AuthService;

beforeEach(async () => {
// Clear all mocks before each test to ensure test isolation
jest.clearAllMocks();

const module: TestingModule = await Test.createTestingModule({
controllers: [AuthController],
providers: [
Expand Down Expand Up @@ -68,8 +71,13 @@ describe('AuthController', () => {

describe('githubLogin', () => {
it('should call AuthService.githubLogin', async () => {
await controller.githubLogin();
expect(authService.githubLogin).toHaveBeenCalled();
// githubLogin is just a Passport guard entry point - it doesn't call authService
// The actual login is handled by the callback endpoint (githubRedirect)
controller.githubLogin();
// Verify the method exists and can be called without errors
expect(controller.githubLogin).toBeDefined();
// Verify authService was NOT called (since this is just a guard entry point)
expect(authService.githubLogin).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -97,8 +105,13 @@ describe('AuthController', () => {

describe('googleLogin', () => {
it('should call AuthService.googleLogin', async () => {
await controller.googleLogin();
expect(authService.googleLogin).toHaveBeenCalled();
// googleLogin is just a Passport guard entry point - it doesn't call authService
// The actual login is handled by the callback endpoint (googleRedirect)
controller.googleLogin();
// Verify the method exists and can be called without errors
expect(controller.googleLogin).toBeDefined();
// Verify authService was NOT called (since this is just a guard entry point)
expect(authService.googleLogin).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -126,8 +139,13 @@ describe('AuthController', () => {

describe('discordLogin', () => {
it('should call AuthService.discordLogin', async () => {
await controller.discordLogin();
expect(authService.discordLogin).toHaveBeenCalled();
// discordLogin is just a Passport guard entry point - it doesn't call authService
// The actual login is handled by the callback endpoint (discordRedirect)
controller.discordLogin();
// Verify the method exists and can be called without errors
expect(controller.discordLogin).toBeDefined();
// Verify authService was NOT called (since this is just a guard entry point)
expect(authService.discordLogin).not.toHaveBeenCalled();
});
});

Expand Down
25 changes: 9 additions & 16 deletions apps/backend/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DynamicModule, Logger, Module } from '@nestjs/common';
import { DynamicModule, Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import ms from 'ms';

import { MailingModule } from '@server/mailing/mailing.module';
import { UserModule } from '@server/user/user.module';
Expand All @@ -26,21 +27,13 @@ export class AuthModule {
inject: [ConfigService],
imports: [ConfigModule],
useFactory: async (config: ConfigService) => {
const JWT_SECRET = config.get('JWT_SECRET');
const JWT_EXPIRES_IN = config.get('JWT_EXPIRES_IN');

if (!JWT_SECRET) {
Logger.error('JWT_SECRET is not set');
throw new Error('JWT_SECRET is not set');
}

if (!JWT_EXPIRES_IN) {
Logger.warn('JWT_EXPIRES_IN is not set, using default of 60s');
}
const JWT_SECRET = config.getOrThrow<ms.StringValue>('JWT_SECRET');
const JWT_EXPIRES_IN =
config.getOrThrow<ms.StringValue>('JWT_EXPIRES_IN');

return {
secret: JWT_SECRET,
signOptions: { expiresIn: JWT_EXPIRES_IN || '60s' },
signOptions: { expiresIn: JWT_EXPIRES_IN },
};
},
}),
Expand All @@ -58,7 +51,7 @@ export class AuthModule {
inject: [ConfigService],
provide: 'COOKIE_EXPIRES_IN',
useFactory: (configService: ConfigService) =>
configService.getOrThrow<string>('COOKIE_EXPIRES_IN'),
configService.getOrThrow<ms.StringValue>('COOKIE_EXPIRES_IN'),
},
{
inject: [ConfigService],
Expand All @@ -82,7 +75,7 @@ export class AuthModule {
inject: [ConfigService],
provide: 'JWT_EXPIRES_IN',
useFactory: (configService: ConfigService) =>
configService.getOrThrow<string>('JWT_EXPIRES_IN'),
configService.getOrThrow<ms.StringValue>('JWT_EXPIRES_IN'),
},
{
inject: [ConfigService],
Expand All @@ -94,7 +87,7 @@ export class AuthModule {
inject: [ConfigService],
provide: 'JWT_REFRESH_EXPIRES_IN',
useFactory: (configService: ConfigService) =>
configService.getOrThrow<string>('JWT_REFRESH_EXPIRES_IN'),
configService.getOrThrow<ms.StringValue>('JWT_REFRESH_EXPIRES_IN'),
},
{
inject: [ConfigService],
Expand Down
4 changes: 3 additions & 1 deletion apps/backend/src/auth/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('AuthService', () => {
const refreshToken = 'refresh-token';

spyOn(jwtService, 'signAsync').mockImplementation(
(payload, options: any) => {
(payload: any, options: any) => {
if (options.secret === 'test-jwt-secret') {
return Promise.resolve(accessToken);
} else if (options.secret === 'test-jwt-refresh-secret') {
Expand Down Expand Up @@ -253,6 +253,7 @@ describe('AuthService', () => {
expect(res.cookie).toHaveBeenCalledWith('token', 'access-token', {
domain: '.test.com',
maxAge: 3600000,
path: '/',
});

expect(res.cookie).toHaveBeenCalledWith(
Expand All @@ -261,6 +262,7 @@ describe('AuthService', () => {
{
domain: '.test.com',
maxAge: 3600000,
path: '/',
},
);

Expand Down
31 changes: 15 additions & 16 deletions apps/backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import axios from 'axios';
import type { Request, Response } from 'express';
import type { CookieOptions, Request, Response } from 'express';
import ms from 'ms';

import { CreateUser } from '@nbw/database';
import type { UserDocument } from '@nbw/database';
Expand All @@ -22,18 +23,18 @@ export class AuthService {
@Inject(JwtService)
private readonly jwtService: JwtService,
@Inject('COOKIE_EXPIRES_IN')
private readonly COOKIE_EXPIRES_IN: string,
private readonly COOKIE_EXPIRES_IN: ms.StringValue,
@Inject('FRONTEND_URL')
private readonly FRONTEND_URL: string,

@Inject('JWT_SECRET')
private readonly JWT_SECRET: string,
@Inject('JWT_EXPIRES_IN')
private readonly JWT_EXPIRES_IN: string,
private readonly JWT_EXPIRES_IN: ms.StringValue,
@Inject('JWT_REFRESH_SECRET')
private readonly JWT_REFRESH_SECRET: string,
@Inject('JWT_REFRESH_EXPIRES_IN')
private readonly JWT_REFRESH_EXPIRES_IN: string,
private readonly JWT_REFRESH_EXPIRES_IN: ms.StringValue,
@Inject('APP_DOMAIN')
private readonly APP_DOMAIN?: string,
) {}
Expand Down Expand Up @@ -171,11 +172,11 @@ export class AuthService {

public async createJwtPayload(payload: TokenPayload): Promise<Tokens> {
const [accessToken, refreshToken] = await Promise.all([
this.jwtService.signAsync(payload, {
this.jwtService.signAsync<TokenPayload>(payload, {
secret: this.JWT_SECRET,
expiresIn: this.JWT_EXPIRES_IN,
}),
this.jwtService.signAsync(payload, {
this.jwtService.signAsync<TokenPayload>(payload, {
secret: this.JWT_REFRESH_SECRET,
expiresIn: this.JWT_REFRESH_EXPIRES_IN,
}),
Expand All @@ -189,7 +190,7 @@ export class AuthService {

private async GenTokenRedirect(
user_registered: UserDocument,
res: Response<any, Record<string, any>>,
res: Response<unknown, Record<string, unknown>>,
): Promise<void> {
const token = await this.createJwtPayload({
id: user_registered._id.toString(),
Expand All @@ -198,18 +199,16 @@ export class AuthService {
});

const frontEndURL = this.FRONTEND_URL;
const domain = this.APP_DOMAIN;
const maxAge = parseInt(this.COOKIE_EXPIRES_IN) * 1000;
const maxAge = ms(this.COOKIE_EXPIRES_IN) * 1000;

res.cookie('token', token.access_token, {
domain: domain,
const cookieOptions: CookieOptions = {
maxAge: maxAge,
});
domain: this.APP_DOMAIN,
path: '/',
};

res.cookie('refresh_token', token.refresh_token, {
domain: domain,
maxAge: maxAge,
});
res.cookie('token', token.access_token, cookieOptions);
res.cookie('refresh_token', token.refresh_token, cookieOptions);

res.redirect(frontEndURL + '/');
}
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/auth/strategies/JWT.strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('JwtStrategy', () => {
it('should throw an error if JWT_SECRET is not set', () => {
jest.spyOn(configService, 'getOrThrow').mockReturnValue(null);

expect(() => new JwtStrategy(configService)).toThrowError(
expect(() => new JwtStrategy(configService)).toThrow(
'JwtStrategy requires a secret or key',
);
});
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('JwtStrategy', () => {

const payload = { userId: 'test-user-id' };

expect(() => jwtStrategy.validate(req, payload)).toThrowError(
expect(() => jwtStrategy.validate(req, payload)).toThrow(
'No refresh token',
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('DiscordStrategy', () => {
it('should throw an error if Discord config is missing', () => {
jest.spyOn(configService, 'getOrThrow').mockReturnValueOnce(null);

expect(() => new DiscordStrategy(configService)).toThrowError(
expect(() => new DiscordStrategy(configService)).toThrow(
'OAuth2Strategy requires a clientID option',
);
});
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/auth/strategies/discord.strategy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DiscordStrategy extends PassportStrategy(strategy, 'discord') {
callbackUrl: `${SERVER_URL}/v1/auth/discord/callback`,
scope: [DiscordPermissionScope.Email, DiscordPermissionScope.Identify],
fetchScope: true,
prompt: 'none',
prompt: 'none' as const,
};

super(config);
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/auth/strategies/github.strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('GithubStrategy', () => {
it('should throw an error if GitHub config is missing', () => {
jest.spyOn(configService, 'getOrThrow').mockReturnValueOnce(null);

expect(() => new GithubStrategy(configService)).toThrowError(
expect(() => new GithubStrategy(configService)).toThrow(
'OAuth2Strategy requires a clientID option',
);
});
Expand Down
Loading