Skip to content

Commit

Permalink
Continuing initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianKopp authored Dec 9, 2018
1 parent f2d7bf0 commit 35c0462
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 54 deletions.
82 changes: 55 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@ngrx/effects": "^6.1.2",
"@ngrx/router-store": "^6.1.2",
"@ngrx/store": "^6.1.2",
"amazon-cognito-identity-js": "^3.0.5",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.3",
"@angular-devkit/build-ng-packagr": "~0.6.8",
"@angular-devkit/build-angular": "~0.6.8",
"ng-packagr": "^3.0.0-rc.2",
"tsickle": ">=0.25.5",
"tslib": "^1.7.1",
"typescript": "~2.7.2",
"@angular-devkit/build-ng-packagr": "~0.6.8",
"@angular/cli": "~6.0.8",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
"@ngrx/store-devtools": "^6.1.2",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
Expand All @@ -48,8 +46,12 @@
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"ng-packagr": "^3.0.0-rc.2",
"protractor": "^5.4.1",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
"tsickle": ">=0.25.5",
"tslib": "^1.7.1",
"tslint": "~5.9.1",
"typescript": "^2.8.0"
}
}
4 changes: 3 additions & 1 deletion projects/ngrx-cognito/src/lib/ngrx-cognito.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { cognitoReducer } from './state/cognito.reducer';
import { EffectsModule } from '@ngrx/effects';
import { CognitoEffects } from './state/cognito.effects';
import { CognitoFacade } from './state/cognito.facade';
import { RouterModule } from '@angular/router';

@NgModule({
imports: [StoreModule.forFeature('cognito', cognitoReducer), EffectsModule.forFeature([CognitoEffects])],
imports: [RouterModule, StoreModule.forFeature('cognito', cognitoReducer), EffectsModule.forFeature([CognitoEffects])],
declarations: [],
exports: []
})
Expand All @@ -23,6 +24,7 @@ export class NgrxCognitoModule {
RequireLoggedInGuardService,
RequireLoggedOutGuardService,
CognitoFacade,
RouterModule,
{ provide: CognitoConfigService, useValue: cognitoConfig }
]
};
Expand Down
2 changes: 1 addition & 1 deletion projects/ngrx-cognito/src/lib/state/cognito.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CognitoStates } from '../model';
import { MemoizedSelector } from '@ngrx/store';
import { CognitoUser } from 'amazon-cognito-identity-js';

const getCognito = createFeatureSelector<CognitoState>('auth');
const getCognito = createFeatureSelector<CognitoState>('cognito');

const getCognitoState = createSelector(
getCognito,
Expand Down
1 change: 1 addition & 0 deletions projects/ngrx-cognito/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*/

export * from './lib/ngrx-cognito.module';
export { cognitoReducer, CognitoState } from './lib/state/cognito.reducer';
6 changes: 2 additions & 4 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
declarations: [AppComponent]
}).compileComponents();
}));
it('should create the app', async(() => {
Expand All @@ -22,6 +20,6 @@ describe('AppComponent', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to ngrx-cognito-app!');
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});
23 changes: 22 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { RouterModule } from '@angular/router';
import { StoreRouterConnectingModule } from '@ngrx/router-store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';

import { NgrxCognitoModule } from 'ngrx-cognito';
import { AppComponent } from './app.component';
import { appReducers, metaReducers } from './state/app.reducer';
import { environment } from '../environments/environment';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, NgrxCognitoModule],
imports: [
BrowserModule,
RouterModule.forRoot([{ path: '', component: AppComponent }]),
StoreModule.forRoot(appReducers, { metaReducers }),
EffectsModule.forRoot([]),
NgrxCognitoModule.forRoot({
cognitoAppClientId: environment.cognitoAppClientId,
cognitoUserPoolId: environment.cognitoUserPoolId
}),
StoreRouterConnectingModule.forRoot(),
StoreDevtoolsModule.instrument({
name: 'Cognito App',
logOnly: !environment.production
})
],
providers: [],
bootstrap: [AppComponent]
})
Expand Down
26 changes: 26 additions & 0 deletions src/app/state/app.reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ActionReducerMap, ActionReducer, MetaReducer } from '@ngrx/store';
import { CognitoState, cognitoReducer } from 'ngrx-cognito';
import { environment } from 'src/environments/environment';

export interface AppState {
cognito: CognitoState;
}

export const appReducers: ActionReducerMap<AppState> = {
cognito: cognitoReducer
};

// log all actions
export function logActions(reducer: ActionReducer<AppState>): ActionReducer<AppState> {
return (state: AppState, action: any): any => {
const result = reducer(state, action);
console.groupCollapsed(action.type);
console.log('prev state', state);
console.log('action', action);
console.log('next state', result);
console.groupEnd();
return result;
};
}

export const metaReducers: MetaReducer<AppState>[] = !environment.production ? [logActions] : [];
4 changes: 3 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const environment = {
production: true
production: true,
cognitoAppClientId: '',
cognitoUserPoolId: ''
};
4 changes: 3 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
production: false,
cognitoAppClientId: '',
cognitoUserPoolId: ''
};

/*
Expand Down
27 changes: 16 additions & 11 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>NgrxCognitoApp</title>
<base href="/">
<head>
<meta charset="utf-8" />
<title>NgrxCognitoApp</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<script>
if (global === undefined) {
var global = window;
}
</script>
</head>
<body>
<app-root></app-root>
</body>
</html>

0 comments on commit 35c0462

Please sign in to comment.