Skip to content
This repository was archived by the owner on Sep 21, 2018. It is now read-only.

Commit ef0185c

Browse files
committed
feat(Interview): Updated readme with interview spec, created all the
required parts to get started, fixed the test runner
1 parent a5756cb commit ef0185c

File tree

15 files changed

+10586
-55
lines changed

15 files changed

+10586
-55
lines changed

.angular-cli.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"testTsconfig": "tsconfig.spec.json",
2020
"prefix": "bc",
2121
"styles": [
22-
"styles.css"
22+
"styles.css",
23+
"styles/theme.scss"
2324
],
2425
"scripts": [],
2526
"environmentSource": "environments/environment.ts",

README.md

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1-
---
2-
# This repository is for version 2.x of the example application.
3-
# [Click here for the latest version (4.x)](https://github.com/ngrx/platform)
4-
---
5-
6-
# @ngrx example application
7-
8-
Example application utilizing @ngrx libraries, showcasing common patterns and best practices.
9-
Take a look at the [live app](http://ngrx.github.io/example-app/).
10-
11-
This app is a book collection manager. Using the Google Books API, the user can search for
12-
books and add them to their collection. This application utilizes [@ngrx/db](https://github.com/ngrx/db)
13-
to persist the collection across sessions; [@ngrx/store](https://github.com/ngrx/store) to manage
14-
the state of the app and to cache requests made to the Google Books API;
15-
[@angular/router](https://github.com/angular/angular) to manage navigation between routes;
16-
[@ngrx/effects](https://github.com/ngrx/effects) to isolate side effects.
17-
18-
Built with [@angular/cli](https://github.com/angular/angular-cli)
19-
20-
### Included
21-
- [ngrx/store](https://github.com/ngrx/store) - RxJS powered state management for Angular apps, inspired by Redux
22-
- [ngrx/effects](https://github.com/ngrx/effects) - Side effect model for @ngrx/store
23-
- [angular/router](https://github.com/angular/angular) - Angular Router
24-
- [ngrx/db](https://github.com/ngrx/db) - RxJS powered IndexedDB for Angular apps
25-
- [ngrx/store-devtools](https://github.com/ngrx/store-devtools) - Instrumentation for @ngrx/store enabling time-travel debugging
26-
- [codewareio/ngrx-store-freeze](https://github.com/codewareio/ngrx-store-freeze) - A @ngrx/store meta reducer that prevents state from being mutated
27-
- [reselect](https://github.com/reactjs/reselect) - Selector library for Redux
28-
29-
### Quick start
30-
31-
```bash
32-
# clone the repo
33-
git clone https://github.com/ngrx/example-app.git
34-
35-
36-
# change directory to repo
37-
cd example-app
38-
39-
# Use npm or yarn to install the dependencies:
40-
npm install
41-
42-
# OR
43-
yarn
44-
45-
# start the server
46-
ng serve
1+
# CloudNC Angular Interview Challenge
2+
(Fork of https://github.com/ngrx/example-app)
3+
4+
## The Challenge
5+
Starting with the "Books" demo application for ngrx, add authenticated
6+
protection to the application so a user cannot access books or
7+
collections without valid credentials.
8+
9+
## Details
10+
* The following components should be protected
11+
(these are components that currenly have routes)
12+
* `CollectionPageComponent` - as this is currently the root route (`path: ''`)
13+
it should be moved to `/collection`
14+
* `FindBookPageComponent`
15+
* `ViewBookPageComponent`
16+
* If a user attempts to access a protected route, they should be
17+
redirected to the login page
18+
* Once the user is logged in, they should see the phrase
19+
`Logged In as ${username}` in the toolbar
20+
* If the user is logged in, and they load the `/` route, they should be
21+
redirected to the `/collection` page
22+
* The authentication service should simply be a stub that checks if the
23+
submitted password is `password`. For example:
24+
```ts
25+
/**
26+
* Asynchronously authenticate with a remote service
27+
* @todo(*) actually authenticate
28+
*/
29+
public authenticate(username: string, password: string): Observable<boolean> {
30+
31+
if (password === 'password') {
32+
console.info(`Logged in as ${username}`);
33+
return Observable.of(true);
34+
}
35+
36+
console.info(`Access denied for ${username} (Incorrect password)`);
37+
38+
return Observable.of(false);
39+
}
4740
```
48-
49-
Navigate to [http://localhost:4200/](http://localhost:4200/) in your browser
50-
51-
_NOTE:_ The above setup instructions assume you have added local npm bin folders to your path.
52-
If this is not the case you will need to install the Angular CLI globally.
41+
* The login state should be persisted to the browser database
42+
(see `src/app/effects/collection.ts` for an example) so page refreshes
43+
result in the user still being logged in
44+
* If the user attempts to visit a protected page, after they are
45+
redirected AND successfully log in, they should be redirected back to
46+
the page that they were first attempting to visit
47+
48+
# Bonus! (if time allows)
49+
* Write tests for the service/guard/reducer/component

karma.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = function (config) {
1616
clearContext: false // leave Jasmine Spec Runner output visible in browser
1717
},
1818
files: [
19-
{ pattern: './src/test.ts', watched: false }
19+
{ pattern: './src/test.ts', watched: false },
20+
{ pattern: './node_modules/@angular/material/prebuilt-themes/indigo-pink.css' }
2021
],
2122
preprocessors: {
2223
'./src/test.ts': ['@angular/cli']

0 commit comments

Comments
 (0)