More Related Content
Similar to Артем Маркушев - JavaScript
Similar to Артем Маркушев - JavaScript (20)
Артем Маркушев - JavaScript
- 3. JS for Backend
Backend / NodeJS / Express vs Geddy
NodeJSconsole.log(‘Hello world!') $ node helloworld.js
Helloworld.js
- 6. Backend / NodeJS / Express vs Geddy
Express vs Geddy
$ npm install express
$ npm install express-generator –g
$ express myapp
$ cd myapp && npm install
$ node app.js
$ npm install -g geddy
$ geddy gen app to_do
$ cd to_do && geddy
- 7. Backend / NodeJS / Express vs Geddy
$ npm install express
$ npm install express-generator –g
$ express myapp
$ cd myapp && npm install
$ node app.js
$ npm install -g geddy
$ geddy gen app to_do
$ cd to_do && geddy
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
var server = app.listen(3000, function () {
var host = server.address().address
var port = server.address().port
console.log('Example app listening at http://%s:%s', host, port)
})
var config = {
detailedErrors: true
, debug: true
, hostname: null
, port: 4000
, model: {
defaultAdapter: 'filesystem'
}
, sessions: {
store: 'memory'
, key: 'sid'
, expiry: 14 * 24 * 60 * 60
}
};
var ToDo = function () {
...
// Add this inside the constructor function
this.validatesPresent('title');
this.validatesLength('title', {min: 5});
...
- 33. Socket.io
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendfile('index.html');
});
io.on('connection', function(socket){
console.log('a user connected');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
Backend Frontend