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
技術同人誌をMCP Serverにしてみた
74th
1
640
XP, Testing and ninja testing
m_seki
3
240
“いい感じ“な定量評価を求めて - Four Keysとアウトカムの間の探求 -
nealle
1
10k
PipeCDのプラグイン化で目指すところ
warashi
1
270
プロダクト志向なエンジニアがもう一歩先の価値を目指すために意識したこと
nealle
0
130
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
1
5.6k
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
190
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
130
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
250
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
2
150
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
150
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
760
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Writing Fast Ruby
sferik
628
62k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Music & Morning Musume
bryan
46
6.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Designing Experiences People Love
moore
142
24k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
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ʙ