Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
avimar
@avimar
@DanielMcColgan restify is great for making a REST API. If you needed something more generic, there's express, hapi, etc... but restify focuses on REST.
@bebor the user side can create a UUID to post... which has to be checked for unique-ness, but give it back json with the new ID
Johnie Lee
@JohnieLee
I am using Promise with Restify. Is there a way to set up a catch all for errors? The uncaughtException doesn't work because that only catches errors, but doesn't handle next(err) calls.
Johnie Lee
@JohnieLee
Alternatively, would it be possible to make the exception event emitter work for parent error classes?
avimar
@avimar
@JohnieLee I've just ended up with this pattern:
    .then(function(results) {
        res.json(200,results);
        })
    .catch(function(err) {
        res.json(500, err);
        })
    .finally(next);
you can't even put res inside a .then() I think since it needs access to req,res,next
simply returning the promise would be pretty cool though, could cut most of my boilerplate.
Johnie Lee
@JohnieLee
I started hacking around and I think this pattern works. It's kind of a hack but is consistent with the design of restify
.then(function(result) {
    // do something that throws error
   throw SomeApplicationError()
})
.catch(err) {
  const wrappedError = new WrappedError(err);
  next(err);
}

server.on('Wrapped', function (req, res, err, cb) {
  // Error handler for application error
  // unwrap the error to find actual application error
  cb();
});
The motivation for that is that it is istill compatible with the middleware concept
server.get('/someEndpoint', [paramValidationMiddleware, endpointHandler, postProcessor])
scippio
@scippio
Hi...
Anybody know what is the default request timeout in the Restify client?
scippio
@scippio
Infinity? ... shiiit..
vellotis
@vellotis
you can't override it?
scippio
@scippio
no I can ... :) it's ok :)
thx
vellotis
@vellotis
Actually I reviewed the code a bit more and saw that it is a bit more complex than that. But still no timeout
you should set requestTimeout
avimar
@avimar
so.. restify logs everything to bunyan at info level. I want to try to monitor errors... 404 not found and not auth probably aren't so important, but others might be. Any suggestions? Perhaps save to bunyan based on code of http response?
This gives me something... bunyan -c 'this.msg!="handled: 200"'
Evan Francis
@ejfrancis
hello, I've got a question about how restify handles routes. if a route handler is busy, does it wait for each previous request to complete before responding to the next? or is it supposed to all happen parallel?
avimar
@avimar
@ejfrancis you mean if you have two requests to the same route? they happen in parallel. If you needed them to wait, that could probably be architected... e.g. a concurrency limit to some external API..
avimar
@avimar
There any reason the audit logger isn't sending req.user to bunyan, that I set via middleware?
avimar
@avimar
is has res so it's not like it's returning just the raw inbound information
and req.timers has the middleware I referenced...
avimar @avimar is confused
avimar
@avimar
Oh. auditlogger builds req, not just passes it along. Doh.
not sure the best way to solve that.. I like the latency and timers and stuff.
apreg
@apreg
hi
how could I rpoxify some requests with restify?
brentsmyth
@brentsmyth
Is there any way to prevent restify from augmenting the header keys?
Or maybe get some insight into why it does it?
Shahjada Talukdar
@destromas1

Guys , created a simple AUTH Server with Node.js Restify Redis Mongo

https://github.com/clevox/clevox-auth

Please feel free to contribute and use!


jgamedev
@jgamedev
hm... why no new messsages in here since August? Have ppl moved over to another forum?
jgamedev
@jgamedev
I just checked the other listed forum thou ( Google Groups) and there where a total of 2 questions for the whole year of 2016
although stackoverflow question count for Looback and Restify are kind of similar, I must admit
avimar
@avimar
@jgamedev would be weird since there's such an underlying difference.
Perhaps since restify is rather low level, there's not much "new" happening with it?
And most questions that apply to express work here, too.
jgamedev
@jgamedev
is Netflix still using it?
FrikkieRetro
@FrikkieRetro

Hi all

I am using knex and resitfy for my API server. I am trying to do the following

db('table').where({
    id: tableId
})
.then(function(stuff){...})
.then(function(morestuff){...})
.catch(function(error){
    res.send(400,{error.message});
    return next();
}

I have an after function that runs to log traffic, so calling next() is always necessary. However, this block of code gives this warning

Warning: a promise was created in a handler at domain.js:300:12 but was not returned from it
Can anyone give me some help with this?
FrikkieRetro
@FrikkieRetro
Note that when I remove the catch, i don't get this warning
avimar
@avimar
@FrikkieRetro pretty sure you need to return db....
FrikkieRetro
@FrikkieRetro
@avimar I did think so as well initially, but I got the same error
Alex Liu
@DonutEspresso
@jgamedev netflix is still using restify extensively
FrikkieRetro
@FrikkieRetro
@DonutEspresso Thanks, I have read that as well. It does the same whether I am returning db or not. I have now reverted to just suppressing the warning on bluebird
Ganesh Majhi
@ganeshmajhi
i have created a restful service using java (spring) & added dependecies using maven.. and now i want it to connect with node.js .. Any help??
Nick Parsons
@nparsons08
@aalimovs All good!
Kreius
@GeCremeans
Hello, I'm new to Restify. is there anything special you have to do for customer headers? I tried res.header to define it there, under my server options.. do I need to specify it in more places?