```coffeescript
devices =
    MediaServer: require "./devices/MediaServer"

upnp =
    createDevice: (name, type) -> new devices[type](name)

module.exports = upnp
```

Add some basic error handling when creating devices
user
```coffeescript
# Currently implemented devices
deviceList = [ 'MediaServer' ]

devices = {}
for deviceType in deviceList
    # device classes are in devices/<DeviceType>.coffee
    devices[deviceType] = require "./devices/#{deviceType}"

exports.createDevice = (name, type) ->
    if not type in deviceList
        return new Error "UPnP device of type #{type} is not yet implemented."

    return new devices[type](name)
```
assistant