Skip to content

Commit

Permalink
feat(ssr): adds response token for future use
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeoxx committed May 15, 2024
1 parent 2718f99 commit d462351
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions projects/ngx-cookie-service-ssr/src/lib/ssr-cookie.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Request } from 'express';
import { Request, Response } from 'express';
import { Inject, Injectable, InjectionToken, Optional, PLATFORM_ID } from '@angular/core';
import { DOCUMENT, isPlatformBrowser } from '@angular/common';

// Define the `Request` token
// Define the `Request` and `Response` token
export const REQUEST = new InjectionToken<Request>('REQUEST');
export const RESPONSE = new InjectionToken<Response>('RESPONSE');

@Injectable({
providedIn: 'root',
Expand All @@ -15,7 +16,8 @@ export class SsrCookieService {
@Inject(DOCUMENT) private document: Document,
// Get the `PLATFORM_ID` so we can check if we're in a browser.
@Inject(PLATFORM_ID) private platformId: any,
@Optional() @Inject(REQUEST) private request: Request
@Optional() @Inject(REQUEST) private request: Request,
@Optional() @Inject(RESPONSE) private response: Response
) {
this.documentIsAccessible = isPlatformBrowser(this.platformId);
}
Expand Down

0 comments on commit d462351

Please sign in to comment.