npm.io
1.0.1 • Published 7 years ago

parse-cloud-function

Licence
MIT
Version
1.0.1
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
2

Parse Cloud Function

npm license npm semantic-release code style: prettier

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

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/fooBar), or hotfix branch (git checkout -b hotfix/fooBar)
  3. Commit your changes (npm run cz)
  4. Push to the feature branch (git push origin feature/fooBar), or hotfix branch (git push origin hotfix/fooBar)
  5. Create a new Pull Request

Keywords