Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Nicholas Glenn
@NickGlenn
Quick question: is it possible create a separate route object and then add it to a server object via use(), similar to Express? It would be nice to group routes and define middleware for that group in an isolated manner.
hellboy81
@hellboy81
Hi
Baris Balic
@barisbalic
@mcavage I am using restify for a couple of APIs, each of which will expose an endpoint then pipe the request through a series of middlewares, some decorate the request for later stages in the pipeline, others decorate the response. I'm not particularly happy about the way I'm arbitrarily adding to the response, but I can't think of a better way to do this. I am also using the on('after') callback to actually return the response, because I always have the ready-built response by the end of the pipeline.
Adam Creeger
@acreeger
@barisbalic Have you looked at "formatters" to decorate the response? http://mcavage.me/node-restify/#content-negotiation
Baris Balic
@barisbalic
@acreeger, I've seen that but the decoration is dependent on the route, and I would still need to res.send explicitly.
(unless I am missing something obvious)
hellboy81
@hellboy81
What is the best way to rewrite http PUT request to restify.HttpClient
http.request( {
   hostname: ..,
   port: ...,
   path: ...
   method: 'PUT'
})
the returned request stream should be used with pipe
hellboy81
@hellboy81
Is there possible with HttpClient to pipe put stream ?
Derrick
@vorpalhex
Hey, is the underlying Router exposed so I can chain my routes off of it, Express style?
Derrick
@vorpalhex
Also, does Restify not respect the order of middleware?
Amarnath Ravikumar
@amarnus
hey guys, I use the audit plugin in my app. I noticed recently that there are several log entries without a remoteAddress set. Why would that be? From the little snooping of the code that I did, I saw that the audit plugin uses req.connection.remoteAddress - should I manually patch it and use the request-ip module instead?
Matt Broadstone
@mbroadst
Hi, I'm continuously getting a "405 Method Not Allowed" when using restify with aurelia. Nothing in this restify/node-restify#284 seems to do the trick. Anyone have a second to help out here?
Baris Balic
@barisbalic
Anyone here familiar with the 'after' event callback? I suspect it is firing before my last middleware has finished doing it's bit.
avimar
@avimar
I have a client application that can't handle 404/403/etc - it's just a generic undifferentiated error so it can't process it properly. Is there a name for an API that returns 200 with the code as a message instead?
Jeff Mealo
@jmealo
I just submitted PR #896 and all of the tests run locally, however, they fail on CI. I had to make a slight revision and I think something is being cached now. Has anyone run into this?
Jeff Mealo
@jmealo
weird, I did a fresh clone and checked out my branch and now the tests fail, but they worked on my machine prior to that, womp womp
Jeff Mealo
@jmealo
@mcavage: @gergelyke: ping restify/clients#11 restify/node-restify#896
Baris Balic
@barisbalic
:fist:
Saleem
@zalym
Hi, I am having some issues when I try to send many POST requests, where the server doesn't allow us to send more than 300 messages at the same time, which is the number of connections it has configured on its end.
Is there some setting in the rectify client to reuse the same connection or to close the connection?
lukebrdn
@lukebrdn
Just updated to Node 4.2.1 and now restify is broken because dtrace is not installing. Can anybody point me in the right direction?
Dan Caragea
@terebentina
anyone managed to make restify work with SSE?
hellboy81
@hellboy81
@lukebrdn move2express
Corey Beaumont
@coreybeaumont
Anyone home? How do you prefer to do functional testing?
avimar
@avimar
@CoreySwish I do end to end testing with supertest... I actually query the API
Corey Beaumont
@coreybeaumont
This message was deleted

@avimar i’m using supertest and tape for functional testing. I’m new to both. I’m running into an issue where the test script will not complete. The actual test runs, but the test script does not conclude. Could restify be holding a connection open?

The Test:

var supertest = require('supertest');
var test = require('tape');
var app = require('../app');
var request = supertest.agent('http://localhost:8080');

