var P4NodeApi = require("./lib/p4nodeapi").P4NodeApi; var restify = require('restify'); var p4 = new P4NodeApi({ "user":"matt", "port":"localhost:1666" }); function respond(req, res, next) { res.send('hello ' + req.params.name); } var server = restify.createServer(); server.get('/hello/:name', respond); server.head('/hello/:name', respond); server.get('/user/:name', function (req, res, next) { p4.run(['user','-o', req.params.name], function(e,d){ console.log("Error: \n",e); console.log("Data: \n",d); res.json( 200, JSON.parse(d)); }); }) server.get('/users', function (req, res, next) { p4.run(['users'], function(e,d){ console.log("Error: \n",e); console.log("Data: \n",d); res.json( 200, JSON.parse(d)); }); }) server.listen(8080, function() { console.log('%s listening at %s', server.name, server.url); });
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 8551 | Matt Attaway |
Very rough draft of a node-based web service for Perforce This change adds queries for all the major Perforce metadata objects. It doesn't handle errors in any sort of reasonable manner; all of these commands are just in place to stress the p4nodeapi and help me test it. Far from production quality, but already pretty handy. |
||
#1 | 8548 | Matt Attaway |
Start of a simple node based REST API for Perforce using the p4nodeAPI To run this yourself build the p4nodeapi and then drop the resulting .node file into a directory called lib next to this app.js file. Please note I have no idea what I'm doing. Right now this actually will generate real results but I consider that a happy accident. |