parse server 에 REST API 확장? 공사하였습니다.

이번에 저희 앱에 비디오 컨텐츠 포스팅 기능을 추가하느라…
클라우드용 트랜스코더를 이용을 했는데…
트랜스코딩 결과를 받기위해서는 특정포트(3000번)로 http post를 처리해줄 서버가 필요하더군요.
따로 그거만 처리하는 웹서버를 만들기 거시기 해서…걍 parse server에 http 서버를 추가해서 아래와 같이 만들었습니다.

app.post('/zencoder', function(req, res) {

   req.accepts('application/json');
   // input message handling
   var json = req.body;
   var jobId = json.job.id.toString();
   console.log("zencoder notification job id:" + jobId + ", status:" + json.job.state);

//  doing something...

   res.status(202).send( {message: "Thanks, Zencoder! We will take it from here."});
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

var httpServer2 = require('http').createServer(app);
httpServer2.listen(3000, function() {
    console.log("zencoder notifications ready on port 3000");
});

테스트 결과 동작은 문제없이 잘되는거 같은데…먼가 좀 찜찜하다는…
더 좋은 방법이 있을까요? ^^

글을 쓰다 보니 parse app 에 추가할게 아니라 아예 인스턴스를 그냥 따로 만드는게 나을거 같네요.

parse를 확장하시기는 했지만,

어쨌든 express 를 사용하신거니, 몇개를 추가하시던 상관없습니다.

다만 저렇게 하면 node프로세스는 한개만 뜰거에요.

전 아예 nginx가 프록시하도록 해서 parse서버자체를 여러개 띄워서 쓰고 있어요.