test('that fantasy player predictions are returned', function(t){
  'use strict';

  request
    .get(‘/users')
    .expect(200)
    .expect('Content-type',/json/)
    .expect('Content-Encoding', 'gzip')
    .end(function(err, res){
      t.equal(2 + 3, 5);
      t.error(err, 'No error');
      t.end(err);

    });
});

You can see the tests are evaluating, but then the test stoip and i have to control+c out of the script. Any thoughts?

The output:

ubuntu@ip-123-34-56-567:~/apps/sapiv0$ npm test

> sapi@1.0.0 test /home/ubuntu/apps/sapiv0
> node test | tap-spec

    SAPI listening at http://0.0.0.0:8080

  that fantasy player predictions are returned

    ✔ should be equal
    ✔ No error
Corey Beaumont
@coreybeaumont
Ive done some checking and can see that the test script is not entering into the callback of end request.end(function(){//Not Getting Here});
Corey Beaumont
@coreybeaumont
I take that back it is entering into the callback but very slow
Tim Branyen
@tbranyen

I'd like to take a URL pathname and match it to an existing restify route handler and get the params from it. basically URL path matching.

Inputs:

/some/random/value
server.get('/some/random/:path', function() { / / });

Output:

{path: 'value'}

Maybe via some method I don't know that works like:

server.router.match('/some/random/value')

Robert Lindstädt
@eljefedelrodeodeljefe
Hi. Probably asked before: is there a way to server.end() like the node base 'http' module? I am trying to get supertest w/ tape running, but obviously the test will never end because of the socket being open.
hmm. now scrolling up there could be an answer(?) :)
Robert Lindstädt
@eljefedelrodeodeljefe

using supertest.agent( ... ) is the workaround.

Can I suggest a testing guide and or providing an .end() method. Will send PRs for both soon, if wanted.

Corey Beaumont
@coreybeaumont
@eljefedelrodeodeljefe I’d be intereted to see how you’ve set up supertest and tape. I ran into issues and moved to using jasmine and request
Matt Forster
@forstermatth
@eljefedelrodeodeljefe @CoreySwish I've been using vesln/hippie to test restify instances with good results (no hangs) - example. @eljefedelrodeodeljefe: there is a .close() method available on the server object, docs here, under Other Methods
Matt Forster
@forstermatth
@eljefedelrodeodeljefe i see that your looking for something to end the request for tests, not the server instance. ignore that second part
Corey Beaumont
@coreybeaumont
Thanks @forstermatth, Have you used jasmine? If so, how do you think it compares?
Robert Lindstädt
@eljefedelrodeodeljefe

@forstermatth exactly. I ended up using supertests.agent() method, which doesn't pull the whole server instance into your test. You must end the server after your tests then though.

@CoreySwish I reckon this is feasible. I will end up doing something like this for more complex queries:

var test = require('tape')
var supertest = require('supertest');
var server = supertest.agent("http://localhost:8080");

test('Proximity API test', function(t) {
  t.plan(1)
  function proximityTest(latAndLong,cb) {
    server
    .post('/users/positions')
    .send({
      lat_and_long: latAndLong
    })
    .expect(200)
    .end(function(err,res){
      if (err) {
        return t.fail('Route does not reply correctly')
      }
      return cb()
    })
  }
  proximityTest([52.487395, 13.394405], function() {
    proximityTest([52.488258, 13.394448], function() {
      proximityTest([52.489029, 13.394501], function() {
        t.pass('Request came through as expected')
      })
    })
  })
})

Unfortunately you can't chain supertest, but it looks okay an node-y to me.

Corey Beaumont
@coreybeaumont
@eljefedelrodeodeljefe thanks for the insight, i was getting really annoyed with the test not completing fully
Matt Forster
@forstermatth
@CoreySwish I'm running the tests using mocha, in the end they are all the same to me, just test runners.
Corey Beaumont
@coreybeaumont
How do you guys handle caching? Do you do this at the app level? At the gateway level? I’m looking at reddis vis aws elastiCache. Just looking for some ideas of implementations
Tim Branyen
@tbranyen
@CoreySwish I'm currently dealing with that myself
Hooked in falcor to restify, but after messing with its router, way overkill. I'm looking at writing a basic memoizer with cache invalidation now
Corey Beaumont
@coreybeaumont
ah I see. are you using a gateway to access the api or are your consumers hitting the restifyapp directly? I’m tyring to figure out if I implement at our gateway level (KONG) or at the restify level. I’m also just planning right now I’m averaging 100 calls per second per apache bench.
Tim Branyen
@tbranyen
Well I'm trying to get an "isomorphic" universal app thing going, so I'll be hitting restify directly
We've abstracted "routes" and "requesters" so I may just integrate that in my requester layer
avimar
@avimar
The docs mention httpsRedirector in the timers... is this available anywhere? I assume it auto-redirects from port 80 to 443 if necessary..?
Google didn't find anything...