Skip to content

Instantly share code, notes, and snippets.

@rodrigobdz
Last active January 27, 2018 15:28
Show Gist options
  • Save rodrigobdz/506ca6a41f220c6dcb1b57d0fa788aaa to your computer and use it in GitHub Desktop.
Save rodrigobdz/506ca6a41f220c6dcb1b57d0fa788aaa to your computer and use it in GitHub Desktop.
Run a single Parse Server function using node
// Sublime Text - Build System for Javascript
//
// Created using the instructions shown in
// https://gist.github.com/corbanb/d0d6bdcfbd8eb455ce99
{
"cmd": ["/usr/local/bin/node", "$file"],
"selector": "source.js",
}
{
"name": "parse_server_run",
"version": "0.0.1",
"description": "Runs a single parse server function",
"preferGlobal": "false",
"bin": {
"parse_server_run": "parse_server_run.js"
},
"author": "Rodrigo Bermudez Schettino",
"engines": {
"node": "*"
},
"dependencies": {
"parse": "^1.10.0"
}
}
#! /usr/bin/env node
var Parse = require('parse/node')
//
// Variables to set
//
let parse_function_name = 'YOUR_PARSE_FUNCTION_NAME'
let parse_function_params = {}
const Config = {
parse: {
url: 'http://localhost:1337',
app_id: 'YOUR_APP_ID',
javascript_key: 'YOUR_JAVASCRIPT_KEY',
}
}
// Parse Server initialization
Parse.serverURL = Config.parse.url
Parse.initialize(Config.parse.app_id, Config.parse.javascript_key)
// Run Parse Server function
Parse.Cloud.run(parse_function_name, parse_function_params).then(function(result){
console.log('result ', result)
}, function(error) {
console.error('error ', error)
})
@rodrigobdz
Copy link
Author

rodrigobdz commented Sep 5, 2017

Run a single Parse Server function using node

Requirements

  • Set the variables parse_function_name, parse_function_params and Config in parse_server_run.js.

Usage

Command line

  1. Download package.json and parse_server_run.js to a common directory.
  2. Create the executable using npm link.
  3. Run the parse_server_run script in the console.

Sublime Text

  1. Install the Build System using the installation instructions from @corbanb's gist.
  2. Build the file ( Tools > Build ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment