Basic Node.js API server using Restify

npm install api-server-basic
1 downloads in the last day
11 downloads in the last week
23 downloads in the last month


Basic Node.js API server that uses Restify and logs in JSON-format to stderr.

Build Status Dependency Status



npm install -S api-server-basic
# install and add to your package.json as a dependency


var serverBuilder = require('api-server-basic')

var requiredParams = {
  port: 0,
    // 0 = server will assign a port. Can be any port number
  name: 'My server',
    // used in logging and if someone does curl --head http://your-server.com/
  routes: aFunctionThatWillBeCalledToConfigureRoutes
    // will be called with opts that include opts.server == <the new server that was setup>

var optionalParams = {
  log: aBunyanCompatableLogger,
  logBeforeRouting: false // Default false. Set to true to log all requests before routing occurs.

var serverData = serverBuilder(requiredParams)

Starting the server


  • convenience function to start
  • Returns a promise that is fulfilled with an object { port: <the actual port listened on> }


  • convenience function to start the server listening.
  • Calls the callback once the server is listening.


  • the server itself


  • the port the server is listening on, which is only set after the server is listening.

serverData.server.log({something: 'that you want to log'}, "this is a message to show that you can log stuff")

  • server log will appear on stderr in JSON format

Run tests

npm install
make test



npm loves you