Skip to content

0.5 to 1.0 Migration Tips

trentm edited this page Feb 23, 2012 · 1 revision

Tips on migrating from restify 0.5.x to 1.0.x.

  • There is no longer a restify.log singleton that you can use. You now have to create your own logger and carry it along through your modules manually. Restify now uses bunyan for logging, which is quite a bit different from the log4js used in restify 0.5.x.

  • On each API handler there is a new req.log attribute. Use it, it's good. Where by "good", it is basically the Logger instance you passed into the server and any logging with req.log will log the associated request id as the "req_id" field.

  • server option: 'log' to provide your own Bunyan logger. You probably want to.

  • can use 'after' event on restify server instead of repeating 'after' handlers/middleware on every endpoint

  • don't need a server 'version' field anymore

  • server option: serverName -> name

  • req.uriParams is gone: use req.params

  • no default handlers for restify server anymore, you likely need to:

      server.use(restify.bodyParser())
      ... and others
    
  • createServer option: 'apiVersion' is gone (I think), use optional 'version' option to routes.

  • add the name of your endpoints: server.get({path: '/foo', name: 'GetFoo'}, getFoo) This'll be in the logging, helpful for discussion and reference.

  • restify.createClient:

    • probably want restify.createJsonClient
    • drop version
    • 'retryOptions' -> 'retry'
    • need 'name' field now
    • 'log' arg is now a Bunyan logger
  • client.get() signature change (ditto head, put, post, del):

    • not an input obj, instead client.put(path, payload, callback)
    • callback is now function (err, req, res, obj) {}, at least for JsonClient.
  • res.sendError() is gone. See http://mcavage.github.com/node-restify/#Error-handling

  • res.newError() is gone. See http://mcavage.github.com/node-restify/#Error-handling