Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An implementation of QVC for node.js

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 node_modules
Octocat-spinner-32 command.js
Octocat-spinner-32 package.json
Octocat-spinner-32 query.js
Octocat-spinner-32 qvc.js


for node.js

This is an implementation of the QVC protocol for node. It supports commands and queries, and simple constraints, but not validation (yet).


Install it from npm using npm install qvc. This will install all needed dependencies

About QVC

QVC is an alternative to REST which adds validation and error handling to ajax requests. It is a protocol on top of the HTTP layer using JSON to encode data in both directions. QVC is short for Query Validation Command, describing the three parts of the protocol. A request to the server can either be a query, where the server should return a result, or a command, where the server should do some action. In both cases the client can send parameters to the server in the form of a JSON object. This JSON object is validated on the server, and the result of the validation is sent to the client in a standardized format. The protocol also provides a way to send validation constraints to the client, for client-side validation of parameters.


There are two parts to using QVC; creating a command/query handler and routing to it. The command/query handler is a function which takes a command/query as its first parameter, and calls the second parameter with the result (standard node.js callback style). For example:

var qvc = require('qvc');

module.exports = {
  load: qvc.query(function(query, done){

    var content = //load data from somewhere...

    done(null, {, content:content});
  save: qvc.command(function(command, done){

    //actually save it

    done(null, true);

This file contains both a command and a query handler, and can be expanded in the future with additional commands and queries. A project can consist of several files like this, with multiple handlers for both commands and queries.

A single routing config file is needed for this to all work. An example is presented here:

var setupQVC = require('qvc').setup;
var handlers = require('./handlers');
var connect = require('connect');
var router = require('urlrouter');

var qvc = setupQVC({
    'load': handlers.load,

connect.use(router(function(app){'qvc/command/:name', qvc.command);'qvc/query/:name', qvc.query);
  app.get('qvc/constraints/:name', qvc.constraints);


Something went wrong with that request. Please try again.