Using parse-server for users and auth and call other internal REST web service
<p>We're planning on hosting parse-server internally to service content for a new mobile app we're building.</p>

<p>Also we have some internal REST services that I'd want our mobile clients to use in addition to what we're building in parse.
I'd like to leverage the parse server users, authentication and session management to front a call to these internal REST services.</p>

<p>I find that the cloud code functions are quite limited as they only accept a POST and I'd like a more RESTful api for the clients to use that maps 1-1 to the internal services so I can just pass the request along.
I've create an express middleware function running alongside parse server that just takes an incoming request, changes the base url, adds a new header (auth related) and routes/proxies that request off to the internal webservice.</p>

<p>Firstly would it be possible to get a parse client api to call this other express endpoint?
Secondly, on the server side what would be the best way to authenticate this call.</p>

<p>I've create a simple node.js test file where I sign into the parse server with the javascript/node api and then set the user session-token in a header in a rest client to call this new endpoint but looking for feedback or a better approach.</p>

<pre><code>var express = require('express');
var request = require('request');
var ParseServer = require('parse-server').ParseServer;
...

var api = new ParseServer({
    ...
});

app.use('/parse', api);

// Middleware function to auth request against parse and forward to other  web service
app.use('/api/', function (req, res, next) {

    var currentToken = req.headers['x-parse-session-token'];

    //TODO, validate user token.. HOW BEST?

    if (currentToken) {
        // Query Parse for some user related data to add to request
        // Modify request and forward to other web service
        var newUrl = apiServerHost + req.baseUrl;

        req.pipe(request(newUrl)).pipe(res);

    } else {
        res.send('Unknown parse user');
    }
});
...
</code></pre>