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
Newbie on Node
Search
Edvinas
February 19, 2014
Programming
0
180
Newbie on Node
My experience starting to build side project with Node. Presented in Vilnius.JS meetup.
Edvinas
February 19, 2014
Tweet
Share
More Decks by Edvinas
See All by Edvinas
Peak of a Programmer
edvinasbartkus
1
110
Other Decks in Programming
See All in Programming
猫と暮らす Google Nest Cam生活🐈 / WebRTC with Google Nest Cam
yutailang0119
0
160
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
810
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
200
TypeScriptでDXを上げろ! Hono編
yusukebe
3
650
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
280
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
340
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
840
生成AI時代のコンポーネントライブラリの作り方
touyou
1
260
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
450
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
910
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
130
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
750
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
173
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
700
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Thoughts on Productivity
jonyablonski
69
4.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
KATA
mclloyd
30
14k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Designing Experiences People Love
moore
142
24k
Transcript
node.js newbie
Chapter #0
Chapter #0 What I want to say?
None
None
Chapter #1
About newbie
Find me github.com/edvinasbartkus
None
None
None
Chapter #2
Chapter #2
⚡ which node /usr/local/bin/node
⚡ which node /usr/local/bin/node
⚡ npm install something ⚡ ls -l drwxr-xr-x node_modules/
⚡ npm install -g something
⚡ cat package.json { "name": "commentreader", "version": "0.0.1", "main": "app.js",
"scripts": { "test": "./node_modules/.bin/mocha --recursive -R xunit test/ > test-reports.xml", "migrate": "./node_modules/.bin/db-migrate up" }, "dependencies": { "express": "3.4.8", "knex": "~0.5.4", "bookshelf": "~0.6.2", "pg": "~2.11.1", "socket.io": "~0.9.16", "htmlparser2": "~3.4.0", "minreq": "~0.2.3", "request": "~2.33.0" }, "devDependencies": { "grunt": "~0.4.2", "grunt-express-server": "~0.4.11", "grunt-contrib-watch": "~0.5.3", "grunt-contrib-concat": "~0.3.0", "should": "~3.1.0", "supertest": "~0.9.0", "mocha": "~1.17.1", "db-migrate": "~0.6.3" } }
CODE STRUCTURE Gruntfile.js Procfile README.md app/ - domains/ - models/
- routes/ - views/ app.js browser/ - components/ - controllers/ - views/ - main.js config.js database.json migrations/ node_modules/ package.json public/ test/ worker.js
// Express var app = express(); app.configure(function () { app.use(express.logger('dev'));
app.use(express.bodyParser()); ! var viewsDir = path.join(__dirname + ‘/browser/views'); app.use(‘/views', express.static(viewsDir)); ! var publicDir = path.join(__dirname + ‘/public'); app.use(express.static(publicDir)); }); EXPRESS
// Routes var pages = require('./app/routes/pages'); app.get('/pages', pages.findAll); app.get('/pages/:id', pages.findById);
app.post('/pages', pages.addPage); EXPRESS ROUTES
// Server var server = app.listen(config.port); ! // Sockets var
sockets = require('./app/sockets')(server); RUN & ATTACH SOCKETS
'use strict'; ! var socket = require('socket.io'); ! module.exports =
function (app) { var io = socket.listen(app, { log: false }); io.on('connection', function (socket) { console.log('User connected'); }); ! // socket.join('room:test'); return io; }; SOCKETS.IO
Chapter #3
Chapter #3
T H E W E B ' S S C
A F F O L D I N G T O O L F O R M O D E R N W E B A P P S
None
Chapter #3.1
Chapter #3.1
GRUNT
Chapter #4
Chapter #4
None
'use strict'; ! var should = require('should'); var app =
require('./../app.js'); ! describe('Existance', function () { it('should exist', function (done) { should.exist(app); done(); }); });
! var should = require('should'); var request = require('supertest'); var
app = require('./../app.js'); ! describe('Pages API', function () { it('GET /pages 200', function (done) { request(app) .get('/pages') .expect(200, done); });
⚡ mocha test/ ! ․․․ ! 3 passing (85ms)
BUSTER.JS INTERN.JS
None
None
Have you met Jenkins?
None
⚡ cat package.json { "main": "app.js", "scripts": { "test": “./node_modules/.bin/mocha
--recursive -R xunit test/ > test-reports.xml”, ! "migrate": "./node_modules/.bin/db-migrate up" }, "dependencies": { }, "devDependencies": { } }
Chapter #Lost_Nmbr.2
None
Free 1 dyno ! !
Free 1 dyno 512mb ram !
Free 1 dyno 512mb ram 4 (virtual) CPU cores Intel
Xeon X5550 @ 2.67GHz
Free 1 dyno 750 free hours !
⚡ cat Procfile web: node app.js
⚡ cat Procfile web: node app.js worker: node worker.js
Heroku idles
Heroku idles Do you remember Jenkins?
Heroku idles Pingdom is also cool
Deploy in 6 seconds
Do not use console.log http://micheljansen.org/blog/entry/1698
Redis & RabbitMQ & Postgres
None
What is the right path?
None
None
Chat Chapter irc.freenode.org #VilniusJS