Browse Source

application builder added

pull/23416/head
erdemcaygor 1 year ago
parent
commit
e40a782db4
  1. 3
      npm/ng-packs/.prettierignore
  2. 2
      npm/ng-packs/apps/dev-app/project.json
  3. 3
      npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts
  4. 39
      npm/ng-packs/packages/oauth/src/lib/services/server-token-storage.service.ts

3
npm/ng-packs/.prettierignore

@ -9,4 +9,5 @@
/tools /tools
/source-code-requirements /source-code-requirements
/.nx/cache /.nx/cache
/.nx/workspace-data /.nx/workspace-data
.angular

2
npm/ng-packs/apps/dev-app/project.json

@ -187,7 +187,7 @@
"continuous": true, "continuous": true,
"executor": "@nx/web:file-server", "executor": "@nx/web:file-server",
"options": { "options": {
"buildTarget": "my-app:build", "buildTarget": "dev-app:build",
"port": 4200, "port": 4200,
"staticFilePath": "dist/apps/dev-app/browser", "staticFilePath": "dist/apps/dev-app/browser",
"spa": true "spa": true

3
npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts

@ -49,7 +49,8 @@ export async function getInitialData() {
return throwError(() => error); return throwError(() => error);
}), }),
); );
await lastValueFrom(result$); // TODO: Not working with SSR
// await lastValueFrom(result$);
await localeInitializer(injector); await localeInitializer(injector);
} }

39
npm/ng-packs/packages/oauth/src/lib/services/server-token-storage.service.ts

@ -1,33 +1,32 @@
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable, Optional } from '@angular/core';
import { OAuthStorage } from 'angular-oauth2-oidc'; import { OAuthStorage } from 'angular-oauth2-oidc';
import { REQUEST } from '@angular/core';
@Injectable({ @Injectable({ providedIn: null })
providedIn: null,
})
export class ServerTokenStorageService implements OAuthStorage { export class ServerTokenStorageService implements OAuthStorage {
private cookies: Map<string, string> = new Map(); private cookies = new Map<string, string>();
constructor(@Inject('cookies') c: string | undefined) {
if (c) { constructor(@Optional() @Inject(REQUEST) private req: Request | null) {
const cookieItems = c.split(';'); const cookieHeader = this.req?.headers.get('cookie') ?? '';
for (const item of cookieItems) { for (const part of cookieHeader.split(';')) {
const index = item.indexOf('='); const i = part.indexOf('=');
if (index > -1) { if (i > -1) {
const key = item.slice(0, index).trim(); const k = part.slice(0, i).trim();
const value = item.slice(index + 1).trim(); const v = decodeURIComponent(part.slice(i + 1).trim());
this.cookies.set(key, value); this.cookies.set(k, v);
}
} }
} }
} }
getItem(key: string): string { getItem(key: string): string {
if (this.cookies) { const fromCookie = this.cookies.get(key);
return this.cookies.get(key); if (fromCookie) {
return fromCookie;
} }
return ''; return '';
} }
removeItem(key: string): void {} setItem(_k: string, _v: string): void {}
removeItem(_k: string): void {}
setItem(key: string, data: string): void {}
} }

Loading…
Cancel
Save