This is intended to be a very short example of how to use connect-prism as a recording proxy.
Examples of when you might consider using something like this:
-
you are developing against a slow or unreliable server
-
you frequently want to work offline but cannot since you rely on a server
-
you are developing against a moving target
-
you want to test agains specific responses that are hard to recreate on the fly
Open the index.js file:
var connect = require('connect');
var prism = require('connect-prism');
var http = require('http');
prism.create({
name: 'api',
context: '/api',
host: 'localhost', //(1)
port: 8080, //(2)
mode: 'mockrecord' //(3)
});
var app = connect()
.use(prism.middleware)
http.createServer(app).listen(3000); //(4)
-
host: the server name of the server you normally would connect to
-
port: the port number on the server you would normally connect to
-
mode: see https://github.com/seglo/connect-prism for explanations
-
listen(…): here you can specify the port number you want your proxy to listen to