mirror of
https://github.com/unraid/api.git
synced 2026-01-07 00:59:48 -06:00
refactor(CookieService): rename SESSION_COOKIE_OPTIONS to SESSION_COOKIE_CONFIG for clearer semantics
This commit is contained in:
@@ -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 {}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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' };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user