Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
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?
avimar
@avimar
@GeCremeans have you check the docs? http://restify.com/
What code did you try?
Kreius
@GeCremeans
I did read through the documentation, I was trying to push a custom header with res.header, but I think I may not fully grasp how restify works for custom ones.
John MHM {freshnode}
@playeren

Hi! Noob here playing around with restify. I have a simple restify app, and I wonder why server.on('after' always fires an err, even though nothing seems amiss?
Err obj:

{"methods":["GET"],"name":"get","params":{},"spec":{"path":{},"method":"GET","versions":[],"name":"get"}}

Server.on after snip:

server.on('after', function(req, res, err){
  var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress;
  let reqStr = req.toString(),
      shortReqArr  = reqStr.split('HTTP'),
      shortReq = shortReqArr[0];
  logga(timeDate() + ' 200: ' + shortReq + ' ip: ' + ip);
   if (err) {
              console.log(timeDate() + ' server after error ' + JSON.stringify(err) + ' \n' );
            }
  next();
});
avimar
@avimar
@playeren I'm not sure -- I don't see in the docs -- maybe it's req, res, next, err ?
John MHM {freshnode}
@playeren
@avimar You mean I don't pass next as a arg in the function? I'll try that, thanks!
John MHM {freshnode}
@playeren
@avimar Yeah that was the issue - thanks again!
Yuval
@ValYouW
Just wrote a prototype batch request handler and would welcome a code review... https://github.com/ValYouW/restify-batch-handler
cAstraea
@cAstraea
Hello guys :D have a silly question I think restify might be listening on the wrong host ? Is there any way to specify this ? It binded to :: instead of localhost restify listening to http://[::]:3998
in ipv6 would be ::1 I think ?
Tri Nguyen
@tnguyen14
I am trying to use the serveStatic method like so:
server.get(/\/docs\/?.*/, restify.serveStatic({
    directory: './doc',
    default: 'index.html'
}));
however, when I go to https://myapp.com/docs/, I get this error: {"code":"ResourceNotFound","message":"/docs/"}
I think this is because if I don't define file in opts, it defaults to directory + req.path, which becomes doc/docs

this is not the desired behavior, and doesn't seem to be the behavior described in the documentation

The above route and directory combination will serve a file located in ./documentation/v1/docs/current/index.html when you attempt to hit http://localhost:8080/docs/current/.

does anyone know what I need to do to get the behavior that I wanted?
Emem Umoh
@ememumoh
Hello?
avimar
@avimar
@tnguyen14 did you figure it out?
@ememumoh Hi.
Bruno Alexandre
@balexandre
guys, how can I call an endpoint from a function inside restify (so I can re-use the call instead of extracting everything to a method and call the method)
Roman
@moltar
What is the correct way to catch and reformat errors?
Fernando Girotto
@efbgirotto
Ashish Pai
@ashishpai2
Hi Everyone,
I want to build a REST based web server. It should be scalable and lightweight. (My app won't be having any front end). Is restify the best choice i've got?
Bruno Alexandre
@balexandre
you can go with restify or express
restify is more if you only target RESTful API's and it's built on top of express anyway :)
Bruno Brant
@Bruno-Brant

@ashishpai2 I've faced the same question three times already. There are many options to consider (which, in my book, is a bit unfortunate), and there are tradeoff's to be considered.

Between Restify and Express the choice is somewhat simple: if you only need API, Restify is the best choice. Restify endpoints can be mostly seamlessly ported to Express if you need to change later.

However, both Restify and Express are "unopinionated", meaning, they don't give you any suggestion of structure. You can have all endpoints in a single file for all they care. And so they won't help you add more structure. I'd go with them only on the simplest of projects, and knowing that I may either want to discard them later on or face a real challenge once things start to get more complex.

Alternatives? You should look at Loopback, which seems very mature. There are others which I haven't considered yet, as you can see here: http://nodeframework.com/index.html#rest-api.

Oh, I ended up doing Restify two out of three.
Antonio Cambule
@acambule
Hi there, i'm new to restify and go through a tutorial http://thejackalofjavascript.com/nodejs-restify-mongolab-build-rest-api/ . I stuck on var client = restify.createJsonClient({
I have an open server and on a second terminal i want to execute a client.js node tells me: TypeError: restify.createJsonClient is not a function.
As I had that problem on the server-side before with other things i found my solution in the restify docs, but on this it seems to be ok. So any hint? Thanks
Antonio Cambule
@acambule
Ok, after all i found out... clients need restify-clients package now, and they have to be required like this: var restifyClients = require('restify-clients');
scippio
@scippio
new restify web? :grin: .... please help.. where is old documentation? :worried:
Bruno Alexandre
@balexandre
guys, I normally use server.get('/endpoint', callback); but is there a way to have all routes in a file, and in one go "attach" them to the server object? like
const routes = require('/routes');
server.get('/endpoint2', callback); // a normal route
server.routes.attach(routes); // attach all from that routes/index.js file
Dinoloop
@ParallelTask

Dinoloop has been designed from the start for gradual adoption, and you can use as little or as much dinoloop as you need. Perhaps you only want to develop some "REST APIs" using dinoloop and other REST APIs can be developed using expressjs. In this section, we will show how to create dinoloop REST API to an existing express app.

Step 1: Add HomeController (file: home.controller.ts)
import { ApiController, Controller, HttpGet } from 'dinoloop';

@Controller('/home')
export class HomeController extends ApiController {

@HttpGet('/get')
get(): string {
    return 'Hello World!';
}

}
Step 2: Mount dinoloop and bind to express instance (file: app.ts)
const app = express();
app.use(bodyParser.json());

// Dino requires express instance and base-uri to which dino will be mounted
const dino = new Dino(app, '/api');

// Dino requires express router too
dino.useRouter(() => express.Router());

// Register controller
dino.registerController(HomeController);

// Bind dino to express
dino.bind();

// These are your normal express endpoints
app.get('/home', (req, res, next) => {
res.status(200).json('Hello World!');
});

app.get('/about', (req, res, next) => {
res.status(200).json('Hello World!');
});

// Start your express app
app.listen(8088, () => console.log('Server started on port 8088'));
Dinoloop is mounted on /api and all of its controller routes/endpoints which are registered with dinoloop are also mounted on /api. Dinoloop will handle those requests which are mounted on /api i.e. /api/home/get, the other end points /home and /about which are created by expressjs are not handled by dinoloop, this way you can slowly migrate your existing express app to dinoloop or you can start writing your new REST APIs using dinoloop.

please find the reference: https://github.com/ParallelTask/dinoloop