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
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.4k
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
480
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
710
新メンバーも今日から大活躍!SREが支えるスケールし続ける組織のオンボーディング
honmarkhunt
1
250
Systèmes distribués, pour le meilleur et pour le pire - BreizhCamp 2025 - Conférence
slecache
0
120
プロダクト志向なエンジニアがもう一歩先の価値を目指すために意識したこと
nealle
0
120
エンジニア向け採用ピッチ資料
inusan
0
180
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
180
ふつうの技術スタックでアート作品を作ってみる
akira888
0
220
WindowInsetsだってテストしたい
ryunen344
1
210
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
660
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
0
100
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
BBQ
matthewcrist
89
9.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
KATA
mclloyd
30
14k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
500
Bash Introduction
62gerente
614
210k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
Into the Great Unknown - MozCon
thekraken
39
1.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
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ʙ