Let's have some command-line fun with curl, [jq][1], and the [new GitHub Search API][2].
Today we're looking for:
/** | |
* Module dependencies | |
*/ | |
var express = require('express'); | |
var fs = require('fs'); | |
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
// img path |
Secure sessions are easy, but not very well documented. | |
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy: | |
The desired configuration for using NginX as an SSL proxy is to offload SSL processing | |
and to put a hardened web server in front of your Node.js application, like: | |
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT] | |
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now. |
# | |
# Working with branches | |
# | |
# Get the current branch name (not so useful in itself, but used in | |
# other aliases) | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# Push the current branch to the remote "origin", and set it to track | |
# the upstream branch | |
publish = "!git push -u origin $(git branch-name)" |
Let's have some command-line fun with curl, [jq][1], and the [new GitHub Search API][2].
Today we're looking for:
httpOnly
(and secure
to true
if running over SSL) when setting cookies.csrf
for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrfbodyParser()
and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer
property and pipe()
the multipart upload stream to the intended destination.For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.
Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon
with HyperThreading enabled, but it can work without problem on slower machines.
You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.
check host localhost with address 127.0.0.1 | |
start "/sbin/start myapp" | |
stop "/sbin/stop myapp" | |
if failed port 3000 protocol HTTP | |
request / | |
with timeout 5 seconds | |
then restart |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)function requireHTTPS(req, res, next) { | |
if (!req.secure) { | |
//FYI this should work for local development as well | |
var domain = "https://" + req.get("host"); | |
if (process.env["SSL_PORT"]) { | |
domain = domain.replace(/:\d+$/, ""); | |
domain += ":" + process.env["SSL_PORT"]; | |
} | |
return res.redirect(domain + req.url); | |
} |