Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Node.jsでシングルページWebアプリケーション
Search
isoda yu
August 22, 2014
Programming
0
350
Node.jsでシングルページWebアプリケーション
第2回 HTML5minutes! 〜triton-js〜 でのLTです。
isoda yu
August 22, 2014
Tweet
Share
More Decks by isoda yu
See All by isoda yu
Web Development with Yeoman
isoden
1
270
Other Decks in Programming
See All in Programming
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
Jakarta EE meets AI
ivargrimstad
0
240
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
200
Macとオーディオ再生 2024/11/02
yusukeito
0
370
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
イベント駆動で成長して委員会
happymana
1
340
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
It's Worth the Effort
3n
183
27k
How STYLIGHT went responsive
nonsquared
95
5.2k
4 Signs Your Business is Dying
shpigford
180
21k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
RailsConf 2023
tenderlove
29
900
Optimizing for Happiness
mojombo
376
70k
A designer walks into a library…
pauljervisheath
204
24k
Transcript
ୈճ)5.-NJOVUFTʂʙUSJUPOKTʙ /PEFKTͰ γϯάϧϖʔδ8FCΞϓϦέʔγϣϯ ా༏ 1
ా༏!JTPEFO@ ·΅Ζ͠ ໊ࣾ ͷϑϩϯτΤϯυΤϯδχΞ ࡀɻ8FCαΠτɾ8FCΞϓϦͱ͔ɻ ࠷ۙ/PEFKT͕Ξπ͍ɻ ࣗݾհ 2
l41"ɺϢʔβ͕ΞϓϦέʔγϣϯΛ͍ͬͯ Δؒɺ8FCϖʔδશମΛϩʔυ͢Δ͜ͱ͕ͳ ͘ɺϨεϙϯε͕ߴͰ6*69ʹ༏Ε͍ͯΔͱ ͍͏རΛ͍࣋ͬͯ·͢ɻz γϯάϧϖʔδ8FCΞϓϦέʔγϣϯ/PEFKTɺ.POHP%#Λ׆༻ͨ͠+BWB4DSJQU41" γϯάϧϖʔδ8&#ΞϓϦέʔγϣϯ 41" 3
41"ͰΑ͘ฉ͘ w ϑϩϯτΤϯυ.7 ϑϨʔϜϫʔΫ w ,OPDLPVU "OHVMBS #BDLCPOF 7VFʜ w
QVTI4UBUFIBTI$IBOHF 4
ࠓ͠·ͤΜʂ 41"ͰΑ͘ฉ͘ w ϑϩϯτΤϯυ.7 ϑϨʔϜϫʔΫ w ,OPDLPVU "OHVMBS #BDLCPOF 7VFʜ
w QVTI4UBUFIBTI$IBOHF 5
41"Ͱͷαʔόʔͷׂ w ೝূͱೝՄ ϢʔβʔೝূͳͲ w σʔλݕূ όϦσʔγϣϯͳͲ w
σʔλετϨʔδͱಉظ σʔλӬଓԽͳͲ 6
4BJMTKT IUUQTBJMTKTPSH 7
4BJMTKT w αʔόʔαΠυ+BWB4DSJQU.7$ϑϨʔϜϫʔΫ w 3VCZ0O3BJMTϥΠΫ w $36%ඪ४ࡌͳͲͳͲػೳ๛ w Πϯετʔϧ<OQNJOTUBMMTBJMTHMPCBM> 8
.PEFMఆٛ TBJMTHFOFSBUFNPEFM.PEFM/BNF<BUUSUZQF BUUSUZQF ʜ> /** * UserModel */ module.exports =
{ attributes: { // Modelͷଐੑఆٛ name : { type: 'string' }, age : { type: 'integer' }, email : { type: 'email' }, gender : { type: 'enum' } } }; 9
$POUSPMMFSఆٛ // $ sails generate controller <ControllerName> [action1, action2, …]
/** * UserController */ module.exports = { /** * `UserController.index()` Userίϯτϩʔϥʔͷ index ΞΫγϣϯ */ index: function (req, res) { User.find({}).exec(function (err, users) { return res.json(users); }); }, /** * `UserController.add()` Userίϯτϩʔϥʔͷ add ΞΫγϣϯ */ add: function (req, res) { return res.view(); } }; 10
ೝূͱೝՄ Ϣʔβʔೝূ 11
ೝূͱೝՄ w QBTTQPSUKT IUUQQBTTQPSUKTPSH w 5XJUUFS'BDFCPPLͳͲͷ4/4ϩάΠϯॲཧ w ৄ͘͠ IUUQOBOUPLBXPSLTDPNTBJMTVTFQBTTQPSU
12
σʔλݕূ όϦσʔγϣϯ 13
BGUFSBMQIBBMQIBEBTIFEBMQIBOVNFSJDBMQIBOVNFSJDEBTIFEBSSBZ CFGPSFCJOBSZCPPMFBODPOUBJOTDSFEJUDBSEEBUFEBUFUJNF EFDJNBMFNBJMFNQUZFRVBMTGBMTFZpOJUFqPBUIFYBEFDJNBM IFY$PMPSJOJOUJOUFHFSJQJQWJQWJTKTPOMFOMPXFSDBTF NBYNBY-FOHUINJONJO-FOHUIOPUOPU$POUBJOTOPU&NQUZ OPU*OOPU/VMMOPU3FHFYOVMMOVNCFSOVNFSJDPCKFDUSFHFY SFRVJSFETUSJOHUFYUUSVUIZVOEFpOFEVOJRVFVQQFSDBTFVSM VSMJTIVVJEVVJEWVVJEW σʔλݕূ 14
/** * UserModel */ module.exports = { attributes: { //
Modelͷଐੑఆٛ name : { type: 'string' }, age : { type: 'integer' }, email : { type: 'email' }, gender : { type: 'enum' } } }; σʔλݕূ 15
σʔλݕূ /** * UserModel */ module.exports = { attributes: {
name: { type: 'string', required: true, unique: true }, age: { type: 'integer', min: 20, }, email: { type: 'email', unique: true } // লུ 16
σʔλετϨʔδͱಉظ σʔλӬଓԽ 17
σʔλετϨʔδͱಉظ 18 /** * UserController ͷ action */ // ৽ن࡞
User.create({ name: 'isoden', age: 20, email: '
[email protected]
', gender: 'male' }).exec(function callback(err, created) { // do something! }); ! // ݕࡧ User.find({}).exec(function callback(err, users) { // do something! });
ϦΫΤετॲཧ༰ /user ɹɹɹɹ => ͯ͢ͷModelΛฦ͢ /user/:id => IDʹϚονͨ͠ModelΛฦ͢ /user?prop1=val1 =>
Model࡞ /user/update/:id?prop1=val1 => IDʹϚονͨ͠Modelͷଐੑߋ৽ /user/destroy/:id => IDʹϚονͨ͠ModelΛআ ! ! add to / create / destroy / find where / find one / populate where / remove from / update σʔλετϨʔδͱಉظ 19
$.get(‘/foo’, callback); Response JSON σʔλετϨʔδͱಉظ 20
ৄ͘͠ʜ w K2VFSZɺFYQSFTTɺNPOHP%# ΛͬͯΤϯυπʔΤϯυ ͷ+BWB4DSJQUઃܭͷղઆ w ͨͬͨϖʔδɺ ԁʜ 21
! ͋Γ͕ͱ͏͍͟͝·ͨ͠! ా༏ 22 ୈճ)5.-NJOVUFTʂʙUSJUPOKTʙ