I am trying to write a Javascript client for a web application that provides a REST API to interact with the application. I want to do this in a very advanced way, for example, with a proven set of tools and methodologies available in Javascript.
Most of the javascript client library development guides that I have found on the Internet are focused on applications that have part of the presentation (I mean the part of HTML). What I need is as a client library with some methods that you can use to develop web applications. Therefore, I do not want to depend on this library with any other javascript library such as jQuery, Backbone, etc.
I looked through the many design patterns available in javascript, especially the patterns mentioned in Learning JavaScript Design Patterns in Addy Osmani's book. And in the end I was embarrassed, I could not decide which one follows.
I mean the following:
- Initialize the library with some key and secret (this can be compared with declaring an object for a class in php).
- There will be a data storage unit that will support the authenticated user ID for a predetermined period of time, such as sessions in php. User data will be stored in cookies or local storage. Conditions will also be provided for overriding the methods of this device so that the user can implement his own storage mechanism. A link to this device will also be transmitted during initialization of the library.
- Save a global request method that processes all API requests related to the library (this can be compared with the main class method in php)
- API, , , . , ( php, API). , .
yoman . , javascript , .
, , : , , . singleton, , .
!