Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "censeo", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Run arbitrary JavaScript or PogoScript on a server", | ||
"author": "Derek Ekins <derek@spathi.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/dereke/censeo.git" | ||
}, | ||
"scripts": { | ||
"test": "node_modules/karma/bin/karma start" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/dereke/censeo/issues" | ||
}, | ||
"keywords": [ | ||
"eval", | ||
"runtime", | ||
"test", | ||
"mocha", | ||
"pogo" | ||
], | ||
"main": "index.js", | ||
"files": [ | ||
"server.js", | ||
"client.js" | ||
"index.js", | ||
"lib/server.js", | ||
"lib/client.js" | ||
], | ||
@@ -17,16 +33,16 @@ "license": "ISC", | ||
"socket.io": "^1.0.6", | ||
"express": "^4.4.5", | ||
"socket.io-client": "^1.0.6", | ||
"bluebird": "^2.1.3" | ||
"bluebird": "2.1.1" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^4.2.0", | ||
"karma": "^0.12.16", | ||
"karma-browserify": "^0.2.1", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^0.1.4", | ||
"karma-mocha": "^0.1.4", | ||
"mocha": "^1.20.1", | ||
"karma-mocha": "^0.1.4", | ||
"browserify": "^4.2.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-browserify": "^0.2.1", | ||
"pogoify": "^0.1.0" | ||
"pogoify": "^0.1.0", | ||
"reqwest": "^1.1.0" | ||
} | ||
} |
127
Readme.md
@@ -7,2 +7,127 @@ # censeo | ||
Preferable only in test code | ||
Preferable only in test code | ||
# Insructions | ||
First of all you need to start up the server specifying a port number to use. | ||
If you are using karma you may want to put this in your `karma.conf.js` file. | ||
``` | ||
require('censeo').server(3001) | ||
``` | ||
Next you want to create a client: | ||
``` | ||
client = require('censeo').client(3001) | ||
``` | ||
Then in your test (you should only use this for tests!). | ||
``` | ||
client | ||
.run(function() { | ||
return 1 + 1; | ||
}).then(function(result){ | ||
expect(result).to.equal(2) | ||
}) | ||
``` | ||
You can also run async code on the server | ||
``` | ||
client | ||
.run(function(callback) { | ||
var fs = require("fs"); | ||
fs.readdir(process.cwd(), callback); | ||
}).then(function(result) { | ||
expect(result).to.include("node_modules"); | ||
}); | ||
``` | ||
Where censeo can come in really handy is if you need to spool up a webserver to test against: | ||
``` | ||
client | ||
.run(function() { | ||
var http, app, server; | ||
http = require("http"); | ||
app = http.createServer(function(req, res) { | ||
var headers; | ||
headers = { | ||
"Content-Type": "text/plain", | ||
Connection: "Close", | ||
"Access-Control-Allow-Headers": "accept, x-requested-with, content-type", | ||
"Access-Control-Allow-Methods": "GET, OPTIONS", | ||
"Access-Control-Allow-Origin": req.headers.origin | ||
}; | ||
if (req.method === "OPTIONS") { | ||
res.writeHead(204, headers); | ||
return res.end("OK"); | ||
} else { | ||
res.writeHead(200, headers); | ||
return res.end("ALIVE"); | ||
} | ||
}); | ||
server = app.listen(8555); | ||
console.log("listening on 8555"); | ||
return { | ||
stop: function(done) { | ||
var self = this; | ||
return server.close(done); | ||
} | ||
}; | ||
}, { | ||
task: true | ||
}).then(function(task){ | ||
// make some http requests to the server | ||
// then stop the server | ||
task.stop(function(){ | ||
console.log('stopped') | ||
}) | ||
}) | ||
``` | ||
# [PogoScript](http://pogoscript.org) | ||
PogoScript makes using censeo even better: | ||
``` | ||
result = client.run! @{1+1} | ||
expect(result).to.equal(2) | ||
``` | ||
or to run a web server | ||
``` | ||
task = client.run!(task: true) | ||
http = require 'http' | ||
app = http.createServer @(req, res) | ||
headers = { | ||
'Content-Type' = 'text/plain' | ||
'Connection' = 'Close' | ||
'Access-Control-Allow-Headers' = 'accept, x-requested-with, content-type' | ||
'Access-Control-Allow-Methods' = 'GET, OPTIONS' | ||
'Access-Control-Allow-Origin' = req.headers.origin | ||
} | ||
if (req.method == 'OPTIONS') | ||
res.writeHead(204, headers) | ||
res.end('OK') | ||
else | ||
res.writeHead(200, headers) | ||
res.end('ALIVE') | ||
server = app.listen(8555) | ||
console.log "listening on 8555" | ||
{ | ||
stop(done)= | ||
server.close(done) | ||
} | ||
server url = 'http://localhost:8555' | ||
response = request!({url = server url}) | ||
expect(response).to.equal('ALIVE') | ||
task.stop!() | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
12145
4
5
193
1
132
0
9
4
+ Addedbluebird@2.1.1(transitive)
- Removedexpress@^4.4.5
- Removedaccepts@1.3.8(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.2(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removeddunder-proto@1.0.0(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedexpress@4.21.2(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedmath-intrinsics@1.0.0(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@1.6.0(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.12(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedqs@6.13.0(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedunpipe@1.0.0(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removedvary@1.1.2(transitive)
Updatedbluebird@2.1.1