1.0.2 • Published 9 years ago

dpd-beforeget v1.0.2

Weekly downloads
1
License
Apache License Ve...
Repository
github
Last release
9 years ago

dpd-beforeget

DEPRECATED

Update to latest deployd and use the built-in "beforerequest"

Old docs in case you want to use it anyway

Adds a beforeget event to standard Deployd collections.

Why

By default Deployd runs the on get logic on each result of a get request, even if, for example, the user is not logged in and should not receive any results.

Example for standard collections

ON GET event

cancelUnless(me, "You are not logged in", 401)

Front end

dpd.mycollection.get({}, function(res) {
    console.log(res) // res === []
})

This would fetch all entries from mycollection and check if the user is logged in repeatedly, for every result. Then return an empty result to the user. (or crash)

With beforeget

ON BEFOREGET event

cancelUnless(me, "You are not logged in", 401)

Front end

dpd.mycollection.get({}, function(res) {
    console.log(res) // res === {"message":"You are not logged in","statusCode":401,"status":401}
})

This time, Deployd would immediately cancel the request and return an error message to the user.

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago