Questions tagged [restify]

restify is a module for use with node.js that facilitates the creation of REST web services.

Filter by
Sorted by
Tagged with
176 votes
18 answers
169k views

mongoError: Topology was destroyed

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. ...
dreagan's user avatar
  • 2,436
158 votes
3 answers
50k views

passport.js RESTful auth

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 ...
ryanrhee's user avatar
  • 2,560
105 votes
6 answers
92k views

Why should I use Restify?

I had the requirement to build up a REST API in node.js and was looking for a more light-weight framework than express.js which probably avoids the unwanted features and would act like a custom-built ...
Mithun Satheesh's user avatar
88 votes
12 answers
405k views

Error: getaddrinfo ENOTFOUND in nodejs for get call

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 : "...
nnm's user avatar
  • 1,395
60 votes
4 answers
105k views

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

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 ...
user3275959's user avatar
47 votes
14 answers
39k views

How can I support cors when using restify

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?
Kim's user avatar
  • 4,613
39 votes
2 answers
17k views

What's the best practice for MongoDB connections on Node.js?

This is something that is a bit unclear to me (I'm just getting started with Node and Mongo), and it really concerns me because of server performance and strain (which I guess is another question, but ...
arturovm's user avatar
  • 1,235
33 votes
7 answers
29k views

Serving static files with restify

I am learning to use Node.js. Currently, I have a folder structure that looks like the following: index.html server.js client index.html subs index.html page.html res css style.css ...
Node Newbie's user avatar
  • 1,971
29 votes
3 answers
27k views

How to parse/read multiple parameters with restify framework for Node.JS

Scenario: We developer are trying to replace a web service (written in C#.Net) with Node.JS Restful API. Issue: Now we need to handle the incoming request as is (we don't have control over it). So ...
Amol M Kulkarni's user avatar
24 votes
3 answers
10k views

serving static files with restify (node.js)

I have the following code: app.js [...] server.get(/\/docs\/public\/?.*/, restify.serveStatic({ directory: './public' })); server.listen(1337, function() { console.log('%s listening at %s', ...
opensas's user avatar
  • 61.8k
21 votes
4 answers
15k views

how do you send html with restify

I want to send plain html instead of a json response for one of my routes in restify. I tried setting the contentType and header property of the response but it doesn't seem to set the contentType in ...
MonkeyBonkey's user avatar
  • 47.2k
19 votes
5 answers
38k views

I need to replace Bearer from the header to verify the Token

bearer = bearerHeader.replace("Bearer",""); jwt.verify(bearer, 'super_secret', function (err, decoded) { console.log(err); console.log(decoded); }); Here is my code. Whenever I try to verify ...
Nainesh Raval's user avatar
19 votes
9 answers
13k views

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

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 ...
philip_nunoo's user avatar
19 votes
1 answer
7k views

Creating an OAuth2.0 service provider using RESTify Node.js

I have a restful API that I built using node.js and node-restify. I am up to the part where I have to secure it. Apparently, it is easy to find out how to use OAuth 2.0 as a client but hard to find ...
whattupyo's user avatar
  • 373
18 votes
2 answers
7k views

Manage errors in Restify

How i can manage all error of my restful server build with Restify of NodeJS? For example internal errors, database errors, validate, required params, not founds, athorizeds... And uncaughtException ...
user1710825's user avatar
17 votes
6 answers
18k views

Is there a way to log every request in the console with restify?

I'm using restify to build an API, and I'm used to express. Is there a way to have restify log every request in the console, like express does with app.use(express.logger('dev'))?
Samuel Bolduc's user avatar
17 votes
2 answers
18k views

How to avoid fast memory increase during scavenge gc?

I have an application built on restify. I have no memory leaks, however I have big memory growth during scavenge gc, then comes heavy weight mark-sweep gc and cleans the memory. It affects ...
Vlad Miller's user avatar
  • 2,278
16 votes
2 answers
13k views

restify optional route parameters

Hi I have an routing issue with restify.io It seems like restify does not support the "?" for optional parameters as express.js does. server.get('/users',function(req,res,next){}); server....
silverfighter's user avatar
15 votes
2 answers
12k views

Redirecting client with NodeJS and Restify

I'm building a REST backend for an SPA with NodeJS, Restify and PassportJS for authentication. Everything's working except the last step, which is redirecting the client from the backends /login/...
Routhinator's user avatar
  • 3,649
14 votes
3 answers
10k views

Node.js restify with socket.io

Is it possible to run socket.io & restify on the same port like express & socket.io? I did just like this but it didn't work # server.coffee restify = require 'restify' socket = require '...
Nick Sanders's user avatar
14 votes
2 answers
8k views

The consequences of not calling next() in restify

I've been using Restify for some time now. I ran across some code that lacks next() and it occurred to me that I'm not sure if I fully understand the reason why next() should be called after res.send()...
stockholmux's user avatar
  • 1,197
13 votes
9 answers
16k views

Cannot find module dtrace-provider

I have a simple nodejs application that is throwing "Cannot find module './build/Release/DTraceProviderBindings'". I look it up online and it looks like that a lot of people are having the same ...
Ernani's user avatar
  • 1,009
13 votes
1 answer
5k views

How to use Restify's RequestLogger?

RequestLogger Sets up a child bunyan logger with the current request id filled in, along with any other parameters you define. server.use(restify.requestLogger()); Registering the plugin does not ...
Gajus's user avatar
  • 71.4k
13 votes
5 answers
30k views

RESTify on Node.js POST body / json

I am in need of help. I am POSTing json data to my node server. The node server is using RESTify for its API. I am having trouble getting req.body.name from the body of the posted data. The posted ...
Danny BoyWonder's user avatar
11 votes
1 answer
10k views

What is the best way to implement a token-based authentication for restify.js?

I'm trying to build a RESTful api with restify.js, but I don't want to expose the api to everyone. And I'm going to use token-based authentication. The process in my mind is like this, I'm not sure ...
user2440712's user avatar
11 votes
5 answers
8k views

How to change the default error output in restify

Is there any way that I can change the default error output? Say I'm going to change the rest error output: { "code": "InvalidArgumentError", "message": "blah blah..." } to: { "code": ...
Finian Lau's user avatar
11 votes
1 answer
7k views

Restify Middleware - correctly calling next middleware in stack

I am using Restify with Nodejs and I have a question on the correct way of returning control to the next middleware in stack. I hope I am using the correct phrase when I say "next middleware in stack"....
callmekatootie's user avatar
11 votes
3 answers
8k views

How to make a clean architecture for RestAPI on NodeJs

I'm thinking to move some REST Services to NodeJS. The only thing I'm worry about is the architecture of this kind of solution. Do it exist somewhere some guideline? Of course, I saw some library ...
Yohann's user avatar
  • 129
10 votes
2 answers
10k views

How can I get the client IP from a request object with Restify?

I'm having a difficult time finding how to access the IP address of the REST client from a route. server.get('api/foo', function(req, res, next) { // How can I access the IP address of the ...
Coder1's user avatar
  • 13.3k
10 votes
1 answer
553 views

Dynamic dropping of handlers in restify

Context I am trying to build a dynamic server with restify (2.6.2) where services are to be installed and uninstalled once the server is started. I realized this can be seen as something odd but it ...
Javier Vélez's user avatar
9 votes
2 answers
7k views

Restify and Angular CORS No 'Access-Control-Allow-Origin' header is present on the requested resource

I faced with that problem when implementing REST api with Restify secured with bearer token authorization type. when I sending simple get request to API server it fails with CORS problem 405 (...
Ph0en1x's user avatar
  • 10k
9 votes
2 answers
11k views

Node.js + Serve Static Files with RESTIFY

I have a multi-level collection of .html, .js, .png, .css, etc files in a site. A peek at my site hiearchy looks like the following: index.html child1 index.html page1.html page2.html ... ...
user2871401's user avatar
  • 1,887
9 votes
2 answers
8k views

location object expected, location array not in correct format

I have spent doing such a straight forward thing. I just want to do a CRUD operation on a user model using nodejs, mongoose, restify stack. My mongo instance is on mongolab. The user should contain a ...
shaun's user avatar
  • 185
9 votes
5 answers
5k views

node js using express and restify together in one app

I am using restify building apis, it works great. But I need to render some web pages as well in the same application. Is it possible I can use express and restify together in one application? this ...
wwli's user avatar
  • 2,651
8 votes
2 answers
12k views

Get restify REST API server to support both HTTPS and HTTP

I am using node.js restify ver4.0.3 The simple following code works as a simple REST API server that supports HTTP. An example API call is http://127.0.0.1:9898/echo/message var restify = require('...
guagay_wk's user avatar
  • 27.3k
8 votes
2 answers
7k views

Restify: API version in URL

Currently under development of API with restify and still cannot get used to specifying the API version in headers. It just doesn't seem very user friendly. Is there any way for version to be part of ...
Tomas's user avatar
  • 2,706
8 votes
2 answers
2k views

CORS-enabled server not denying requests

I am trying to use express Cors with my resitfy server and it doesn't seem to be denying requests coming from other ips. I am working locally so I tried setting origin to a random public ip but all of ...
Sam Munroe's user avatar
  • 1,339
8 votes
2 answers
25k views

Node Js - Identify if the request is coming from mobile or non-mobile device

I'm still new with node js. Is there any workaround or methods on how to identify the request from client-side is from mobile or non-mobile devices using node js? Because what i'm doing now is i want ...
DMDJ's user avatar
  • 377
8 votes
1 answer
4k views

throttle per url in node.js restify

The documentation states: Note that you can always place this on per-URL routes to enable different request rates to different resources (if for example, one route, like /my/slow/database is ...
ilovett's user avatar
  • 3,288
8 votes
2 answers
3k views

Combine output of 2 queries in REST API

I am using node.js restify module. I have a REST API which outputs the result of a single MySQL query in json. Here is the code of the API; var rest_api_get_list = function (app, url_name) { ...
user avatar
8 votes
3 answers
10k views

Node.js, restify and proper routing

I'm still wrapping my head around Node, but I have a very simple question. I see a lot of node examples where people are declaring their routes and all their logic in a single app.js file (or ...
pilotguy's user avatar
  • 639
7 votes
1 answer
2k views

restify.serveStatic is not a function error

I am using following script but this script is throwing error that serveStatic is not a function I have installed restify using this command "npm install --save restify" var restify = require('...
Tushar's user avatar
  • 167
7 votes
1 answer
18k views

Testing CORS with cURL [duplicate]

I've been implementing CORS in a lil app I have using node-restify to test it out and it turns out that in the browser, the behaviour is as expected, this means, in a different origin with CORS ...
David Dias's user avatar
  • 1,802
7 votes
4 answers
2k views

JavaScript leaking memory (Node.js/Restify/MongoDB)

Update 4: By instantiating the restify client (see controllers/messages.js) outside of the function and calling global.gc() after every request it seems the memory growth rate has been reduced a lot (~...
ndsc's user avatar
  • 1,203
7 votes
1 answer
8k views

How to make synchronous call with mongoose and nodejs

I'm designing a client/server synchronization feature. The client sends a bunch of changed events to server. The server will do creation, deletion or modification upon requested item status. After the ...
duckegg's user avatar
  • 1,389
6 votes
1 answer
3k views

Can Express.Js output minified JSON?

I'm currently switching from restified to Express, and I noticed that the output of res.send({}) in Express has pretty-printed JSON with white space, while the Restify output is minified without white ...
Killroy's user avatar
  • 919
6 votes
2 answers
668 views

'headers already sent' error while using restify with socket.io

I'm following official restify guide to use socketio with restify. api.js var mongoose = require('mongoose'); var restify = require('restify'); var fs = require('fs'); var server = restify....
Eray's user avatar
  • 7,088
6 votes
1 answer
3k views

Node.js Restify - Simple service

I'm trying to make a server which stores Json posts, here is the server so far: var restify = require('restify'); var server = restify.createServer(); server.post('/message/', function create(req, ...
Federico Lenzi's user avatar
6 votes
3 answers
8k views

Set default value for URL parameter in HTTP GET in node.js

I am using node.js restify. I have a HTTP GET request that looks like this; http://127.0.0.1//read_val?XXX=123&YYY=456&ZZZ=789 In my handling function, to retrieve the URL parameters, the ...
guagay_wk's user avatar
  • 27.3k
6 votes
4 answers
6k views

basic authentication with Node.js and restify

I'm currently developing a RESTful web service with NodeJS and restify. I have everything up and running with node-mysql for the database, but I also would like to implement HTTP Basic authentication....
Nico's user avatar
  • 1,081

1
2 3 4 5
13