Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.
Use npm
to install Mocha:
npm install mocha
package mongo | |
import ( | |
"time" | |
"log" | |
"gopkg.in/mgo.v2" | |
"gopkg.in/mgo.v2/bson" | |
) | |
// Profile - is the memory representation of one user profile |
Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.
Use npm
to install Mocha:
npm install mocha
// controllers/LoginController.js | |
module.exports = { | |
index: function(req, res) { | |
var email = req.param('email'); | |
var password = req.param('password'); | |
// delay everthing to prevent bruteforce, dos and timing attacks | |
setTimeout(function() { |
Here's all you have to do to add clustering to your node.js application.
cluster.js
, and run cluster.js
instead of server.js
(or /bin/www, or whatever it's called for your project)server.js
filevar cluster = require('cluster');
if (cluster.isMaster) {
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;
func doPut(url string) { | |
client := &http.Client{} | |
request, err := http.NewRequest("PUT", url, strings.NewReader("<golang>really</golang>")) | |
request.SetBasicAuth("admin", "admin") | |
request.ContentLength = 23 | |
response, err := client.Do(request) | |
if err != nil { | |
log.Fatal(err) | |
} else { | |
defer response.Body.Close() |
This tutorial uses the "Sample hapi.js REST API" project.
Take a look at: https://github.com/agendor/sample-hapi-rest-api/
##Topics
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt |
/** | |
* Find Records | |
* | |
* An API call to find and return model instances from the data adapter | |
* using the specified criteria. If an id was specified, just the instance | |
* with that unique id will be returned. | |
* | |
* @param {Integer|String} id - the unique id of the particular instance you'd like to look up | |
* @param {Object} where - the find criteria (passed directly to the ORM) | |
* @param {Integer} limit - the maximum number of records to send back (useful for pagination) |
package main | |
import ( | |
"os" | |
"log" | |
"net" | |
"strconv" | |
"strings" | |
) |