parse-cloud-function
v1.0.1
Published
Create scalable parse cloud functions
Downloads
5
Maintainers
Readme
Parse Cloud Function
Create scalable parse cloud functions
Parse Cloud Function helps in adding middlewares to cloud functions for more clean,reusable and scalable cloud code
Installation
npm install --save parse-cloud-function
Example
A working example can be found here
Supported versions
- parse-server >= 3.0.0
- node >= 6.4
Basic Usage
//parse cloud code file
const CloudFunction = require('parse-cloud-function')
const authMiddleware = async req => {
if (!req.user) throw 'unauthorized'
return req // passes the req to the next middleware function
}
const anotherMiddleware = async req => {
req.data = 'some data'
return req
}
new CloudFunction(Parse)
.use([authMiddleware, anotherMiddleware])
.define('myFunction', async req => {
console.log(req.data) // 'some data'
return 'success'
})
Development setup
npm install && npm run dev
Contribution
- Fork the project
- Create your feature branch (
git checkout -b feature/fooBar
), or hotfix branch (git checkout -b hotfix/fooBar
) - Commit your changes (
npm run cz
) - Push to the feature branch (
git push origin feature/fooBar
), or hotfix branch (git push origin hotfix/fooBar
) - Create a new Pull Request