This file talks about both inner module interface and the one that we call from other modules.
Controllers control different route of url respectively. They call for the API services exposed. They will expose API and Data for corresponding views.
- about.js
- account.js
- blog.js
- login.js
submit()
- main.js
- management.js
addClass()
- msg.js
- nav.js
setTab(t);
isSelected(t);
- settings.js
- signup.js
submit();
valid();
- stat.js
getCourse(c);
getStudents(c);
getData();
- tools.js
Services are all singleton. They expose global API or data access.
- data.js
Provide $resource wrapped object, User, Students, Course. These objects contain API for http request and handles. The http methods are configured globally by adding corresponding headers in http request, thus are able to solve cross domain problem.
API:
setNav(nav);
getNav(nav);
obj User;
obj Course;
obj Students;
- flash.js
Queue to display messages such as info, warning and errors.
API:
setMessage(m);
getMessage();
nextMessage();
- session.js
API:
login(user);
logout();
who();
isLoggedIn();
app.js
dependency control, http request header set, route define.
Views have access to the corresponding controller's exposed API. They insert the data or function return value into the generated html code.
I use strict RESTful API.
GET http://api.example.com/usersget a list of usersGET http://api.example.com/users/:userIdget info for the particular userPOST http://api.example.com/userspost data(by post body) for particular userGET http://api.example.com/coursesget a list of coursesGET http://api.example.com/courses/:courseIdget information of a particular courseGET http://api.example.com/courses/:courseId/:studentIdget information of the particular student in the particular coursePOST http://api.example.com/coursespost a course info to serverPOST http://api.example.com/courses/:courseIdpost a student's info to the particular course.