2020-06-01ãã1ã¶æéã®è¨äºä¸è¦§
æ£ç´ãï¼ã¶æãé»è»ã«ä¹ã£ã¦ããªãã®ã§ã浦島太éã«ãªã£ãæ°åã åèã®å»å°ã¨é座ã¨æ¯ã¹ãã¨äººãå¤ãããã¤ãããå°ãªãã é座ã¨ããã°çè²·ããã¦ããä¸å½äººã大éã«ããã¨ããã¤ã¡ã¼ã¸ããã£ãã®ã§ãããã¡ãã å ¨ãããªã㦠ããã10å¹´åãããã®é座ã®â¦
Node.jsã®èªè¨¼ã¯JWT(JSON Web Token)ã ã£ãã®ã§Denoãåãããã«ã§ããã¿ãããªã®ã§ãã£ã¦ã¿ããèªè¨¼ç¨ã®DBã¯MongoDBã«ãªãã¾ãã masalib.hatenablog.com ååã®MongoDBã«èªè¨¼ãå ããå½¢ã«ãªã£ã¦ãã¾ããèªè¨¼ã¨ãã¼ã¿ããããªãããã«æ¯åãMongoDBã®è¨å®ãâ¦
Node.jsã®èªè¨¼ã¯JWT(JSON Web Token)ã ã£ãã®ã§Denoãåãããã«ã§ããã¿ãããªã®ã§ãã£ã¦ã¿ããä»åã¯ã¦ã¼ã¶ã¼æ å ±ã¯ãã¼ãã³ã¼ãï¼ãã¸ãã¯ãã³ãã¼ï¼ã«ãªã£ã¦ããã次ãããã«ã¯MongoDBã§ã®èªè¨¼ãããã
mysqlã®REST APIã®ä»çµã¿ãä½ã£ãã®ã§ masalib.hatenablog.com ä»åº¦ã¯MongoDbã®REST APIãä½ãããã¨æãã¾ããè¥å¹²åã®è¨äºã¨ãã¶ãã¨ããã¯ããã®ã¯ãäºæ¿ãã ããã
è±ã®æ ¶æ¬¡ã®çè»ã§ãã å¾ãã¦ã¿ããwww è¡ä¸ã§èªåãä¹ã£ã¦ããã®ããã¬ãã (ã´âï½*)ã·ã¼ãããã ã¨ããããã
Denoã®ã½ã¼ã¹ãä¿®æ£ãããã³ã«ãããã°ã©ã ãæ¢ãã¦èµ·åããã¨ããäºããããªã£ã¦ããã Node.jsã§ã¯nodemonã¨ããã¢ããªã±ã¼ã·ã§ã³ããã£ã¦ã½ã¼ã¹ãä¿®æ£ããã¨èªåçã«åèµ·åãã¦ããããã¼ã«ããã£ãã Denoã«ãèªåçã«åèµ·åãããã¼ã«ãããã®ã§ããã¦â¦
node.jsã§ã¯ããMongoDBã®ãã¼ã¿ãã¨ããµã³ãã«ãããè¦ãã®ã§Denoã§ãMongoDBã«æ¥ç¶ãã¦è¡¨ç¤ºãããã¨æãã¾ã
åèã«ãã¦ããyoutubeãRESTAPIãä½ã£ã¦ããã®ã§ãã¡ããåèã«MYSQLã®RESTAPIãä½ãããã¨æãã¾ãã RESTã®å¦çã®é¨åã¯ããªãåèï¼ã±ããï¼ã«ãã¦ãã
ãªãã§ã ããã»ã»ã» ããã«ãã¬ãã éãå¨ã®åããããã£ã¦ã»ã»ã»ãããããªï½çµæ§ãªæéãç«ã£ã¦ããã ãã© ã ã£ã¦å¯æãã£ããã ãã»ã»ã» ç«ã«ãã§ã®ç«ã ã¨ãããã¨ã§ç«ã«ãã§ã«è¡ã£ã¦æµ®æ°ããã¦ãã¾ããã ãªããç«ã©ãã«ãã¬ã¦ãã¾ãããããããããâ¦
åå,MYSQLã®æ¥ç¶ã®ããã°ã©ã ãæ¸ããã®ã§ããããã¹ã¯ã¼ãã¨ããã½ã¼ã¹ã«æ¸ãã®ã¯æ®éã¯ããªãã§ãããªã®ã§ãããã¤ãèæ ®ãã¦ç°å¢å¤æ°ã«æ¥ç¶æ å ±ãè¨è¼ãã¾ããåèã«ããã®ãHerokuã«ã¢ããããWEBã¢ããªã±ã¼ã·ã§ã³ã ã£ãã®ã§ã³ãã³ããã¼ã¹ã§ãããã¡ã¤â¦
WEBã¢ããªã±ã¼ã·ã§ã³ã¨è¨ã£ããå ã«ãè§ã«ãmysqlã§ããï¼ï¼ ã¨ããäºã§Deno.landã§mysqlã«æ¥ç¶ãã¦ãã¼ã¿ãåå¾ãããã¨æãã¾ã
Hello Worldã§ãµã¼ãã¼ã¯ç«ã¦ã¦ããã®ã§ãã ããã¯ã¡ãã£ã¨éããã¨ãããã¨ã§ node.jsã¨è¨ã£ããexpressã§ããï¼ï¼ expressãkoaã«å½±é¿ããããoakã使ã£ã¦ããã¾ã import {Application,Router} from "https://deno.land/x/oak/mod.ts"; const port = 500â¦
èªã¿æ¸ãã¨æ¸ãã¦ããã®ã§ããæ¸ãããã§ã ãã¡ã¤ã«ã®æ¸ã込㿠const encoder = new TextEncoder() const greetText = encoder.encode("Hello World\nMy Name is Masalib") await Deno.writeFile("greet.txt", greetText) ãã¡ã¤ã«ã«æ¸ãè¾¼ãã«ã¯ãDeno.wriâ¦
ããã³ãã¨ã³ãå´ã¨ããã¯ã¨ã³ãå´ã§ã¡ãã£ã¨æåã«ãªã£ãè¨èªãããã®ã§ããè¨èªã¨è¨ããã·ã¹ãã ãªã®ã§ããdenoã¨ãããã®ãããã¾ã. ã³ã³ã»ããã¨ãã¦ã¯node.jsã®å¼±ç¹ãè£ã£ãå½¢ãããã®ã§ããç§ã¯ãã¾ã触ã£ããã¨ããªãã®ã§å ¥éãã¦ã¿ããã¨æãã¾ããâ¦