From b3e213ba0462e45366076e75f1a0c4d89ec9d9c4 Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Mon, 7 Oct 2024 11:14:45 -0400 Subject: [PATCH] refactor(CookieService): rename SESSION_COOKIE_OPTIONS to SESSION_COOKIE_CONFIG for clearer semantics --- api/src/unraid-api/auth/auth.module.ts | 4 ++-- api/src/unraid-api/auth/cookie.service.spec.ts | 4 ++-- api/src/unraid-api/auth/cookie.service.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/src/unraid-api/auth/auth.module.ts b/api/src/unraid-api/auth/auth.module.ts index fb97414e5..bd81d2184 100644 --- a/api/src/unraid-api/auth/auth.module.ts +++ b/api/src/unraid-api/auth/auth.module.ts @@ -3,7 +3,7 @@ import { AuthService } from './auth.service'; import { UsersModule } from '@app/unraid-api/users/users.module'; import { PassportModule } from '@nestjs/passport'; import { ServerHeaderStrategy } from '@app/unraid-api/auth/header.strategy'; -import { CookieService, SESSION_COOKIE_OPTIONS } from './cookie.service'; +import { CookieService, SESSION_COOKIE_CONFIG } from './cookie.service'; @Module({ imports: [UsersModule, PassportModule], @@ -11,7 +11,7 @@ import { CookieService, SESSION_COOKIE_OPTIONS } from './cookie.service'; AuthService, ServerHeaderStrategy, CookieService, - { provide: SESSION_COOKIE_OPTIONS, useValue: CookieService.defaultOpts() }, + { provide: SESSION_COOKIE_CONFIG, useValue: CookieService.defaultOpts() }, ], }) export class AuthModule {} diff --git a/api/src/unraid-api/auth/cookie.service.spec.ts b/api/src/unraid-api/auth/cookie.service.spec.ts index 24ae9894c..368a8f5c3 100644 --- a/api/src/unraid-api/auth/cookie.service.spec.ts +++ b/api/src/unraid-api/auth/cookie.service.spec.ts @@ -1,5 +1,5 @@ import { Test, type TestingModule } from '@nestjs/testing'; -import { CookieService, SESSION_COOKIE_OPTIONS } from './cookie.service'; +import { CookieService, SESSION_COOKIE_CONFIG } from './cookie.service'; import { describe, it, beforeAll, afterAll } from 'vitest'; import { emptyDir, ensureFile } from 'fs-extra'; @@ -17,7 +17,7 @@ describe.concurrent('CookieService', () => { const module: TestingModule = await Test.createTestingModule({ providers: [ CookieService, - { provide: SESSION_COOKIE_OPTIONS, useValue: { namePrefix: 'unraid_', sessionDir } }, + { provide: SESSION_COOKIE_CONFIG, useValue: { namePrefix: 'unraid_', sessionDir } }, ], }).compile(); diff --git a/api/src/unraid-api/auth/cookie.service.ts b/api/src/unraid-api/auth/cookie.service.ts index d74630043..92138ace6 100644 --- a/api/src/unraid-api/auth/cookie.service.ts +++ b/api/src/unraid-api/auth/cookie.service.ts @@ -4,9 +4,9 @@ import { Injectable, Inject } from '@nestjs/common'; import { join } from 'path'; /** token for dependency injection of a session cookie options object */ -export const SESSION_COOKIE_OPTIONS = 'SESSION_COOKIE_OPTIONS'; +export const SESSION_COOKIE_CONFIG = 'SESSION_COOKIE_CONFIG'; -type SessionCookieOptions = { +type SessionCookieConfig = { namePrefix: string; sessionDir: string; }; @@ -14,13 +14,13 @@ type SessionCookieOptions = { @Injectable() export class CookieService { constructor( - @Inject(SESSION_COOKIE_OPTIONS) readonly opts: SessionCookieOptions = CookieService.defaultOpts() + @Inject(SESSION_COOKIE_CONFIG) readonly opts: SessionCookieConfig = CookieService.defaultOpts() ) {} /** * @returns new SessionCookieOptions with `namePrefix: 'unraid_', sessionDir: '/var/lib/php'` */ - static defaultOpts(): SessionCookieOptions { + static defaultOpts(): SessionCookieConfig { return { namePrefix: 'unraid_', sessionDir: '/var/lib/php' }; }