 
   @getAuthorType =-> JAccount
 
+  capitalize = (str)-> str.charAt(0).toUpperCase() + str.slice(1)
+
   @create = permit 'create apps',
 
     success: (client, data, callback)->

        type            : String
        default         : (value)-> Inflector.slugify @name.toLowerCase()
      slug_             : String

    relationships       :
      creator           :

      {connection:{delegate}} = client
      {profile} = delegate

      if not data.name or not data.urls?.script
        return callback new KodingError 'Name and Url is required!'

      data.name = capitalize @slugify data.name

      data.manifest           ?= {}

      # Overwrite the user/app information in manifest
      data.manifest.name       = data.name
      data.manifest.authorNick = profile.nickname
      data.manifest.author     = "#{profile.firstName} #{profile.lastName}"

      # Optionals
      data.manifest.version   ?= "1.0"
      data.identifier         ?= "com.koding.apps.#{data.name.toLowerCase()}"

      app           = new JApp
        name        : data.name
        urls        : data.urls
        type        : data.type or 'web-app'
        manifest    : data.manifest
        identifier  : data.identifier
        version     : data.manifest.version
        originId    : delegate.getId()

      app.save (err)->
        return callback err  if err
