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
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
220
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
230
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
240
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
300
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
190
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
1
290
return文におけるstd::moveについて
onihusube
1
1.3k
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1k
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
350
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
180
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
590
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
360
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
460
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
The Cult of Friendly URLs
andyhume
78
6.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Site-Speed That Sticks
csswizardry
2
190
We Have a Design System, Now What?
morganepeng
51
7.3k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Embracing the Ebb and Flow
colly
84
4.5k
How GitHub (no longer) Works
holman
311
140k
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ʙ