             options.dbName ?= process.env.POUCHDB_NAME or 'cozy'
             PouchModel.db = new Pouch options.dbName
 
-getRequests = (root) ->
-    modelPath = "#{root}/server/models/"
-    requestFile = modelPath + "requests"
+getRequests = (modelsPath) ->
+    requestFile = path.join(modelsPath, "requests")
     # get the requests file
     try requests = require requestFile
     catch err

    models = []

    # get all indexes defined in models into an array
    for file in fs.readdirSync modelPath
        try
            model = require modelPath + file
            if model?.prototype instanceof CozyModel
                models.push model

    # get all requests from the request file into an array
    for docType, requestDefinitions of requests
        model = require modelPath + docType

        for requestName, requestDefinition of requestDefinitions
            requestsToSave.push {model, requestName, requestDefinition}


    api.setupModels()

    try {requestsToSave, models} = getRequests options.modelsPath
    catch err
        log.raw err.stack
        log.error "Failed to load requests file."
