s h a k ra s a nd h o t s to n e t h e ra py ( s h s t )€¦ · java -xmx4g -xms4g -jar app.jar::...
TRANSCRIPT
![Page 1: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/1.jpg)
Shakras and Hot Stone Therapy (SHST)Shakras and Hot Stone Therapy (SHST)
Modern techniques for relaxation using ancient methodsModern techniques for relaxation using ancient methods
(a hands-on approach)(a hands-on approach)
1 . 1
![Page 2: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/2.jpg)
Server Architectures with NodeServer Architectures with Node
Why should the browser folk have all the fun?Why should the browser folk have all the fun?
1 . 2
![Page 3: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/3.jpg)
Your friendly presenterYour friendly presenter
Jeffrey [email protected], Chariot SolutionsSomewhat Recent Javascript Convert
1 . 3
![Page 4: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/4.jpg)
Javascript Convert?Javascript Convert?
1 . 4
![Page 5: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/5.jpg)
Javascript Convert?Javascript Convert?
Actually, yesActually, yes
1 . 4
![Page 6: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/6.jpg)
However, there's beauty in thereHowever, there's beauty in there
1 . 5
![Page 7: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/7.jpg)
However, there's beauty in thereHowever, there's beauty in there
This may take a bit of time to �nd.This may take a bit of time to �nd.
1 . 5
![Page 8: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/8.jpg)
E�cient use of resources makes me happy.E�cient use of resources makes me happy.
2 . 1
![Page 9: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/9.jpg)
E�cient use of resources makes me happy.E�cient use of resources makes me happy.
(hapi?)
2 . 1
![Page 10: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/10.jpg)
This thing is This thing is thinthin
2 . 2
![Page 11: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/11.jpg)
Customer production server from pm2:
$ pm2 status │ SERVER (PROD) │ online | 12D │ 0% │ 148.7 MB |
2 . 3
![Page 12: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/12.jpg)
Customer production server from pm2:
12 days of uptime12 days of uptime
$ pm2 status │ SERVER (PROD) │ online | 12D │ 0% │ 148.7 MB |
2 . 3
![Page 13: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/13.jpg)
Customer production server from pm2:
12 days of uptime12 days of uptime
150MB of RAM!150MB of RAM!
$ pm2 status │ SERVER (PROD) │ online | 12D │ 0% │ 148.7 MB |
2 . 3
![Page 14: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/14.jpg)
java -Xmx4G -Xms4G -jar app.jar
:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for 24.811)
2 . 4
![Page 15: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/15.jpg)
Single threadedSingle threaded
2 . 5
![Page 16: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/16.jpg)
Code isomorphism between client and serverCode isomorphism between client and server
If you use JS on the client...If you use JS on the client...
2 . 6
![Page 17: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/17.jpg)
Fun to write, to be honestFun to write, to be honest
2 . 7
![Page 18: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/18.jpg)
JS is a gateway drug to LambdaJS is a gateway drug to Lambda
2 . 8
![Page 19: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/19.jpg)
Node architecture makes me happyNode architecture makes me happy
3 . 1
![Page 20: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/20.jpg)
Node architecture makes me happyNode architecture makes me happy
(hapi?)
3 . 1
![Page 21: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/21.jpg)
Node was born from two neat pieces ofNode was born from two neat pieces oftechnologytechnology
3 . 2
![Page 22: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/22.jpg)
Node was born from two neat pieces ofNode was born from two neat pieces oftechnologytechnology
libuvlibuv
3 . 2
![Page 23: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/23.jpg)
Node was born from two neat pieces ofNode was born from two neat pieces oftechnologytechnology
libuvlibuv
v8v8
3 . 2
![Page 24: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/24.jpg)
3 . 3
![Page 25: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/25.jpg)
3 . 4
![Page 26: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/26.jpg)
v8v8 & & shakrashakra
3 . 5
![Page 27: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/27.jpg)
libuvlibuv
3 . 6
![Page 28: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/28.jpg)
Only a matter of timeOnly a matter of time
3 . 7
![Page 29: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/29.jpg)
What, exactly, is it good for?What, exactly, is it good for?
3 . 8
![Page 30: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/30.jpg)
IOIO
3 . 9
![Page 31: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/31.jpg)
IOIO
Like, Like, tonstons of IO of IO
3 . 9
![Page 32: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/32.jpg)
3 . 10
![Page 33: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/33.jpg)
Try not to do too muchTry not to do too much
All CPU use on node is crimethinkAll CPU use on node is crimethink
Get in, get outGet in, get out
3 . 11
![Page 34: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/34.jpg)
A humorous vingette...A humorous vingette...
3 . 12
![Page 35: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/35.jpg)
bcrypt(3)bcrypt(3)!!!!!!!!!!
3 . 13
![Page 36: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/36.jpg)
WARNING:WARNING:
Handrails are not availableHandrails are not available
3 . 14
![Page 37: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/37.jpg)
There really is only one real method in nodeThere really is only one real method in nodethat matters.that matters.
3 . 15
![Page 38: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/38.jpg)
There really is only one real method in nodeThere really is only one real method in nodethat matters.that matters.
on()on()
3 . 15
![Page 39: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/39.jpg)
3 . 16
![Page 40: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/40.jpg)
Looks familiar?Looks familiar?
server.on('request', (req, res) => { // node HTTP server }) observer.subscribe((x) => { // Angular HttpClient })
3 . 17
![Page 41: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/41.jpg)
The fundamental unit of javascript is theThe fundamental unit of javascript is thecontinuationcontinuation..
Javascript is a Javascript is a continuation orientedcontinuation orientedlanguage.language.
3 . 18
![Page 42: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/42.jpg)
whenItIsDone(thing, (result) => { doSomethingElse(result) })
3 . 19
![Page 43: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/43.jpg)
const fs = require('fs') fs.readFile('./foo.txt', 'utf8', (err, contents) => { console.log(contents) });
3 . 20
![Page 44: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/44.jpg)
The The continuationcontinuation is a lambda is a lambda
3 . 21
![Page 45: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/45.jpg)
The The continuationcontinuation is a lambda is a lambda
It executes later.It executes later.
3 . 21
![Page 46: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/46.jpg)
The The continuationcontinuation is a lambda is a lambda
It executes later.It executes later.
You can never get here from there.You can never get here from there.
3 . 21
![Page 47: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/47.jpg)
(err, contents) => { console.log(contents) });
3 . 22
![Page 48: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/48.jpg)
fs.readFile('./foo.txt', 'utf8', (err, contents) => { console.log(contents) }); fs.readFile('./bar.txt', 'utf8', (err, contents) => { console.log(contents) });
3 . 23
![Page 49: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/49.jpg)
This is the beauty of nodejsThis is the beauty of nodejs
Handle your result Handle your result
3 . 24
![Page 50: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/50.jpg)
This is the beauty of nodejsThis is the beauty of nodejs
Handle your result Handle your result laterlater
3 . 24
![Page 51: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/51.jpg)
Man, it can get ugly fastMan, it can get ugly fast
4 . 1
![Page 52: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/52.jpg)
const fs = require('fs') const dns = require('net') fs.readFile('./foo.txt', 'utf8', (err, contents) => { fs.writeFile('./bar.txt', 'utf8', (err, contents) => { dns.lookup(contents, (err, address, family) => { console.log(address) }) }) })
4 . 2
![Page 53: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/53.jpg)
do(foo, bar => { some(bar, baz => { thing(baz, quux => { complex(quux, quuz => { eventually(quuz, waldo => { go(waldo, fred => { crazy(fred, thud => { console.log(thud) }) }) }) }) }) }) })
4 . 3
![Page 54: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/54.jpg)
Promises are syntactic sugarPromises are syntactic sugar
4 . 4
![Page 55: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/55.jpg)
do(foo) .then(bar => { some(bar) }).then(baz => { thing(baz) }).then(quux => { complex(quux) }).then(quuz => { eventually(quuz) }).then(waldo => { go(waldo) }).then(fred => { crazy(fred) }).then(thud => { console.log(thud)
4 . 5
![Page 56: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/56.jpg)
asyncasync / / awaitawait are the new hotness are the new hotness
4 . 6
![Page 57: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/57.jpg)
try{ const bar = await do(foo) const baz = await some(bar) const quux = await thing(baz) const quuz = await complex(quux) const waldo = await eventually(quuz) const fred = await go(waldo) const thud = await crazy(fred) console.log(thud) }catch(err){ // whoops }
4 . 7
![Page 58: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/58.jpg)
const p = do(foo); const bar = await p;
4 . 8
![Page 59: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/59.jpg)
const util = require('util') const readFileAsync = util.promisify(fs.readFile) const contents = await readFileAsync('./foo.txt', 'utf8')
4 . 9
![Page 60: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/60.jpg)
4 . 10
![Page 61: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/61.jpg)
4 . 11
![Page 62: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/62.jpg)
const f = (a, b) => { return a + b } const p = f('a', ?) assert(p('b') === 'ab')
4 . 12
![Page 63: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/63.jpg)
Let's do some actual Let's do some actual workwork..
5 . 1
![Page 64: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/64.jpg)
REST serversREST servers
ExpressHAPIRestifyLoopbackSails... probably a baker's dozen more by now
5 . 2
![Page 65: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/65.jpg)
Express.js is the gold standardExpress.js is the gold standard
Does whatcha needDoes whatcha need
5 . 3
![Page 66: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/66.jpg)
const express = require('express') const app = express() const port = 80 app.get('/', (req, res) => res.send('Hello World!')) app.listen(port, () => console.log(`Example app listening on por
5 . 4
![Page 67: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/67.jpg)
C'mon get HAPIC'mon get HAPI
5 . 5
![Page 69: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/69.jpg)
Things to likeThings to like
In this desolate wasteland of In this desolate wasteland of ~0.0.9~0.0.9
5 . 7
![Page 70: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/70.jpg)
Vibrant plugins, easy API to write your ownVibrant plugins, easy API to write your own
goodboomnescon�dencepoopbellblipp
5 . 8
![Page 71: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/71.jpg)
server.route({ method: 'GET', path: '/', handler: function (request, h) { return 'Hello!' } })
5 . 9
![Page 72: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/72.jpg)
hapi ❤ joihapi ❤ joi
const session = joi.object().keys({ id: joi.number().integer().min(1).required(), name: joi.string().trim(true).min(1).required(), date: joi.string().trim(true).isoDate().required() })
5 . 10
![Page 73: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/73.jpg)
method: 'GET', options: { tags: ['api'], description: 'Gets all subscriptions for a session', path: '/session/{id}/subscriptions', validate: { params: { id: joi.number().integer().min(1) } },
5 . 11
![Page 74: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/74.jpg)
response: { options: { abortEarly: false }, sample: 100, schema: joi.array().items(joiSchemas.registration) }
5 . 12
![Page 75: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/75.jpg)
"/api/session": { "get": { "responses": { "default": { "description": "", "schema": { "type": "array", "items": { "$ref": "#/definitions/IdNameDateModel" } } } }, "produces": ["application/json"], "tags": ["api"],
5 . 13
![Page 76: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/76.jpg)
![Page 77: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/77.jpg)
5 . 14
![Page 78: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/78.jpg)
Stupid node tricks with hapi, express, andStupid node tricks with hapi, express, andwebsocketswebsockets
5 . 15
![Page 79: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/79.jpg)
const hapi = require('hapi') const ws = require('ws') const server = new hapi.Server({port: 8000}) const listener = server.listener const wss = new WebSocket.Server({ server: listener, path: '/api/chat' }) await server.start()
5 . 16
![Page 80: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/80.jpg)
this._removeListeners = addListeners(this._server, { listening: this.emit.bind(this, 'listening'), error: this.emit.bind(this, 'error'), upgrade: (req, socket, head) => { this.handleUpgrade(req, socket, head, (ws) => { this.emit('connection', ws, req); }); } });
5 . 17
![Page 81: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/81.jpg)
server.events.on('log', (event, tags) => { server.events.on('request', (request, event, tags) => { server.events.on('response', (request) => {
5 . 18
![Page 82: S h a k ra s a nd H o t S to n e T h e ra py ( S H S T )€¦ · java -Xmx4G -Xms4G -jar app.jar:: Spring Boot :: (v2.0.3.RELEASE) Started TestApp in 24.351 seconds (JVM running for](https://reader033.vdocuments.us/reader033/viewer/2022042217/5ec0349e04992a539862969c/html5/thumbnails/82.jpg)
Takeaway (whew!)Takeaway (whew!)
Understand on()Grok continuations, how code moves through nodeNever eat CPU.Use cool language featuresBe Javascripty on the server
6