restify

Application 'appname' failed to start (port 8080 not available) on open shift node app

Deadly 提交于 2019-11-27 02:14:13
问题 I have written a node restify server in coffee and I can't seem to get it running. While deploying I get the following error: Waiting for application port (8080) become available ... after which I do get the following error Application 'appname' failed to start (port 8080 not available) If coffeescript seems to be the problem is there a work around it. I would not want to change back to js. My server code is: restify = require 'restify' Bunyan = require 'bunyan' server = restify.createServer

How can I support cors when using restify

被刻印的时光 ゝ 提交于 2019-11-27 01:27:23
问题 I have a REST api created with the restify module and I want to allow cross-origin resource sharing. What is the best way to do it? 回答1: You have to set the server up to set cross origin headers. Not sure if there is a built in use function or not, so I wrote my own. server.use( function crossOrigin(req,res,next){ res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); return next(); } ); I found this from this tutorial. http:/

Error: getaddrinfo ENOTFOUND in nodejs for get call

ε祈祈猫儿з 提交于 2019-11-26 17:36:54
问题 I am running a web server on node the code for which is given below var restify = require('restify'); var server = restify.createServer(); var quotes = [ { author : 'Audrey Hepburn', text : "Nothing is impossible, the word itself says 'I'm possible'!"}, { author : 'Walt Disney', text : "You may not realize it when it happens, but a kick in the teeth may be the best thing in the world for you"}, { author : 'Unknown', text : "Even the greatest was once a beginner. Don't be afraid to take that

mongoError: Topology was destroyed

≡放荡痞女 提交于 2019-11-26 15:10:24
I have a REST service built in node.js with Restify and Mongoose and a mongoDB with a collection with about 30.000 regular sized documents. I have my node service running through pmx and pm2. Yesterday, suddenly, node started crapping out errors with the message "MongoError: Topology was destroyed", nothing more. I have no idea what is meant by this and what could have possibly triggered this. there is also not much to be found when google-searching this. So I thought I'd ask here. After restarting the node service today, the errors stopped coming in. I also have one of these running in

Difference between response.send and response.write in node js

佐手、 提交于 2019-11-26 12:10:00
问题 I have written a small API which uses the Node js \"restify\" framework. This API receives a request (actually anything after \"/\") and then send that request to another server. Get the response back from server and passes the response back to original source of request. For this API I am using both restify server and client. Below is that API code for better understanding. var apiServer = require(\'apiServer\'); apiServer.start(); var restify = require(\'restify\'); var assert = require(\

passport.js RESTful auth

旧城冷巷雨未停 提交于 2019-11-26 09:14:29
问题 How does one handle authentication (local and Facebook, for example) using passport.js, through a RESTful API instead of through a web interface? Specific concerns are handling the passing of data from callbacks to a RESTful response (JSON) vs using a typical res.send({ data: req.data }), setting up an initial /login endpoint which redirects to Facebook (/login cannot be accessed via AJAX, because it is not a JSON response - it is a redirect to Facebook with a callback). I\'ve found https:/