Express.js: Difference between revisions

From air
Jump to navigation Jump to search
(Created page with "http://expressjs.com <pre> sudo npm install -g express express --help express ls -al </pre>")
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
http://expressjs.com
http://expressjs.com



<pre>
<pre>
sudo npm install -g express
sudo npm install -g express

sudo npm install -g express-generator
express --help
express --help


express
express -e myapp
cd myapp
ls -al
ls -al

sudo npm install
DEBUG=myapp ./bin/www

</pre>
</pre>

Browse http://localhost:3000


==Extra : [[HTTPS]]==
<pre>
mkdir cert
cd cert
openssl genrsa 1024 > key.pem
openssl req -x509 -new -key key.pem > key-cert.pem
</pre>


<pre>
ar express = require('express')
, fs = require('fs')
, routes = require('./routes');

var privateKey = fs.readFileSync('cert/key.pem').toString();
var certificate = fs.readFileSync('cert/key-cert.pem').toString();

// To enable HTTPS
var app = module.exports = express.createServer({key: privateKey, cert: certificate});
..
</pre>

==Ressources==
* [https://github.com/azat-co/cheatsheets/blob/master/express4/index.md Cheatsheet]
* [http://www.manning-source.com/books/cantelon/Node.jsSample08.pdf Chapitre 8 du livre "Node.js in Action", Mannings]

Latest revision as of 19:48, 1 September 2014

http://expressjs.com

sudo npm install -g express

sudo npm install -g express-generator
express --help

express -e myapp
cd myapp
ls -al

sudo npm install
DEBUG=myapp ./bin/www

Browse http://localhost:3000


Extra : HTTPS

mkdir cert
cd cert
openssl genrsa 1024 > key.pem
openssl req -x509 -new -key key.pem > key-cert.pem


ar express = require('express')
  , fs = require('fs')
  , routes = require('./routes');

var privateKey = fs.readFileSync('cert/key.pem').toString();
var certificate = fs.readFileSync('cert/key-cert.pem').toString();  

// To enable HTTPS
var app = module.exports = express.createServer({key: privateKey, cert: certificate});
..

Ressources