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
360
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
290
Other Decks in Programming
See All in Programming
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
170
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
170
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
110
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
150
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
390
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
470
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
120
Composerが「依存解決」のためにどんな工夫をしているか #phpcon
o0h
PRO
1
260
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
130
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
250
XP, Testing and ninja testing
m_seki
3
240
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
680
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
43
7.6k
It's Worth the Effort
3n
185
28k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
GraphQLとの向き合い方2022年版
quramy
49
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
Raft: Consensus for Rubyists
vanstee
140
7k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
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ʙ