Welcome! Congratulations on making our shortlist! Below you will find a task that will put your skills to the test. Good luck.
- Angular2 - RC.4 NOTE!! If you go looking at the angular2 docs, remember that they will reflect the latest version of angular2, at the time of writing is RC.5.
- angular-cli - version 1.0.0-beta.10
- SASS
git clone <path to your repo of test>nodeversion4.2.2(updating this is dependent on your OS)npmversion3.10.3(you can usually runnpm install npm@3.10.3 -gto update, might need to be run assudoon ubuntu or mac)- run
npm install typings -g(if ubuntu or mac, normally needs to be run assudo) - run
npm install angular-cli@1.0.0-beta.10 -g(if ubuntu or mac, normally needs to be run assudo) - run
npm install-> this will download and install all the packages required to build the Angular2ClientApp(Don't run thissudo, you should not need to) - it should automatically run this, but in-case it doesn't, run
typings install - MEGA PRO TIP: If you already have other versions of Node, NPM, typings or angular-cli installed, use Docker to instantiate a clean development environment. We recommend the Ubuntu 16.04 docker image that can be found on Docker Hub
Step into the ClientApp directory (cd ClientApp/) and run npm start or ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
Below is the basic structure that you should concern yourself with.
ClientApp -- src -- app --
|-- components -> Angular2 components that make up the application
|-- footer -> the app's footer
|-- header -> the app's header
|-- main-content -> the app's main content,
|-- shared
|-- search-input-card -> the card used to display the search box
|-- search-result-table -> the table used to display the results
|-- welcome-card -> a friendly greeting card
|-- mock -> the example data
|-- models
|-- services -> *this is where you wire up the API*
|-- app.component -> main app component
|-- config.ts -> Configution strings, such as API urls. *You may need to change this*
ServerApp -- -> this is where you much do the Primary Task
| -- data.json -> the data for you to use
The ApiDataService looks like this:
@Injectable()
export class ApiDataService {
constructor(private http:Http) {
}
public performSearchRequest(searchTerm:string, queryType:string):Promise<SearchResult[]> {
return new Promise<SearchResult[]>((resolve, reject) => {
let url = Config.apiBaseUrl + Config.searchApi;
url += "?s=" + searchTerm;
console.log("Your query to be: " + url);
if (queryType == 'mock') {
//for now, fetching mock data! Not filtered by search query as that would be giving it away ;)
resolve(MockSearchData);
} else {
//use reject(error) to return an error back
reject("To be completed!");
}
});
}
}
It needs to be expanded/modified to work your NodeJS/Express server. This is pretty much the only modification you should have to do to the ClientApp, as everything is wired up.
This can only be completed once you complete the primary task, but this is presented first so that you have a good idea of what is expected from the API.
This is the primary task. Complete the app in the ServerApp sub-directory.
Your task is to build an API, using NodeJS and ExpressJS
- To get an idea of what needs to happen, Hit the submit button without any value in the search box, and you will see it populate a table with results. It is up to you to replicate this.
- Please complete the server application in the
ServerAppsub-directory - Run
npm initto get started. Build a simple NodeJS project, complete withpackage.json. We should be able tonpm installto install the dependencies after we clone your source - Use ExpressJS to create a simple API server that accepts a query string. Hints: a. You will need to "body-parser" JSON b. You will need CORS handling
- Read the file
data.jsoninto the application and return a filtered list based on the search term to theClientApp - Move over to the
ApiDataServicein theClientApp, modify it to make the request to your API server - Process the response and resolve the
Promiseto present your data to theClientApp - If you don't modify the structure of the data returned, then the
ClientAppshould display a table with your results
Please be sure to "show your working out" by committing as much as possible. Even though you could create one commit for the entire solutions, this is discouraged. We would like to see the steps/process you used to arrive to your solution.
Look in main-content.component.ts and main-content.component.html to complete these
- BONUS: Handle errors returned from the backed, "query string blank" and/or any other errors you might one to return, like 404 not found. For now, you will see an error being presented with a simple
alert(), additional bonus points will be added for a creative expansion of theClientAppto present an error in a more user-friendly way. - BONUS: Handle "no results found" when returned from the backend
Completing this test will help us understand to what degree you satisfy the following criteria:
- Aptitude, can you accomplish the task set forth using the Power of the Internet?
- Precision, can you edit just what needs to be edited in order to accomplish your goals?
- Attention, can you follow the guide set forth by the architect?