   , 500)
 
 
+sanitizeTask = (device, task) ->
+  task.device = device
+  task.timestamp = mongodb.Timestamp()
+  return task
+
 cluster = require 'cluster'
 numCPUs = require('os').cpus().length
 

          response.writeHead 405, {'Allow': 'GET'}
          response.end('405 Method Not Allowed')
      else if FILES_REGEX.test(urlParts.pathname)
        filename = FILES_REGEX.exec(urlParts.pathname)[1]
        if request.method == 'PUT'
          metadata = {
            SoftwareVersion : request.headers.softwareversion,

          response.end('405 Method Not Allowed')
      else if TASKS_REGEX.test(urlParts.pathname)
        if request.method == 'POST'
          deviceId = querystring.unescape(TASKS_REGEX.exec(urlParts.pathname)[1])
          if body
            # queue given task
            task = sanitizeTask(deviceId, JSON.parse(body))

            db.tasksCollection.save(task, (err) ->
              if err
