|
| 1 | +# Fortune Cookies |
| 2 | +JavaScript Applications Exam, 10 September 2015 |
| 3 | + |
| 4 | +Implement a SPA application for fortune cookies. |
| 5 | + |
| 6 | +## Application description |
| 7 | + |
| 8 | +The application must provide the following functionality |
| 9 | + |
| 10 | +* **Users** can **Register**, **Login** and **Logout** in the application |
| 11 | + * _Users provide `username` and `password`_ |
| 12 | +* **Logged-in users** can: |
| 13 | + * **Share** a new fortune cookie |
| 14 | + * Providing `text` and `category` |
| 15 | + * **Re-share** an existing fortune cookie |
| 16 | + * This can be either: |
| 17 | + * A fortune cookie, shared by this user |
| 18 | + * A fortune cookie, shared by other user |
| 19 | + * **Like** or **dislike** a fortune cookie |
| 20 | + * **Get** their hourly fortune cookie |
| 21 | + * A random cookie from all shared cookies |
| 22 | + * This cookie is changed every hour |
| 23 | + * i.e. if the user asks for their fortune cookie at 11:30 and then again at 11:45, their fortune cookie will be the same |
| 24 | + * or if the user asks for their fortune cookie at 11:30 and then again at 12:00, the two fortune cookies may be different |
| 25 | + * It depends on the total count of fortune cookies |
| 26 | +* **All users** (even not logged in) can **see** fortune cookies, that are shared by any user |
| 27 | +* **Cookies** can be: |
| 28 | + * Sorted by `likes` or `shareDate` |
| 29 | + * Filtered by a single `category` |
| 30 | + * i.e. show only the fortune cookies in a given `category` |
| 31 | + |
| 32 | +## Application routes |
| 33 | + |
| 34 | +Implement at least the following routes in your app: |
| 35 | + |
| 36 | +* `#/` |
| 37 | + * Redirects to `#/home` |
| 38 | +* `#/home` |
| 39 | + * Shows all fortune cookies |
| 40 | + * Available to all users, logged-in or not |
| 41 | + * Provides a way to sort the cookies by `likes` or `shareDate` |
| 42 | + * Provides a way to filter fortune cookies by `category` |
| 43 | +* `#/home?category=CCCC` |
| 44 | + * Shows only the fortune cookies in category **CCC** |
| 45 | +* `#/my-cookie` |
| 46 | + * Shows the current hourly fortune cookie for the logged-in user |
| 47 | + |
| 48 | + |
| 49 | +## Application requirements |
| 50 | + |
| 51 | +**Mandatory** provide a good **User Experience(UX)** |
| 52 | + * No need to be pretty, just usable |
| 53 | + * Please do not make your colleagues wonder where to click, to share a fortune cookie |
| 54 | + |
| 55 | +**Mandatory** use extensively the following libraries: |
| 56 | + |
| 57 | +* jQuery |
| 58 | + * For AJAX |
| 59 | + * For DOM manipulation |
| 60 | +* Handlebars.js |
| 61 | + * For view templates |
| 62 | + |
| 63 | +**Do NOT** use any of the following: |
| 64 | +* AngularJS |
| 65 | +* KendoUI framework |
| 66 | + * Data-binding, routing, ViewModels, etc... |
| 67 | +* Durandal |
| 68 | +* Backbone.js |
| 69 | +* Ember.js |
| 70 | +* Batman.js |
| 71 | + |
| 72 | +You can use libraries for: |
| 73 | +* Notifications |
| 74 | + * toastr or any other |
| 75 | +* UI components |
| 76 | + * jQueryUI, KendoUI UI components, Twitter Bootstrap |
| 77 | +* Utils frameworks: |
| 78 | + * Moment, Underscore/Lodash |
| 79 | + * Libs for encryption |
| 80 | + * etc... |
| 81 | +* Routers |
| 82 | + * Only Sammy.js is allowed |
| 83 | +* Module loading |
| 84 | + * System.js, RequireJS or other |
| 85 | + |
| 86 | +## Server routes |
| 87 | + |
| 88 | +### Users |
| 89 | + |
| 90 | +* `api/users` |
| 91 | + * GET |
| 92 | + * **Returns** all users |
| 93 | + * POST |
| 94 | + * **Registers** a new user |
| 95 | + * Needs **username** and **passHash** to be sent in the body of the request |
| 96 | +* `api/auth` |
| 97 | + * PUT |
| 98 | + * **Logs in** an user |
| 99 | + * Needs **username** and **passHash** to be sent in the body of the request |
| 100 | + * If the request is valid returns **username** and **authKey** |
| 101 | + |
| 102 | +### Fortune Cookies |
| 103 | + |
| 104 | +* `api/cookies` |
| 105 | + * GET |
| 106 | + * **Returns** all shared fortune cookies |
| 107 | + * POST |
| 108 | + * **Shares** or **re-shares** a new fortune cookie |
| 109 | + * User must be **logged-in** |
| 110 | + * Needs **text**, **category**, **img** to be sent in the body of the request and the current user's **authKey** as a header with name: `x-auth-key` |
| 111 | + * `img` is a string to an online image |
| 112 | + * `img` is optional and if not sent, a **default batman** image will be provided |
| 113 | +* `api/cookies/:id` |
| 114 | + * PUT |
| 115 | + * **Likes** or **dislikes** a fortune cookie |
| 116 | + * Needs `type` to be sent in the body of the request |
| 117 | + * `type` can only have values 'like' or 'dislike' |
| 118 | + |
| 119 | +### My Fortune Cookies |
| 120 | + |
| 121 | +* `api/my-cookie` |
| 122 | + * GET |
| 123 | + * **Returns** the hourly fortune cookie |
| 124 | + |
| 125 | +### Categories |
| 126 | +* `api/categories` |
| 127 | + * GET |
| 128 | + * **Returns** an array with all categories |
| 129 | + |
| 130 | +## Deliverables |
| 131 | + |
| 132 | +* **ZIP** all your code, including the server |
| 133 | + * Remove only the `node_modules` folder |
| 134 | +* Send the ZIP file on the page, provided in http://telerikacademy.com |
| 135 | + |
| 136 | +## Constraints and validation |
| 137 | +* Username |
| 138 | + * A string |
| 139 | + * Has length between 6 and 30 |
| 140 | + * Can contain only Latin letters, digits and the characters '\_' and '.' |
| 141 | +* Fortune Cookie Text |
| 142 | + * A string |
| 143 | + * Has length between 6 and 30 |
| 144 | + * Can contain any characters |
| 145 | +* Fortune Cookie Category |
| 146 | + * A string |
| 147 | + * Has length between 6 and 30 |
| 148 | + * Can contain any characters |
| 149 | +* Fortune Cookie Img |
| 150 | + * A string |
| 151 | + * Must be a valid url address |
0 commit comments