æ¯æããŽã«ãããŒã«ã«èŒªãŽã ã®ããã«äžçãåºããå€æ¹ã«ã¯ãããå ã¿ãŸãã æ¬åœã«è³ªåãããã°ããããã©ã®ããã«è¡ããããã瀺ããŸããR.ãã©ããããªãŒ
æŽæ°ïŒè§£æ㯠2017幎ãŸã§ã«æ©èœããŸãã ã
ã¯ããã«
ãã®èšäºã§ã¯ãããŒã¿ãä¿åããã³åŠçããããã®Backend-as-a-Serviceã¢ãããŒãã«ã€ããŠèª¬æããŸãã ãã®ã¢ãããŒãã®ä»£è¡šã§ããparse.comãµãŒãã¹ã®é·æãšçæã«ã€ããŠèª¬æããŸãã ãœãŒã·ã£ã«ãéããŠç°¡åã«æ瀺ããããŠãŒã¶ãŒèªèšŒãµãŒãã¹ã uLoginãããã¯ãŒã¯ã äž»ãªç®çã¯ãããã2ã€ã®ãµãŒãã¹ãã©ã®ããã«çžäºäœçšãããã瀺ãããšã§ããããã«ããããããžã§ã¯ãã¯ãã°ã€ã³ãšãã¹ã¯ãŒãã«ãããŠãŒã¶ãŒç»é²ãå¿ èŠãšããŸããããåæã«ããŠãŒã¶ãŒããªããžã§ã¯ããæäœããããšãèš±å¯ããæ©èœã¯ä¿æãããŸãã
BaaSãšparse.comã«ã€ããŠ
Parse.comã¯ãæã人æ°ã®ãããµãŒãã¹ãšããŠã®ããã¯ãšã³ãïŒBaaSïŒãããã€ããŒã®1ã€ã§ãã BaaSã¢ãããŒãã䜿çšãããšãã¢ããªã±ãŒã·ã§ã³ããŒã¿ãä¿åããã³åŠçããããã«ãµãŒããŒãäžããå¿ èŠããªããªããŸãã ããã¯ãã¢ãã€ã«éçºããã³éåžžã®Webã§äœ¿çšãããŸãã Parse.comã«ã¯ããµãŒããŒãå«ãããã€ãã®ãã©ãããã©ãŒã çšã®ç¬èªã®SDKããããŸãã ããããç§ã¯javascriptã«ã€ããŠè©±ããŸãã
ãµãŒããŒãäžããããšãªãjavascriptãä»ããŠããŒã¿ããŒã¹ãæäœããæ©èœã¯ãããšãã°Github PagesãBitbucketãããã³ä»ã®å€ãã®ç¡æã®ã¢ããªã±ãŒã·ã§ã³ã§ãã¹ãã§ããSingle page applicationïŒSPAïŒã®åªããæ©äŒãéããŸãã ã¯ã©ã€ã¢ã³ãã³ãŒãããããŒã¿ããŒã¹ãæäœããããšã«ã€ããŠèãããšãã«æåã«çåã«æã£ãã®ã¯ãããŒãããç¥ãããŠãããããã¢ã¯ã»ã¹æš©ã®å·®å¥åã§ãã parse.comã®ããã¥ã¡ã³ãã調ã¹ããšãããããã«ã¯ãŠãŒã¶ãŒèªèšŒã䜿çšãããŠããããšãããããŸããã åãŠãŒã¶ãŒã«ã¯ãç¬èªã®ãŠãŒã¶ãŒåãšãã¹ã¯ãŒãããããŸãã SDKã«ã¯ãæ°ãããŠãŒã¶ãŒããŠãŒã¶ãŒåãšãã¹ã¯ãŒãã§ç»é²ããåãããŒã¿ã§èªèšŒããããã®ã¡ãœããããããŸãã é»åã¡ãŒã«ãè¿œå ã§ããŸããã parse.comèªäœã¯é»åã¡ãŒã«æ€èšŒã®ããã«ã«ã¹ã¿ã é»åã¡ãŒã«ãéä¿¡ã§ããŸãã
ç»é²ã³ãŒãã®äŸ
var user = new Parse.User(); user.set("username", "my name"); user.set("password", "my pass"); user.set("email", "email@example.com"); // other fields can be set just like with Parse.Object user.set("phone", "415-392-0202"); user.signUp(null, { success: function(user) { // Hooray! Let them use the app now. }, error: function(user, error) { // Show the error message somewhere and let the user try again. alert("Error: " + error.code + " " + error.message); } });
ã¢ã¯ã»ã¹æš©ã¯ãäœæããããªããžã§ã¯ãã«å²ãåœãŠãããšãã§ããACLã«ãã£ãŠåºå¥ãããŸãã ããšãã°ããªããžã§ã¯ãã®ãããªãã¯ãªãŒãã£ã³ã°ãžã®ã¢ã¯ã»ã¹ãèšå®ããŸãããèš±å¯ããããŠãŒã¶ãŒã«ã®ã¿ç·šéãèš±å¯ããŸãã ããã«ãããŒãã«ãæäœããããã®ã¡ãœããã«å¶éãèšå®ã§ããŸãã ããšãã°ãå šå¡ã«ããŒãã«ãžã®æžã蟌ã¿ãèš±å¯ããããšãã§ããŸãããç¹å®ã®ã°ã«ãŒã以å€ã®å šå¡ãžã®èªã¿åããçŠæ¢ã§ããŸãïŒããšãã°ããã°èšé²ã®å ŽåïŒã ãŸãã管çè ã«ã¯ãã¹ã¿ãŒããŒãæäŸãããã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ããå®å šãªã¢ã¯ã»ã¹ãååŸã§ããŸãã ãã ããSPAã§ã¯ãããŒãé衚瀺ã«ã§ããªããããããã¯åãå ¥ããããŸããã ãã¡ãããã¹ããŒã ãç·šéãããããã¹ãŠã®ããŒã¿ã«å¯ŸããŠCRUDæäœãå®è¡ãããã§ãã管çé åããããŸãã
管çè ïŒ
åé¡æ
ãã°ã€ã³ãšãã¹ã¯ãŒãã®ã¿ã«ãããŠãŒã¶ãŒèªèšŒã¯ã倱瀌ã«èŠããããã«ãªããŸããã ãããã£ãŠã parse.comã® SDKã«ã¯Parse.FacebookUtilsã¯ã©ã¹ããããããã䜿çšããŠãŠãŒã¶ãŒã¢ã«ãŠã³ãããœãŒã·ã£ã«ã«ãªã³ã¯ã§ããŸãã ãããã¯ãŒã¯ã ãã ããããã¯ãjavascriptã®parse.com SDKã§äœ¿çšã§ããå¯äžã®ãœãŒã·ã£ã«ãããã¯ãŒã¯ã§ãã TwitterããããŸããã javascript çšã§ã¯ãããŸãã ã ä»ã®ãœãŒã·ã£ã«ãããã¯ãŒã¯ãä»ããŠãŠãŒã¶ãŒãæ¬åœã«èªèšŒããå Žåã®å¯ŸåŠæ¹æ³ã ãããã¯ãŒã¯ïŒ
ã¯ã©ãŠãã³ãŒã
幞ããªããšã«Parse.comã¯ãããŒã¿ãŠã§ã¢ããŠã¹ã ãã§ãªãããµãŒããŒäžã§ã³ãŒããå®è¡ããæ©èœãæäŸããŸãã 圌ãã¯Fichu Cloud CodeãšåŒã°ããŠããŸããã äœæãããé¢æ°ã®ã³ãŒãã¯ãŠãŒã¶ãŒã䜿çšã§ããŸãããã€ãŸããç§å¯ããŒã§çœ²åãããã¯ãšãªãäœæãããšãã«äœ¿çšã§ããŸãã ããããããã¯ããŸã圹ã«ç«ã¡ãŸããã
ç§ã¯ããµã€ãã«æ¢è£œã®ãŠãŒã¶ãŒèªèšŒãŠã£ãžã§ãããåãããµãŒãã¹ãéžæãå§ãã uLoginã«æ±ºããŸãã ã éžæã«ã€ããŠã®ããã€ãã®èšèã Loginzã«ç®ãã€ãããã圌ã¯ãŠãŒã¶ãŒåãšãã¹ã¯ãŒããå ¥åããããèŠæ±ããTwitterçµç±ã§ãã°ã€ã³ããããã«æ±ããããã圌ã«ã¯æºè¶³ããŠããªãã£ãã ããããä»ã«ãããœãŒã·ã£ã«ãªäººãã¡ãããã§ãããã ãã€ãŒããæžãããã®ã¢ã¯ã»ã¹ãèŠæ±ããã¢ããªã±ãŒã·ã§ã³ïŒomgãinfuriatesïŒã ãã®ããã uLoginã«ã¯åªãããœãŒã·ã£ã«ãµãŒãã¹ã»ããããããŸã ã ãããã¯ãŒã¯ãæ¢è£œã®ãŠã£ãžã§ãããjavascriptã®ã³ãŒã«ããã¯é¢æ°ã§accessTokenãè¿ããç¬èªã®ãœãŒã·ã£ã«ãäœæããããšãã§ããŸãã ãŠãŒã¶ãŒèªèšŒã¢ããªã±ãŒã·ã§ã³ã
parse.comã¯ãã°ã€ã³ãšãã¹ã¯ãŒãã§ãŠãŒã¶ãŒãç»é²ããããã«èŠæ±ãããããuLoginã«ãã£ãŠè¿ãããããŒã¿ã䜿çšããŠãã®ãã¢ãååŸã§ãããšããçµè«ã«éããŸããã ãããè¡ãã«ã¯ãé¢æ°ãå®çŸ©ããå¿ èŠãããã¢ããªã±ãŒã·ã§ã³ã§clound / main.jsãã¡ã€ã«ãäœæããŸãã getCredentialsãšåŒã³ãŸãããã
Parse.Cloud.define("getCredentials", function(request, response) { var token = request.params.token; var userLogin, userPassword; response.success({'username': userLogin, 'password': userPassword}); });
uLoginãµãŒãã¹ã䜿çšãããšãè¿ããããã£ãŒã«ãã®ãªã¹ããæ§æã§ããŸã ã ãã ããå¿ èŠãªãã®ã¯æ¬¡ã®ãšããã§ãã
ãããã¯ãŒã¯ -ãŠãŒã¶ãŒã®ãœãŒã·ã£ã«ãããã¯ãŒã¯èå¥åã
ãããã£ãŒã« -ãŠãŒã¶ãŒã®ãããã£ãŒã«ã®ã¢ãã¬ã¹ïŒãœãŒã·ã£ã«ãããã¯ãŒã¯äžã®ãŠãŒã¶ãŒã®ããŒãžãžã®ãªã³ã¯ïŒååŸã§ããå ŽåïŒïŒã
uid-ãœãŒã·ã£ã«ãããã¯ãŒã¯å ã®ãŠãŒã¶ãŒã®äžæã®èå¥åã
identity-ã°ããŒãã«ã«äžæã®ãŠãŒã¶ãŒèå¥åã
identityã¯éåžžã profileã«äŒŒãURLã§ãããããã ãããã¯ãŒã¯ãšuidããã®ãŠãŒã¶ãŒãã°ã€ã³ïŒããã§ã¯ãŠãŒã¶ãŒå ïŒãæ¥çããããšã«ããŸããã
ãã¹ã¯ãŒãã«ã¯ãã£ãšç§å¯ãå¿ èŠãªã®ã§ã identity ã token ã secretã®ããã·ã¥ããã¹ã¯ãŒããšããŠäœ¿çšããããšã«ããŸããã
äžææ§ã®ã¢ã€ãã³ãã£ã㣠ãç§å¯ã®ããŒã¯ã³ ã åuLoginãšã³ããªã¯ããŠãŒã¶ãŒãšuLoginã ããç¥ã£ãŠããæ°ããããŒã¯ã³ãäœæãã ç§å¯ã¯ã¢ããªã±ãŒã·ã§ã³èšå®ã«ä¿åããããœã«ãã§ãã
ãã®æ¹æ³ã¯ã uLoginãä»ããæ°ãããã°ã€ã³ããšã«ãæ°ããããŒã¯ã³ ããããã£ãŠæ°ãããã¹ã¯ãŒããååšããããã äžé©åã§ãã ãããã£ãŠãæ¯åæ°ãããŠãŒã¶ãŒãã¹ã¯ãŒããä¿åããå¿ èŠããããŸãã ãã ãããŠãŒã¶ãŒã®ãã°ã€ã³åŸã parse.comã¯ã»ãã·ã§ã³ãé·æéä¿åãããããæ¯åèªèšŒããå¿ èŠã¯ãããŸããã ã¬ãã£ã¯ã©ãŠãã³ãŒã ã
ãœãªã¥ãŒã·ã§ã³ã®å質ã¯ããªãçããããã®ã§ãããå Žåã«ãã£ãŠã¯éåžžã«æ©èœçã§ãã ããšãã°ããŠãŒã¶ãŒåãšãã¹ã¯ãŒãã§ãŠãŒã¶ãŒã®å ¥åãæåŠããå Žåã ãã ãããã®å Žåã§ããã¡ãœããã¯ãã¡ã€ãã©ã€ãºãããããŒã¯ã³ãåãåã£ãåŸã«ãŠãŒã¶ãŒãã¹ã¯ãŒãã®æŽæ°ãåæ¢ã§ããŸãã å¥ã®ãªãã·ã§ã³ãšããŠãããã¯ããã·ã¥ã®ä»£ããã«äžæçãªãã¹ã¯ãŒããšããŠã©ã³ãã ãªæååã䜿çšããããšã§ãïŒãã®å®çŸã¯å°ãåŸã®ããšã§ãïŒã
ãã¡ãããããŒã¯ã³ã確èªããåŸã uLoginããããŒã¿ãååŸããŠãäžæãã¹ã¯ãŒããçºè¡ãããŸãã ãã®åŸããã®ãã°ã€ã³ãæã€ãŠãŒã¶ãŒããããã©ãããå€æããŸãã ããã§ãªãå Žåã¯ãç»é²ããŸãã ç§ãã¡ã¯åœŒã«ãœãŒã·ã£ã«ããã®ããŒã¿ãæžããŸãã ãªããžããªå ã®ãããã¯ãŒã¯ïŒãšã€ãªã¢ã¹ãã¢ãã¿ãŒïŒããŠãŒã¶ãŒåãšãã¹ã¯ãŒãã®ã«ããã«ãè¿ããŸãã
uLoginããã³c parse.comãšã®å¯Ÿè©±ã¯httpsçµç±ã§è¡ããããã¹ãŠã®ããŒã¿ã¯ãŠãŒã¶ãŒã®ã¿ãå©çšã§ããŸãã
ã¯ã©ã€ã¢ã³ãèªèšŒ
parse.comã§èªèšŒæžã¿ãŠãŒã¶ãŒãååŸããã«ã¯ãããªãã®ã³ãŒããå¿ èŠã§ãã
uLoginãŠã£ãžã§ããã®æ¥ç¶
<script src="//ulogin.ru/js/ulogin.js"></script> <div id="uLogin" data-ulogin="display=small;fields=first_name,last_name;providers=vkontakte,odnoklassniki,mailru,facebook;hidden=other;redirect_uri=&callback=authCallback"></div>
ã³ãŒã«ããã¯é¢æ°ã³ãŒããè¿œå ããŸãã
var user; window.authCallback = function (token) { Parse.Cloud.run('getCredentials', {token: token}, { success: function (data) { Parse.User.logIn(data.username, data.password, { success: function () { user = Parse.User.current(); }, error: function (user, error) { //handle it } }); } }); };
ããã¯ã å ã»ã©ã¯ã©ãŠãã³ãŒãã§èšè¿°ããgetCredentialsãµãŒããŒé¢æ°ã®åŒã³åºããçºçããå Žæã§ãã
ãŠãŒã¶ãŒã次ã«var user = Parse.User.currentïŒïŒ;ã䜿çšããŠãã°ã€ã³ãããšã ãŠãŒã¶ãŒãèªèšŒãããŠãããã©ãããå€æã§ããŸãã ãã®å ŽåãuLoginãŠã£ãžã§ããã¯é衚瀺ã«ããå¿ èŠããããŸãã
parse.comã䜿çšããåäžããŒãžã¢ããªã±ãŒã·ã§ã³ã®é·æãšçæ
é·æ
- ãµããŒããããµãŒããŒã¯ãããŸãã
- ãã¡ã€ã«çšã«20GBãããŒã¿çšã«20GBã2TBãã©ãã£ãã¯ã1ç§ããã30ãªã¯ãšã¹ãããŠãŒã¶ãŒæ°ã«å¶éãªã
- ãµãŒããŒã§jsã³ãŒããå®è¡ããæ©èœ
- ãã¡ã€ã«ã®æäœïŒäœæãã³ã³ãã³ãã®ååŸãURLã®ååŸïŒ
- ã°ã©ããã€ãã³ããªã©ãåããæ¢è£œã®åªããåæã
çæïŒ
- ããŒã¿é 延
- èªåããã¯ã¢ãããªãïŒãã³ããäœæããããã®ãã¿ã³ããããŸãïŒ
- æªäœ¿çšãã¡ã€ã«ã®èªåã¯ãªãŒãã³ã°ã¯ãããŸããïŒãã®ããã®ãã¿ã³ããããŸãïŒ
- ããã¯ãšã³ãèŠæ±ãåæžããèšèšã®å¿ èŠæ§
- 2ã€ã®å€éšãµãŒãã¹ãžã®äŸåïŒparse.comãšuLoginïŒ2çªç®ã®äŸåã¯ãµãŒããŒã§ç°¡åã«çœ®ãæããããšãã§ããŸãïŒ
泚ïŒ
ä»ã®ã¯ã©ã€ã¢ã³ããåãå ¬éããŒã¿ã«æžã蟌ãããšãã§ããŸãã ã¯ã©ã€ã¢ã³ãåŽã§uLoginã䜿çšããŠãŠãŒã¶ãŒãèªèšŒã§ããå ŽåããŠãŒã¶ãŒããŒã¿ã®ç®¡çã«éå£ã¯ãããŸããã æ¬ ç¹ã¯ããªã¯ãšã¹ãæ°ã®å¶éãäžè¬çã§ããããšã§ãã
ãã¢ãããžã§ã¯ã
imhonetãbookmixãlivelibãèŠãŠãèªãã æ¬ãä¿åããããã®ç¬èªã®ãµãŒãã¹ãäœæããããšãèããŸããã ãã®äž»ãªç®çã¯ãè©äŸ¡ãè³Œå ¥ãã«ããŒãªã©ã®äœåãªéã¿ã®ãªãæ¬ã®ãªã¹ãã§ãã ãã®ãããªãµãŒãã¹ãéžæããéãããŒã¿ã¹ãã¬ãŒãžã®ä¿¡é Œæ§ã«é¢å¿ãããããããããžã§ã¯ãã1ã2幎ã§çµäºããããŒã¿ã倱ãããããšã¯ãããŸããã ãããã£ãŠããµãŒãã¹ãéçºãããšãã«ãå€éšã®ç¡æã®ããŒã¿ãŠã§ã¢ããŠã¹ãã€ãŸãBaaSã䜿çšããããšã«ããŸããã ããã«ããããã¹ãã£ã³ã°ã®è²»çšãæ¯æãå¿ èŠããªããªãããœãããŠã§ã¢ã®æŽæ°ã®åé¡ãå¿é ããå¿ èŠããªããªããŸãã ç§ã¯GithubããŒãžã§çµ±èšãä¿æããããšãèšç»ããŸããã ãããããµãŒãã¹ãparse.comã«äŸåãå§ããããããã¹ãã£ã³ã°ã䜿çšããããšã«ããŸããã SPAã«ã€ããŠã¯ãAngularJSã䜿çšããããšã«ããŸããã圌ãç¥ã£ãŠããã圌ã«å¿ èŠãªãã®ãç¥ã£ãŠããããã§ãã ãšã³ãã£ãã£ã®åé¢ãçç¥ããŠãã人ã¯ããããã®éã®å¥åŠãªäŸåé¢ä¿ã«æ°ä»ãã§ãããããAngularJSãããžã§ã¯ãããšã«ãç§ã¯ããã«ã€ããŠäœãæ°ããããšãåŠã³ãŸãã ä»ãç§ã¯ããè¯ãæ¹æ³ãç¥ã£ãŠããŸãã ã¢ã«ãããã¯ç®çã§ã®ã¿æžãæããã®ã¯äžèŠã ãšèããããŸããã
ãœãŒã·ã£ã«ãéããŠã®ã¿ãŠãŒã¶ãŒãç»é²ãããšèšã人ãããŸãã ãããã¯ãŒã¯ã¯ã瀟äŒãžã®ã¢ã¯ã»ã¹ã倱ãããå Žåã«ãããžã§ã¯ããžã®ã¢ã¯ã»ã¹ãåãæ»ãéã«æ·±å»ãªåé¡ãåŒãèµ·ããå¯èœæ§ããããŸãã ãããã¯ãŒã¯ã ãã®åé¡ã¯ãuLoginãèšå®ããŠãŠãŒã¶ãŒã®ã¡ãŒã«ã¢ãã¬ã¹ãå°ããïŒãããŠèªåã§ç¢ºèªããïŒããšã§è§£æ±ºããã¡ãŒã«ã§ã¢ã¯ã»ã¹ã埩å ããŸãã ããããããã¯ãã¢ãããžã§ã¯ãã§ã¯åœãŠã¯ãŸããŸãããèªãã æ¬ã®ãªã¹ãã¯å ¬éãããŠãããããæ·±å»ãªåé¡ãçºçããå Žåã¯ãå¥ã®ã¢ã«ãŠã³ãã«è€è£œããã ãã§ãã
ãœãŒã¹ã³ãŒã
ãã¢
PSïŒãã¢ã¯ç§ã®å¶äœã§ããããªãã«ããããšã¯ã§ããŸããã
Upd ïŒHabraå¹æã¯ãããŸããã§ããããå¶éã®åã«ã¯ãŸã ãããããããŸãïŒã¯ãªãã¯ããŠæ¡å€§ïŒ